Module:Infobox chord: Difference between revisions

Bcmills (talk | contribs)
No edit summary
Bcmills (talk | contribs)
No edit summary
Line 13: Line 13:
local cats = ""
local cats = ""
local errors = ""
local errors = ""
local name = frame.args["Name"]
if value_provided(name) then
local caption = "Name"
if name:match(",") then
caption = "Names"
-- removing manual line breaks
local matches
name, matches = name:gsub("<br/?>", "")
if matches > 0 then
cats = cats .. "[[Category:Todo:remove manual line breaks]]"
end
-- removing whitespaces after commas
name = name:gsub(",%s+", ",")
-- placing line breaks after commas
name = name:gsub(",", ",<br/>")
end
table.insert(infobox_data, {
caption,
name,
})
end


if utils.value_provided(frame.args["Harmonics"]) then
if utils.value_provided(frame.args["Harmonics"]) then
table.insert(infobox_data, {
"Name"
})
local harmonics = {}
local harmonics = {}
local i = 0
local i = 0
Line 36: Line 61:
local prime_limit = 1
local prime_limit = 1
local odd_limit = 1
local odd_limit = 1
local debug_data = ""


for i, h in ipairs(harmonics) do
for i, h in ipairs(harmonics) do
for j, prime in ipairs(utils.prime_factorization_raw(h)) do
for j, prime in ipairs(utils.prime_factorization_raw(h)) do
debug_data = debug_data .. "prime:" .. prime .. "<br/>"
if prime > prime_limit then
if prime > prime_limit then
prime_limit = prime
prime_limit = prime
Line 56: Line 84:
cats = cats .. "[[Category:" .. prime_limit .. "-limit chords]]"
cats = cats .. "[[Category:" .. prime_limit .. "-limit chords]]"
cats = cats .. "[[Category:" .. odd_limit .. "-odd-limit chords]]"
cats = cats .. "[[Category:" .. odd_limit .. "-odd-limit chords]]"
end
if debug_data ~= "" then
table.insert(infobox_data, {
"Debug",
debug_data,
})
end
end