Module:IPA: Difference between revisions

ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 48: Line 48:
local pieces = {}
local pieces = {}
for pre, escaped, post in mw.ustring.gmatch(i_ipa, "([^%*]*)(%*[^%*]+%*)([^%*]*)") do
for pre, escaped, post in mw.ustring.gmatch(i_ipa, "([^%*]*)(%*[^%*]+%*)([^%*]*)") do
table.insert(pieces, get_SAMPAd(pre) .. '</span>' .. mw.ustring.match(escaped, "^%*([^%*]+)%*$") .. '<span class="' .. class .. '">' .. get_SAMPAd(post))
local piece = get_SAMPAd(pre) .. '</span>' .. mw.ustring.match(escaped, "^%*([^%*]+)%*$") .. '<span class="' .. class .. '">' .. get_SAMPAd(post)
table.insert(pieces, piece)
end
end
i_ipa = table.concat(pieces)
i_ipa = table.concat(pieces)
i_ipa = mw.ustring.gsub(i_ipa, "(%s+)(%<%/span%>)(%S)", "%2%1%3")
i_ipa = mw.ustring.gsub(i_ipa, '(%S+)(%<span class%=%"' .. class .. '%"%>)(%s)', "%1%3%2")
else
else
i_ipa = get_SAMPAd(i_ipa)
i_ipa = get_SAMPAd(i_ipa)
Line 56: Line 59:
if linked then
if linked then
out = out .. "[[" .. language_pron .. "|" .. i_ipa .. "]]"
out = out .. "[[" .. language_pron .. "|" .. i_ipa .. "]]"
out = mw.ustring.gsub(out, "(%<%/span%>)", "]]%1")
out = mw.ustring.gsub(out, '.(%<span class%=%"' .. class .. '%"%>)', "%1[[" .. language_pron .. "|")
else
else
out = out .. i_ipa
out = out .. i_ipa