local p = {};
local year = {};
year = "early 2<sup>nd</sup>";
local lines = {}; local text = {}; local tr = {}; local t = {};
local roman = {};
roman = "I";
roman = "II";
roman = "III";
roman = "IV";
roman = "V";
roman = "VI";
roman = "VII";
local reg = "<(+):(+)>";
local reg_simple = "<(+)>";
local function wrapInCollapsible(always, off, on)
return
'<div class="vsSwitcher" data-toggle-category="inscriptions" style="width:fit-content">'
.. always
.. '<span class="vsHide">'
.. off
.. '</span><span class="vsToggleElement" style="margin-left: 1em;"></span>'
.. '<div class="vsHide" style="display:block">\n'
.. on
.. '</div></div>';
end
local function formatText(here_text, isLemma, bold, indent)
local final_bold;
if (isLemma) then
here_text, _ = here_text:gsub(reg, function (str, id)
id = id:gsub("%-.+", ""); local str_display = str:gsub("%", ""); str = str:gsub("]", "")
if (id == bold) then return "''']'''";
else return "]"; end
end);
else
here_text, _ = here_text:gsub(reg, function (str, id)
local str_display = str:gsub("%", ""); str = str:gsub("]", "")
if (str == bold) then final_bold = id; return "'''" .. str_display .. "'''";
else return str_display; end
end)
end
here_text = here_text:gsub("{", "<span class=\"Ital\" lang=\"xum\">"):gsub("}", "</span>")
:gsub("(+a?)", "<sup>%1</sup>"):gsub("%.", "")
return indent .. here_text .. "\n", final_bold;
end
local function format(here_tr, bold, it, isLemma, indent)
local function boldify (str, id)
if (id == bold) then return "'''" .. str .. "'''";
elseif (isLemma) then
if (id:gsub("%-.+", "") == bold) then return "'''" .. str .. "'''";
else return str; end
else return str; end
end
local r, _ = here_tr:gsub(reg, boldify):gsub(reg_simple, function (x) return boldify(x, x) end)
if (it) then return indent .. ":''" .. r .. "''\n";
else return indent .. ":" .. r .. "\n"; end
end
local function getEntry(table, quote, precise, isLemma, bold, trad, indent)
local r = "";
local r_;
local here_text, here_tr;
if (precise == nil) then here_text = text; here_tr = tr;
else here_text = text; here_tr = tr end
if (here_text:match(",")) then
for v in string.gmatch(here_text, "(+)") do
r_, _ = getEntry(table, quote, v, isLemma, bold, false, indent);
r = r .. r_;
end
else
r_, bold = formatText(here_text, isLemma, bold, indent);
r = r .. r_;
if (here_tr ~= nil) then r = r .. format(here_tr, bold, true, isLemma, indent); end
end
if (trad) then r = r .. format(t, bold, false, isLemma, indent);
else
local here_t = t;
if (here_t ~= nil) then r = r .. format(here_t, bold, false, isLemma, indent); end
end
return r, bold;
end
function p.quote(frame)
local number = frame.args;
local face = frame.args;
local table = number .. face;
local list = require("Module:User:Catonif/RQ:xum:TI/" .. table);
lines = list;
text = list;
tr = list;
t = list;
local here_year = year;
local quote = frame.args;
local precise = frame.args; if (precise == "") then precise = nil; end
local here_lines;
if (precise == nil) then
here_lines = lines;
else
here_lines = lines;
if (here_lines == nil) then
here_lines = "line " .. precise;
end
end
local always = "'''" .. here_year .. " century <small class='ce-date'>]</small>''', '']'', table " .. roman .. ", face " .. face:upper() .. " ( .. face .. ".jpg photo]; ), " .. here_lines;
local show = ":\n";
local bold = frame.args;
local isLemma = frame.args == "1";
local indent = ":";
local hide = getEntry(table, quote, precise, isLemma, bold, true, indent);
local r = wrapInCollapsible(always, show, hide);
return r;
end
return p;