Module:WikiLink

require('Module:StrSplit')

local p = {}

function p.wikilink(strArg) local str = mw.getCurrentFrame.args[1]

--local str = "eternity sword series [wikiterm]{custom link}" --local str = "Hy&shy;per­di&#8203;mensio&shy;n Nept&shy;unia asf "

--if (strArg ~= nil) then --   str = strArg --end mw.logObject(str) local table = strSplit(str,",\n") mw.logObject(table)

local res = "" for i,ind in ipairs(table) do       local customLink = ind:match("%{.*%}") local wikiTerm = ind:match("%[.*%]") local indSub = ind:gsub("&#8203;", "") :gsub("&shy;", "") :gsub("­","") :gsub(" -.- -","") :gsub(" -%(.*%) -","") local wikiString = " ".. ind .." " if (wikiTerm ~= nil) then mw.logObject("wikiterm: " .. wikiTerm) --indTemp = wikiTerm:gsub("[%[%]]","") --ind = ind:gsub(" ?%[.*%] ?","") wikiString = "wikipedia:".. wikiTerm:gsub("[%[%","") .."| ".. ind:gsub(" ?%[.*%] ?","") .." ]]" elseif (customLink ~= nil) then mw.logObject("customLink: " .. customLink) ind = ind:gsub(" ?%{.*%} ?",""):gsub(" ?%[.*%] ?","") wikiString = " [".. customLink:gsub("[%{%}]","") .." ".. ind:gsub("[%[%]]","") .." ] " end mw.logObject("wikistring: "..wikiString) if (i > 1) then res = res .. ", "       end res = res .. wikiString end mw.logObject("res: "..res) return res end

return p