Editing Module:D'ni Tools
From Guild of Archivists
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 190: | Line 190: | ||
local function parseDniWord(input | local function parseDniWord(input) | ||
local output | local output | ||
local word = mw.text.trim(input) | local word = mw.text.trim(input) | ||
Line 206: | Line 204: | ||
suffix = prefix | suffix = prefix | ||
end | end | ||
if (word == '') then | if (word == '') then | ||
Line 215: | Line 212: | ||
output = first | output = first | ||
elseif (first == '-') then | elseif (first == '-') then | ||
output = prefix..'[[Dictionary:'..word..'|'..mw.ustring.sub(word,2,-1)..']]'..suffix | output = prefix..'[[ContainsTerm::Dictionary:'..word..'|'..mw.ustring.sub(word,2,-1)..']]'..suffix | ||
elseif (last == '-') then | elseif (last == '-') then | ||
output = prefix..'[[Dictionary:'..word..'|'..mw.ustring.sub(word,1,-2)..']]'..suffix | output = prefix..'[[ContainsTerm::Dictionary:'..word..'|'..mw.ustring.sub(word,1,-2)..']]'..suffix | ||
elseif (first == '.' or first == '!' or first == '?' or first == ',') then | elseif (first == '.' or first == '!' or first == '?' or first == ',') then | ||
output = first..prefix..'[[Dictionary:'..mw.ustring.sub(word,2,-1)..'|'..mw.ustring.sub(word,2,-1)..']]'..suffix | output = first..prefix..'[[ContainsTerm::Dictionary:'..mw.ustring.sub(word,2,-1)..'|'..mw.ustring.sub(word,2,-1)..']]'..suffix | ||
elseif (last == ',') then | elseif (last == ',') then | ||
output = prefix..'[[Dictionary:'..mw.ustring.sub(word,1,-2)..'|'..mw.ustring.sub(word,1,-2)..']]'..suffix..last | output = prefix..'[[ContainsTerm::Dictionary:'..mw.ustring.sub(word,1,-2)..'|'..mw.ustring.sub(word,1,-2)..']]'..suffix..last | ||
else | else | ||
output = prefix..'[[Dictionary:'..word..'|'..word..']]'..suffix | output = prefix..'[[ContainsTerm::Dictionary:'..word..'|'..word..']]'..suffix | ||
end | end | ||
Line 250: | Line 242: | ||
else | else | ||
origArgs = frame.args | origArgs = frame.args | ||
end | end | ||
for word in ipairs(origArgs) do | for word in ipairs(origArgs) do | ||
output = output..parseDniWord(origArgs[word] | output = output..parseDniWord(origArgs[word]) | ||
end | end | ||
return output | return output |