Search code examples
luamediawikimediawiki-templates

Hyperlinking text in Lua


I have a Lua script and I want to know how I can hyperlink the right-hand side of my equations within this code.

So far I have the code:

local p = {}

p['Ag'] = Ag

I'd like to hyperlink the right-hand side of the 2nd line (the Ag) to the local server page //localhost/mediawiki/index.php/Silver. I have Googled the answer, I have also skimmed the Lua documentation (http://www.lua.org/manual/5.1/, e.g., using Ctrl+F (find) and looking for key words like hyperlinking and links) and checked some example Lua scripts I have but I still can't find any way to do this but it's so simple I'm sure there's a way.

I want this hyperlink to appear when I save this as a module on MediaWiki and call it via a template.


Solution

  • You should be able to use standard wiki syntax:

    p['Ag'] = '[//localhost/mediawiki/index.php/Silver ' .. Ag .. ']'
    

    Or if Silver is a wiki page (which I assume it is):

    p['Ag'] = '[[Silver|' .. Ag .. ']]'