Modul:Vorlage:Vers
Zur Navigation springen
Zur Suche springen
Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | ||
Modul | Deutsch
|
Modul: | Dokumentation |
Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus
-- Export
local p = { }
function p.uc_html(c)
return "&#x" .. mw.ustring.format("%04x;", mw.ustring.codepoint(c))
end
function p.special_escape(c)
r, n = mw.ustring.gsub(c, "[a-zA-Z]", {
["a"] = "<small>○</small>"; -- äoilische Basis u. unbestimmte Silbe
["b"] = "̆"; -- Breve
["B"] = "⏜"; -- Brücke
["E"] = "<span style='font-size:xx-small;'>└─┴─┘</span>"; -- 5 Mora
["f"] = "ˌ"; -- Versfuß
["F"] = "<span style='font-size:xx-small;'>└───┘</span>"; -- 4 Mora = ganze Note
["G"] = "<span style='font-size:xx-small;'>└──╴</span>"; -- 3 Mora = 3/4 Note
["h"] = " ́"; -- Haupthebung
["H"] = "<span style='font-size:xx-small;'>──</span>"; -- 2 Mora = halbe Note
["i"] = "<span style='text-decoration:underline;'>◠</span>"; -- Indifferenz
["I"] = "◠<span style='line-height:100%;font-size:150%;'>̣</span>"; -- Indifferenz (alternativ)
["k"] = "<span style='line-height:100%;vertical-align:-40%;text-decoration:overline'><span style='vertical-align:45%;'>◡</span></span>"; -- Kürze oder Länge
["l"] = "<span style='line-height:100%;vertical-align:30%;text-decoration:underline'><span style='vertical-align:25%;'>◡</span></span>"; -- Länge oder Kürze
["m"] = "̄"; -- Macron
["M"] = "͞"; -- doppelter Macron
["n"] = " ̀"; -- Nebenhebung
["o"] = "<span style='vertical-align:-15%;font-size:small;'>(</span>◡<span style='vertical-align:-15%;font-size:small;'>)</span>"; -- optionale kurze Silbe
["s"] = "⫽"; -- Strophenende
["u"] = " "; -- unbetont (Platzhalter für Betonungszeichen)
["v"] = "/"; -- Versende
["w"] = "¦"; -- häufiges Wortende
-- [""] = ""; --
})
if n ~= 0 then return r end
return p.uc_html(c)
end
function p.do_convert (str)
str,_ = mw.ustring.gsub(str, "\\([^a-zA-Z])", p.uc_html)
str,_ = mw.ustring.gsub(str, "!!", " ‖ "); -- THIN SPACE + DOUBLE VERTICAL LINE + THIN SPACE
str,_ = mw.ustring.gsub(str, ".", {
["/"] = "—"; -- EM DASH
["-"] = "◡"; -- LOWER HALF CIRCLE
["'"] = "́"; -- COMBINING ACUTE ACCENT
["~"] = "̀"; -- COMBINING GRAVE ACCENT
["_"] = "̱"; -- COMBINING MACRON BELOW
-- ["^"] = "∧"; -- LOGICAL AND
["\n"] = "<br/>\n"; -- Line break + new line
["!"] = " | "; -- THIN SPACE + VERTICAL BAR + THIN SPACE
})
str,_ = mw.ustring.gsub(str, "%%", "×"); -- MULTIPLICATION SIGN
str,_ = mw.ustring.gsub(str, "[§$+*]", {
["§"] = "<span style='line-height:100%;vertical-align:30%;text-decoration:underline'><span style='vertical-align:25%;'>◡◡</span></span>";
["$"] = "<span style='line-height:100%;vertical-align:-40%;text-decoration:overline'><span style='vertical-align:45%;'>◡◡</span></span>";
["+"] = "<span style='font-size:x-small;vertical-align:10%;'>◡</span>";
["*"] = "<span style='font-size:x-small;vertical-align:-10%;'>◠</span>";
})
str,_ = mw.ustring.gsub(str, "\\([a-zA-Z])", p.special_escape)
return str
end
function p.convert (frame)
local str = frame.args[1]
return p.do_convert(str)
end
return p