11,796
edits
TheNightAvl (talk | contribs) No edit summary |
TheNightAvl (talk | contribs) No edit summary |
||
(8 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
[1] = {}, | [1] = {}, | ||
[2] = {list = true}, | [2] = {list = true}, | ||
} | |||
local params_inline_linkless = { | |||
[1] = {list = true}, | |||
} | } | ||
function get_SAMPAd(ipa) | function export.get_SAMPAd(ipa) | ||
local correspondences = mw.loadData("Module:IPA/SAMPA") | local correspondences = mw.loadData("Module:IPA/SAMPA") | ||
ipa = mw.ustring.gsub(ipa, "'''", "ʹʹ") | |||
ipa = mw.ustring.gsub(ipa, "''", "ʹ") | |||
for from, to in pairs(correspondences) do | for from, to in pairs(correspondences) do | ||
ipa = mw.ustring.gsub(ipa, " | ipa = mw.ustring.gsub(ipa, "([^%#])" .. from, "%1" .. to) | ||
ipa = mw.ustring.gsub(ipa, "^" .. from, to) | |||
ipa = mw.ustring.gsub(ipa, " | |||
end | end | ||
ipa = mw.ustring.gsub(ipa, "ʹʹ", "'''") | |||
ipa = mw.ustring.gsub(ipa, "ʹ", "''") | |||
ipa = mw.ustring.gsub(ipa, "%#", "") | |||
return ipa | return ipa | ||
end | end | ||
Line 40: | Line 45: | ||
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 | ||
local piece = get_SAMPAd(pre) .. '</span>' .. mw.ustring.match(escaped, "^%*([^%*]+)%*$") .. '<span class="' .. class .. '">' .. get_SAMPAd(post) | local piece = export.get_SAMPAd(pre) .. '</span>' .. mw.ustring.match(escaped, "^%*([^%*]+)%*$") .. '<span class="' .. class .. '">' .. export.get_SAMPAd(post) | ||
table.insert(pieces, piece) | table.insert(pieces, piece) | ||
end | end | ||
Line 52: | Line 57: | ||
end | end | ||
else | else | ||
i_ipa = get_SAMPAd(i_ipa) | i_ipa = export.get_SAMPAd(i_ipa) | ||
end | end | ||
if linked then | if linked then | ||
Line 69: | Line 74: | ||
local args = require("Module:parameters").process(frame:getParent().args, params) | local args = require("Module:parameters").process(frame:getParent().args, params) | ||
local language = require("Module:languages").get_by_code(args[1]) | local language = require("Module:languages").get_by_code(args[1]) | ||
return format_ipa(language, args[2], args["nolarge"], args["nopre"], args["linked"]) | |||
end | end | ||
Line 79: | Line 80: | ||
local args = require("Module:parameters").process(frame:getParent().args, params_inline) | local args = require("Module:parameters").process(frame:getParent().args, params_inline) | ||
local language = require("Module:languages").get_by_code(args[1]) | local language = require("Module:languages").get_by_code(args[1]) | ||
return format_ipa(language, args[2], true, true, true) | |||
end | |||
function export.show_inline_linkless(frame) | |||
local args = require("Module:parameters").process(frame:getParent().args, params_inline_linkless) | |||
return format_ipa({name = ""}, args[1], true, true, false) | |||
end | end | ||