Module:syllables: Difference between revisions

m
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
m (Added variable delimiter)
mNo edit summary
Line 10: Line 10:
}
}


function export.make_syllables(language, caption, list)
function export.make_syllables(language, caption, list, delimiter)
local syllables = ""
local syllables = ""
local i = 1
local i = 1
local n_i = 1
local n_i = 1
local delimiter = args["delimiter"] or "·"
local split = delimiter or "·"
while list[i] do
while list[i] do
if list[i] == "" then
if list[i] == "" then
Line 20: Line 21:
n_i = 1
n_i = 1
else
else
if n_i > 1 then syllables = syllables .. delimiter end
if n_i > 1 then syllables = syllables .. split end
syllables = syllables .. list[i]
syllables = syllables .. list[i]
n_i = n_i + 1
n_i = n_i + 1
Line 31: Line 32:
function export.show_syllables(frame)
function export.show_syllables(frame)
local args = m_parameters.process(frame:getParent().args, params)
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])
return export.make_syllables(m_languages.get_by_code(args[1]), args["caption"] or "Syllabification", args[2], args["delimiter"])
end
end


function export.show_hyphens(frame)
function export.show_hyphens(frame)
local args = m_parameters.process(frame:getParent().args, params)
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])
return export.make_syllables(m_languages.get_by_code(args[1]), args["caption"] or "Hyphenation", args[2], args["delimiter"])
end
end


return export
return export