Module:Sharpness documentation: Difference between revisions
ArrowHead294 (talk | contribs) mNo edit summary |
formatting, nits |
||
| Line 1: | Line 1: | ||
local yesno = require("Module:yesno") | local yesno = require("Module:yesno") | ||
local | local module = {} | ||
function | function module.main(frame) | ||
local in_str = frame.args["input"] | local in_str = frame.args["input"] | ||
local note = frame.args["note"] or "" | local note = frame.args["note"] or "" | ||
local notation = frame.args["notation"] or "" | local notation = frame.args["notation"] or "" | ||
-- type: "sharp" or "flat" | -- type: "sharp" or "flat" | ||
-- value: absolute value of sharpness (the "n" as in sharp-n and flat-n) | -- value: absolute value of sharpness (the "n" as in sharp-n and flat-n) | ||
-- extension: used for identifying alternative symbol set | -- extension: used for identifying alternative symbol set | ||
local type, value, extension = in_str:match("%-(%a*)(%d+)(%a*)") | local type, value, extension = in_str:match("%-(%a*)(%d+)(%a*)") | ||
-- signed sharpness | -- signed sharpness | ||
local s = tonumber(value) | local s = tonumber(value) | ||
| Line 17: | Line 17: | ||
s = -s | s = -s | ||
end | end | ||
if extension == nil then | if extension == nil then | ||
extension = "" | extension = "" | ||
end | end | ||
local out_str = "This template is used " | local out_str = "This template is used " | ||
if s == 0 then | if s == 0 then | ||
out_str = out_str | out_str = out_str | ||
| Line 35: | Line 33: | ||
out_str = out_str | out_str = out_str | ||
.. "for [[edo]]s where a sharp " | .. "for [[edo]]s where a sharp " | ||
.. ((s < 0) and "lowers" or "raises") .. " by " .. math.abs(s) .. " step" | .. ((s < 0) and "lowers" or "raises") | ||
.. " by " | |||
.. math.abs(s) | |||
.. " step" | |||
if math.abs(s) ~= 1 then | if math.abs(s) ~= 1 then | ||
out_str = out_str .. "s" | out_str = out_str .. "s" | ||
end | end | ||
out_str = out_str .. "." | out_str = out_str .. "." | ||
if notation == "" then | if notation == "" then | ||
out_str = out_str .. " This symbol set " | out_str = out_str .. " This symbol set " | ||
if math.abs(s) == 1 then | if math.abs(s) == 1 then | ||
out_str = out_str .. "is identical to standard notation." | out_str = out_str .. "is identical to standard notation." | ||
| Line 51: | Line 52: | ||
if extension == "" then | if extension == "" then | ||
if math.abs(s) == 2 then | if math.abs(s) == 2 then | ||
out_str = out_str .. "comprises sharps, flats, and Stein–Zimmerman [[24edo #Notation|quartertone]] accidentals." | out_str = out_str | ||
.. "comprises sharps, flats, and Stein–Zimmerman [[24edo #Notation|quartertone]] accidentals." | |||
else | else | ||
out_str = out_str .. "is based on [[ups and downs notation]] and comprises sharps, flats, " | out_str = out_str | ||
.. "is based on [[ups and downs notation]] and comprises sharps, flats, " | |||
.. (s % 2 == 0 and "naturals, and Stein–Zimmerman [[24edo #Notation|quartertone]] accidentals " or "and naturals ") | |||
.. "with arrows from [[Helmholtz–Ellis notation]]." | |||
end | end | ||
elseif extension == "a" or extension == "A" then -- extension for modern-style ups and downs | elseif extension == "a" or extension == "A" then -- extension for modern-style ups and downs | ||
| Line 66: | Line 67: | ||
out_str = out_str .. " It is based on " .. notation .. "." | out_str = out_str .. " It is based on " .. notation .. "." | ||
end | end | ||
-- display custom note | -- display custom note | ||
if note then | if note then | ||
out_str = out_str .. " " .. note | out_str = out_str .. " " .. note | ||
end | end | ||
-- display the note about supersets of 12edo for sharpness-1 and above | -- display the note about supersets of 12edo for sharpness-1 and above | ||
if s >= 1 then | if s >= 1 then | ||
local n_edo = s * 12 -- edo number for supersets of 12edo | |||
out_str = out_str | out_str = out_str | ||
.. "\n\n<h3>Parameters</h3>\n" | .. "\n\n<h3>Parameters</h3>\n" | ||
.. "Passing <code>{{pipe}}" | .. "Passing <code>{{pipe}}" | ||
.. | .. n_edo | ||
.. "</code> will change '''Step offset''' to '''Semitones''' in the case of [[" | .. "</code> will change '''Step offset''' to '''Semitones''' in the case of [[" | ||
.. | .. n_edo | ||
if | .. "edo]]" | ||
out_str = out_str .. ", since " .. | if s >= 2 then | ||
out_str = out_str .. ", since " .. n_edo .. "edo is a superset of [[12edo]]" | |||
end | end | ||
out_str = out_str .. "." | out_str = out_str .. "." | ||
end | end | ||
-- display the see also section for sharpness-3 and above | -- display the "see also" section for sharpness-3 and above | ||
if s >= 3 or (s == 2 and (extension == "a" or extension == "A")) then | if s >= 3 or (s == 2 and (extension == "a" or extension == "A")) then | ||
out_str = out_str | out_str = out_str .. "\n\n<h3>See also</h3>\n" .. "* [[Alternative symbols for ups and downs notation]]" | ||
end | end | ||
end | end | ||
local | local is_debug = yesno(frame.args["debug"]) | ||
return frame:preprocess( | return frame:preprocess(is_debug == true and "<pre>" .. out_str .. "</pre>" or out_str) | ||
end | end | ||
return | return module | ||