Module:MOS scalesig: Difference between revisions
Jump to navigation
Jump to search
remove preprocessing function, as expected input will always be unparsed scalesigs |
ArrowHead294 (talk | contribs) mNo edit summary |
||
(10 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
local p = {} | |||
local getArgs = require("Module:Arguments").getArgs | |||
local mos = require("Module:MOS") | local mos = require("Module:MOS") | ||
local yesno = require("Module:Yesno") | local yesno = require("Module:Yesno") | ||
-- | -- "Main" function; calls appropriate mos-string functions | ||
function p._mos_scalesig(input_mos, is_link, is_long) | function p._mos_scalesig(input_mos, is_link, is_long) | ||
local is_link = yesno(is_link, false) | local is_link = yesno(is_link, false) -- Should the the scalesig be a link? | ||
local is_long = yesno(is_long, false) | local is_long = yesno(is_long, false) -- Should the scalesig be in the long form "xL ys (p/q-equivalent)"? | ||
return (is_link == true | |||
and (is_long and mos.as_long_link(input_mos) or mos.as_link(input_mos)) | |||
or (is_long and mos.as_long_string(input_mos) or mos.as_string(input_mos))) | |||
end | end | ||
-- Wrapper function | -- Wrapper function | ||
function p.mos_scalesig(frame) | function p.mos_scalesig(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
Line 28: | Line 22: | ||
local is_link = yesno(args["link"], false) | local is_link = yesno(args["link"], false) | ||
local is_long = yesno(args["long"], false) | local is_long = yesno(args["long"], false) | ||
local debugg = yesno(args["debug"]) | |||
local result = p._mos_scalesig(input_mos, is_link, is_long) | |||
-- Debugger option | |||
if debugg == true then | |||
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" | |||
end | |||
return | return frame:preprocess(result) | ||
end | end | ||
function p.tester() | function p.tester() | ||
local input_mos = mos.new(5,2) | local input_mos = mos.new(5, 2) | ||
return p._mos_scalesig(input_mos, true, true) | return p._mos_scalesig(input_mos, true, true) | ||
end | end | ||
return p | return p |
Latest revision as of 12:47, 1 June 2025
Note: Do not invoke this module directly; use the corresponding template instead: Template:MOS scalesig.
This module formats a string into a mos scale signature, with non-breaking spaces. Scale signatures can optionally be formatted as a link to the scale's wiki page.
To include this module in other modules, uselocal mos_scalesig = require("Module:MOS scalesig")._mos_scalesig
.
local p = {}
local getArgs = require("Module:Arguments").getArgs
local mos = require("Module:MOS")
local yesno = require("Module:Yesno")
-- "Main" function; calls appropriate mos-string functions
function p._mos_scalesig(input_mos, is_link, is_long)
local is_link = yesno(is_link, false) -- Should the the scalesig be a link?
local is_long = yesno(is_long, false) -- Should the scalesig be in the long form "xL ys (p/q-equivalent)"?
return (is_link == true
and (is_long and mos.as_long_link(input_mos) or mos.as_link(input_mos))
or (is_long and mos.as_long_string(input_mos) or mos.as_string(input_mos)))
end
-- Wrapper function
function p.mos_scalesig(frame)
local args = getArgs(frame)
local input_mos = mos.parse(args["scalesig"])
local is_link = yesno(args["link"], false)
local is_long = yesno(args["long"], false)
local debugg = yesno(args["debug"])
local result = p._mos_scalesig(input_mos, is_link, is_long)
-- Debugger option
if debugg == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
function p.tester()
local input_mos = mos.new(5, 2)
return p._mos_scalesig(input_mos, true, true)
end
return p