Module:syllables: Difference between revisions
Jump to navigation
Jump to search
TheNightAvl (talk | contribs) mNo edit summary Tag: Reverted |
TheNightAvl (talk | contribs) m (Undo revision 4349 by TheNightAvl (talk)) Tag: Undo |
||
Line 1: | Line 1: | ||
local export = {} | local export = {} | ||
local m_languages = require("Module:languages") | |||
local m_parameters = require("Module:parameters") | |||
local | local params = { | ||
[1] = {required = true}, | |||
[2] = {list = true, allow_empty = true}, | |||
["caption"] = {}, | |||
local | |||
local | |||
[ | |||
} | |||
[ | |||
} | |||
[" | |||
} | } | ||
function export.make_syllables(language, caption, list) | |||
local syllables = "" | |||
function | |||
local i = 1 | local i = 1 | ||
local n_i = 1 | |||
while | while list[i] do | ||
if list[i] == "" then | |||
if | syllables = syllables .. ", " | ||
n_i = 1 | |||
else | else | ||
if n_i > 1 then syllables = syllables .. "·" end | |||
syllables = syllables .. list[i] | |||
n_i = n_i + 1 | |||
end | end | ||
i = i + 1 | |||
end | end | ||
return caption .. ': <span style="font-size:110%;">' .. syllables .. '</span>' | |||
return | |||
end | end | ||
function export.show_syllables(frame) | |||
function export. | local args = m_parameters.process(frame:getParent().args, params) | ||
local args = | return export.make_syllables(m_languages.get_by_code(args[1]), args["caption"] or "Syllabification", args[2]) | ||
end | end | ||
function export. | function export.show_hyphens(frame) | ||
local args = | local args = m_parameters.process(frame:getParent().args, params) | ||
return export.make_syllables(m_languages.get_by_code(args[1]), args["caption"] or "Hyphenation", args[2]) | |||
end | end | ||
return export | return export | ||
Revision as of 04:23, 22 August 2023
Documentation for this module may be created at Module:syllables/documentation
local export = {}
local m_languages = require("Module:languages")
local m_parameters = require("Module:parameters")
local params = {
[1] = {required = true},
[2] = {list = true, allow_empty = true},
["caption"] = {},
}
function export.make_syllables(language, caption, list)
local syllables = ""
local i = 1
local n_i = 1
while list[i] do
if list[i] == "" then
syllables = syllables .. ", "
n_i = 1
else
if n_i > 1 then syllables = syllables .. "·" end
syllables = syllables .. list[i]
n_i = n_i + 1
end
i = i + 1
end
return caption .. ': <span style="font-size:110%;">' .. syllables .. '</span>'
end
function export.show_syllables(frame)
local args = m_parameters.process(frame:getParent().args, params)
return export.make_syllables(m_languages.get_by_code(args[1]), args["caption"] or "Syllabification", args[2])
end
function export.show_hyphens(frame)
local args = m_parameters.process(frame:getParent().args, params)
return export.make_syllables(m_languages.get_by_code(args[1]), args["caption"] or "Hyphenation", args[2])
end
return export