Module:Sandbox/Andreyyshore/Vertical header: Difference between revisions

Content deleted Content added
No edit summary
mNo edit summary
 
(18 intermediate revisions by the same user not shown)
Line 1:
local p = {}
 
function p.stack(framestr, vertAlign, noBold)
local t = {}
local strbreakPattern = frame.args"<[1bB][rR] */? *>"
local function splitLines(line)
local breakPattern = "<[bB][rR] */? *>"
table.insert(t, line)
local function splitLines(line)
return ""
table.insert(t, line)
end
return ""
local text = mw.ustring.toNFC(str):gsub("%[%[([^%[%]%|]+)%|([^%[%]%|]+)%]%]", function(a, b)
end
return "[[" .. splitLines((stra .. "|" .. b:gsub(breakPattern, "(.-)(]]<br>[[" .. breakPatterna .. ")|", splitLines))) .. "]]"
end)
for k, v in pairs(t) do
splitLines(text:gsub("(.-)(" .. breakPattern .. ")", splitLines))
t[k] = (v
for k, v in pairs(t) do
:gsub("([^'%[%]])", "%1<br>")
t[k] = (
:gsub("'([^'])", "'<br>%1")
mw.ustring.gsub(
:gsub("(''+)<br>", "%1")
: mw.ustring.gsub(v, "([^'%[%[+]])<br>", "%1<br>"),
:gsub( "<br>'(%[^']+)", "%1'<br>%1")
)
:gsub("%[%[([^%[%]]+)%]%]", function(n)
:gsub("(''+)<br>", "%1")
local inBrackets = n
:gsub("(%[%[+)<br>", "%1")
local stripped = ""
:gsub("<br>(%]+)", "%1<br>")
if inBrackets:find("%|") == nil then
:gsub("%[%[([^%[%]]+)%]%]", function(n)
inBrackets = inBrackets:gsub("<br>", "") .. "|" .. inBrackets
local inBrackets = n
else
local stripped = ""
stripped = inBrackets:match("^[^%|]+%|"):gsub("<br>", "")
inBrackets = stripped .. if inBrackets:gsubfind("^[^%|]+%|<br>",) "")== nil then
inBrackets = inBrackets:gsub("<br>", "") .. "|" .. inBrackets
end
else
return "[[" .. inBrackets .. "]]"
stripped = inBrackets:match("^[^%|]+%|"):gsub("<br>", "")
end)
inBrackets = stripped .. inBrackets:gsub("^[^%|]+%|<br>$", "")
end
)
return "[[" .. inBrackets .. "]]"
end
end)
if #t == 1 then
:gsub("<br>$", "")
return t[1]
)
end
end
local dom1 = mw.html.create("tr")
if #t == 1 then return t[1] end
local dom2
local dom1 = mw.html.create("tr")
for _, v in pairs(t) do
if noBold ~= "" then dom1:css("font-weight", "normal") end
dom1:wikitext(
local dom2
tostring(
for _, v in pairs(t) do
mw.html.create("td")
dom1:wikitext(
:css({
tostring(
["border"] = "none",
mw.html.create("td")
["padding"] = 0,
:css({
["border"] = "none",
})
["padding"] = 0,
:wikitext(v)
["vertical-align"] = vertAlign,
)
["width"] = "1em",
)
["max-width"] = "1em"
end
})
dom2 = mw.html.create("table")
:wikitext(mw.html.create("tbody"v)
)
:css("vertical-align", "inherit")
)
:wikitext(tostring(dom1))
end
)
dom2 = mw.html.create("table")
:css({
:wikitext(tostring(dom1))
["margin"] = 0,
:css({
["border-collapse"] = "collapse",
["vertical-alignmargin"] = "inheritauto",
["border-collapse"] = "collapse",
})
["vertical-align"] = "inherit"
:attr({cellspacing = 0, cellpadding = 0})
})
return tostring(dom2)
:attr({cellspacing = 0, cellpadding = 0})
return tostring(dom2)
end
 
Line 69 ⟶ 71:
local maxWidth = frame.args.maxWidth
local noBold = frame.args.noBold
local style = frame.args.style:gsub("\"", "&quot;")
local cellStyle = frame.args.cellstyle:gsub("\"", "&quot;")
local wikiText = "class = \"nowrap"
local normalAlign = ""
-- local stupidIEAlign = ""
local stack = frame.args.stack
local breakPattern = "<[bB][rR] */? *>"
local rows = 1
Line 88 ⟶ 92:
wikiText = wikiText .. " unsortable"
end
wikiText = wikiText .. "\" style=\"line-height:99%;vertical-align:" .. vertAlign .. ";padding:"
if stack == "" then
wikiText = wikiText .. "99"
else
wikiText = wikiText .. "120"
end
wikiText = wikiText .. "%;vertical-align:" .. vertAlign .. ";padding:"
if sortPadding == "" then
wikiText = wikiText .. ".4em"
Line 94 ⟶ 104:
wikiText = wikiText .. "21px"
end
if (stack ~= "" and text:find(breakPattern) ~= nil) then
wikiText = wikiText .. " .4em .2em;background-position:50% .4em !important;"
wikiText = wikiText .. "min-width:" .. width .. ";max-width:" .. width .. ";width:" .. width .. ";overflow:hidden\"2em"
wikiText = wikiText .. " | <div style=\"" .. frame:preprocess("{{writing-mode|v1}}{{Transform-rotate|180}}") .. "-ms-transform: none \ ;padding-left:1px;text-align:"
if vertAlign == "top" then
normalAlign = "right"
-- stupidIEAlign = "left"
elseif vertAlign == "middle" then
normalAlign = "center"
-- stupidIEAlign = "center"
else
wikiText = wikiText .. " .4em"
normalAlign = "left"
-- stupidIEAlign = "right"
end
wikiText = wikiText .. normalAlign" .. "2em;" background-- text-alignposition:"50% .. stupidIEAlign .. " \4em !important;"
if stack == "" then
wikiText = wikiText .. "min-width:" .. width .. ";max-width:" .. width ..
";width:" .. width .. ";overflow:hidden;" .. cellStyle .. "\""
end
wikiText = wikiText .. " | <div style=\""
if stack == "" then
wikiText = wikiText .. frame:preprocess("{{writing-mode|v1}}{{Transform-rotate|180}}") ..
"-ms-transform: none \ ;padding-left:1px;"
if vertAlign == "top" then
normalAlign = "right"
-- stupidIEAlign = "left"
elseif vertAlign == "middle" then
normalAlign = "center"
-- stupidIEAlign = "center"
else
normalAlign = "left"
-- stupidIEAlign = "right"
end
else normalAlign = "center"
end
wikiText = wikiText .. "text-align:" .. normalAlign .. ";" -- text-align:" .. stupidIEAlign .. " \ ;"
wikiText = wikiText .. style .. "\">"
local textToAdd = text
if stack ~= "" then
textToAdd = p.stack(text, vertAlign, noBold)
end
if noBold == "" then
wikiText = wikiText .. texttextToAdd
else
wikiText = wikiText .. frame:preprocess("{{nobold|1=" .. texttextToAdd .. "}}")
end
wikiText = wikiText .. "</div>"