Module:MOS scalesig: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
Ganaram inukshuk (talk | contribs)
remove tester; merge functions (check if anything breaks)
Line 5: Line 5:
local yesno = require("Module:Yesno")
local yesno = require("Module:Yesno")


-- "Main" function; calls appropriate mos-string functions
-- Wrapper function; calls mos module's to-string and to-link 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)
function p.mos_scalesig(frame)
local args = getArgs(frame)
local args = getArgs(frame)
Line 23: Line 13:
local is_long = yesno(args["long"], false)
local is_long = yesno(args["long"], false)
local debugg = yesno(args["debug"])
local debugg = yesno(args["debug"])
local result = p._mos_scalesig(input_mos, is_link, is_long)
function make_scalesig()
if is_link then
-- Text is a link to the mospage
-- Long link links to and displays "xL ys (p/q-equivalent)"
-- (Short) link instead displays "xL ys<p/q>"
-- Has no effect if it's octave-equivalent.
return (is_long and mos.as_long_link(input_mos) or mos.as_link(input_mos))
else
-- Text is the scalesig, with nbsp and appropriate brackets added
-- Long string displays "xL ys (p/q-equivalent)"
-- (Short) string instead displays "xL ys<p/q>"
-- Has no effect if it's octave-equivalent.
return (is_long and mos.as_long_string(input_mos) or mos.as_string(input_mos))
end
end
local result = make_scalesig()
-- Debugger option
-- Debugger option
Line 31: Line 38:
return frame:preprocess(result)
return frame:preprocess(result)
end
function p.tester()
local input_mos = mos.new(5, 2)
return p._mos_scalesig(input_mos, true, true)
end
end


return p
return p