Module:Infobox interval: Difference between revisions
mNo edit summary |
m Better FJS name parsing, more categories |
||
| Line 52: | Line 52: | ||
ratio_string = frame.args['Ratio'] or '' | ratio_string = frame.args['Ratio'] or '' | ||
end | end | ||
end | |||
local infobox_data = {} | |||
local cats = '' | |||
if rational then | |||
cats = cats .. '[[Category:Rational intervals]]' | |||
else | |||
cats = cats .. '[[Category:Irrational intervals]]' | |||
end | |||
if regular and rational then | |||
local prime_limit = 2 | |||
if not rat.eq(ratio, 1) then | |||
prime_limit = rat.max_prime(ratio) | |||
end | |||
cats = cats .. '[[Category:' .. prime_limit .. '-limit]]' | |||
end | end | ||
| Line 62: | Line 78: | ||
table.insert(special_properties, '[[Superparticular interval|superparticular]]') | table.insert(special_properties, '[[Superparticular interval|superparticular]]') | ||
end | end | ||
cats = cats .. '[[Category:Superparticular]]' | |||
end | end | ||
end | end | ||
| Line 70: | Line 87: | ||
if rat.is_harmonic(ratio) then | if rat.is_harmonic(ratio) then | ||
table.insert(special_properties, '[[harmonic]]') | table.insert(special_properties, '[[harmonic]]') | ||
cats = cats .. '[[Category:Harmonics]]' | |||
elseif rat.is_harmonic(ratio, true, not small) then | elseif rat.is_harmonic(ratio, true, not small) then | ||
table.insert(special_properties, '[[Harmonic|reduced harmonic]]') | table.insert(special_properties, '[[Harmonic|reduced harmonic]]') | ||
cats = cats .. '[[Category:Octave-reduced harmonics]]' | |||
end | end | ||
if rat.is_subharmonic(ratio) then | if rat.is_subharmonic(ratio) then | ||
table.insert(special_properties, '[[subharmonic]]') | table.insert(special_properties, '[[subharmonic]]') | ||
cats = cats .. '[[Category:Subharmonics]]' | |||
elseif rat.is_subharmonic(ratio, true, not small) then | elseif rat.is_subharmonic(ratio, true, not small) then | ||
table.insert(special_properties, '[[Subharmonic|reduced subharmonic]]') | table.insert(special_properties, '[[Subharmonic|reduced subharmonic]]') | ||
cats = cats .. '[[Category:Octave-reduced subharmonics]]' | |||
end | end | ||
end | end | ||
| Line 170: | Line 182: | ||
caption = 'Names' | caption = 'Names' | ||
-- removing manual line breaks | -- removing manual line breaks | ||
name = name:gsub('<br/>', '') | name = name:gsub('<br/?>', '') | ||
-- removing whitespaces after commas | -- removing whitespaces after commas | ||
name = name:gsub(',%s+', ',') | name = name:gsub(',%s+', ',') | ||
| Line 201: | Line 213: | ||
if (not FJS_name or #FJS_name == 0) and rational and regular then | if (not FJS_name or #FJS_name == 0) and rational and regular then | ||
FJS_name = rat.as_FJS(ratio) | FJS_name = rat.as_FJS(ratio) | ||
elseif FJS_name and #FJS_name > 0 then | |||
FJS_name = FJS_name:gsub('%s', '') | |||
FJS_name = FJS_name:gsub('<br/?>', '') | |||
FJS_name = FJS_name:gsub('<sup>(.*)</sup>', '^{%1}') | |||
FJS_name = FJS_name:gsub('<sub>(.*)</sub>', '_{%1}') | |||
cats = cats .. '[[Category:Todo:remove manually set FJS name]]' | |||
end | end | ||
if FJS_name and #FJS_name > 0 then | if FJS_name and #FJS_name > 0 then | ||