Module:Infobox chord: Difference between revisions

m Restore figure space
Bcmills (talk | contribs)
attempt to add sort tags to categories
Line 88: Line 88:
local subharmonics = {}
local subharmonics = {}
for i, h in ipairs(harmonics) do
for i, h in ipairs(harmonics) do
-- find the subharmoncis from the harmonics
-- find the subharmonics from the harmonics
local gcd = utils._gcd(lcm, h)
local gcd = utils._gcd(lcm, h)
local s = lcm / gcd
local s = lcm / gcd
Line 124: Line 124:
odd_limit = denom
odd_limit = denom
end
end
end
end
-- compute tag to add for category sort order: as many "#" as the number of digits in the first harmonic
local sort_tag = ""
local first_num = page_name.match("^(%d+):")
if first_num then
first_num = tonumber(first_num)
sort_tag = "|#"
local sort_bound = 10
while sort_bound <= harmonics[1] do
sort_tag = sort_tag .. "#"
sort_bound = sort_bound * 10
end
end
end
end
Line 136: Line 149:
if prime_limit < 96 then
if prime_limit < 96 then
table.insert(infobox_data, {"[[Prime limit]]", "[[" .. prime_limit .. "-limit|" .. prime_limit .. "]]"})
table.insert(infobox_data, {"[[Prime limit]]", "[[" .. prime_limit .. "-limit|" .. prime_limit .. "]]"})
cats = cats .. "[[Category:" .. prime_limit .. "-limit chords]]"
cats = cats .. "[[Category:" .. prime_limit .. "-limit chords" .. sort_tag .. "]]"
else
else
table.insert(infobox_data, {"[[Prime limit]]", prime_limit})
table.insert(infobox_data, {"[[Prime limit]]", prime_limit})
cats = cats .. "[[Category:Just intonation chords]]"
cats = cats .. "[[Category:Just intonation chords" .. sort_tag .. "]]"
end
end


if odd_limit < 32 then
if odd_limit < 32 then
table.insert(infobox_data, {"[[Intervallic odd limit]]", "[[" .. odd_limit .. "-odd-limit|" .. odd_limit .. "]]"})
table.insert(infobox_data, {"[[Intervallic odd limit]]", "[[" .. odd_limit .. "-odd-limit|" .. odd_limit .. "]]"})
cats = cats .. "[[Category:" .. odd_limit .. "-odd-limit chords]]"
cats = cats .. "[[Category:" .. odd_limit .. "-odd-limit chords" .. sort_tag .. "]]"
else  
else  
table.insert(infobox_data, {"[[Odd limit]]", odd_limit})
table.insert(infobox_data, {"[[Odd limit]]", odd_limit})