local mSep = require('Module:Separated entries')local getArgs = require('Module:Arguments').getArgs
local p =
-- Some of the characters used do not render properly on all browsers.local svaraDesc = mw.loadData('Module:Svara/equivalents')local svaraResolve = mw.loadData('Module:Svara/resolve')
-- Convert shorthand notation into standard notation.function p.resolve(input, type) local svaras = svaraResolve[type]
for key, value in pairs(input) do if svaras[value] then input[key] = svaras[value]; end end
return inputend
-- Called by the svaraC template-- print(p.carnatic)function p.carnatic(frame) -- Carnatic notation is case-insensitive. Enable the capitalise option. local input = p.sanitiseArgs(frame, true) input = p.resolve(input, "carnatic")
return p._main(frame, input, 'carnatic')end
-- Called by the svaraH template-- print(p.hindustani)function p.hindustani(frame) local input = p.sanitiseArgs(frame) input = p.resolve(input, "hindustani")
return p._main(frame, input, 'hindustani')end
-- Get the equivalent note in other notation standards.-- print(p.getEquivalents('carnatic'))function p.getEquivalents(frame, args, type) local output = local western = local alternate = local altType = "" local altText = "" local entry
if (type
for key, value in pairs(args) do if svaraDesc[value] then entry = svaraDesc[value] alternate[key] = entry[altType]; western[key] = entry["western"]; end end
output = frame:expandTemplate output = "Alternate notations:" .. output return outputend
-- Generates the output.function p._main(frame, input, type) local foot = nil local abbr = true local svaras = if input['foot'] then foot = true input['foot'] = nil end
if input['abbr'] then abbr = false input['abbr'] = nil end for key, value in pairs(input) do svaras[key] = value
if (abbr) then if type ~= "western" and svaraDesc[value] then -- Use the abbr tag to add a description; avoid the default dotted -- underline style as it messes up the macrons. svaras[key] = frame:expandTemplate end end end
svaras['separator'] = " " local output = mSep.main(svaras)
if (foot) then local equivalents = p.getEquivalents(frame, input, type) output = output .. frame:expandTemplate end return outputend
-- Currently cleans up and returns the input.function p.sanitiseArgs(frame, capitalise) local args = getArgs(frame)
-- Capitalise arguments. if (capitalise) then for key, value in pairs(args) do args[key] = mw.ustring.upper(args[key]); end end
return argsend
-- Called by the svara template.function p.main(frame) local args = p.sanitiseArgs(frame) return p._main(frame, args)end
-- Runs through the entire functionality of this module.function p.status(frame) local types = local output = for key, value in pairs(types) do local temp = "
" .. key1 .. " | " .. frame:expandTemplate -- add foot='yes' to isolate individual errors. .. " | " .. value1 .. " |
return p