Module:MOS scalesig: Difference between revisions

Ganaram inukshuk (talk | contribs)
name -> scalesig
Ganaram inukshuk (talk | contribs)
module now calls link functions from module:mos
Line 20: Line 20:
--  be 2/1-equivalent.
--  be 2/1-equivalent.
-- - is_link - Whether the scalesig is a link to its wiki page.
-- - is_link - Whether the scalesig is a link to its wiki page.
-- NOTE: args are passed in individually rather than as a table as expected use
-- includes formatting scalesig text/links for other mos-related modules.
function p._mos_scalesig(unparsed, is_link, is_long)
function p._mos_scalesig(unparsed, is_link, is_long)
local input_mos = p.preprocess_unparsed_scalesig(unparsed)
local input_mos = p.preprocess_unparsed_scalesig(unparsed)
Line 27: Line 25:
local is_long = yesno(is_long, false)
local is_long = yesno(is_long, false)
-- Link is the article name, if to be used
-- Text is the parsed scalesig
local link = mos.as_long_string(input_mos)
local text = is_long and mos.as_long_string(input_mos) or mos.as_string(input_mos)
if is_link then
if is_link then
if link == text then
return is_long and mos.as_long_link(input_mos) or mos.as_link(input_mos)
return string.format("[[%s]]", link)
else
return string.format("[[%s | %s]]", link, text)
end
else
else
return text
return is_long and mos.as_long_string(input_mos) or mos.as_string(input_mos)
end
end
end
end