Module:Infobox chord: Difference between revisions

Bcmills (talk | contribs)
Remove the (now unused) Name parameter.
Bcmills (talk | contribs)
Move color names to middle of table; make code more consistent with other multi-valued entries
Line 14: Line 14:
local cats = ""
local cats = ""


local color_name = frame.args["ColorName"]
local color_names = {}
if utils.value_provided(color_name) then
if utils.value_provided(frame.args["ColorName"]) then
local caption2 = "[[Color notation|Color name]]"
color_name = frame.args["ColorName"]
-- search for ", " not "," because many chord names contain commas, e.g. Cz,y6
-- search for ", " not "," because many chord names contain commas, e.g. Cz,y6
if color_name:match(", ") then
for name in (color_name .. ", "):gmatch("(.-), ") do
caption2 = "[[Color notation|Color names]]"
table.insert(color_names, name)
-- removing manual line breaks
local matches
color_name, matches = color_name:gsub("<br%s?/?>", "")
if matches > 0 then
cats = cats .. "[[Category:Todo:remove manual line breaks]]"
end
-- replacing every comma+whitespace(s) instance with a line break
color_name = color_name:gsub(",%s+", "<br />")
end
end
table.insert(infobox_data, {
caption2,
color_name,
})
else
else
cats = cats .. "[[Category:Todo:add color name]]"
cats = cats .. "[[Category:Todo:add color name]]"
Line 201: Line 189:
table.insert(infobox_data, {"Step intervals", table.concat(step_interval_links, ", ")})
table.insert(infobox_data, {"Step intervals", table.concat(step_interval_links, ", ")})
table.insert(infobox_data, {"Step cents", table.concat(step_cents, ", ")})
table.insert(infobox_data, {"Step cents", table.concat(step_cents, ", ")})
-- TODO: category goes here.
if table.getn(color_names) > 0 then
local label = "Color name"
if table.getn(color_names) > 1 then
label = "Color names"
end
table.insert(infobox_data, {"[[Color notation|" .. label .. "]]", table.concat(color_names, "<br/>")})
end


if prime_limit < 96 then
if prime_limit < 96 then