5261
редагування
Admin (обговорення | внесок) Немає опису редагування |
Admin (обговорення | внесок) Немає опису редагування |
||
| Рядок 37: | Рядок 37: | ||
local sections = {} | local sections = {} | ||
for line in mw.ustring.gmatch(content, "[^\n]+") do | for line in mw.ustring.gmatch(content, "[^\n]+") do | ||
-- | -- ТІЛЬКИ заголовки рівня 2: == Назва == | ||
if mw.ustring.match(line, "^==[^=]") and mw.ustring.match(line, "[^=]==$") then | if mw.ustring.match(line, "^==[^=]") and mw.ustring.match(line, "[^=]==$") then | ||
local section_name = mw.ustring.match(line, "^==%s*(.-)%s*==$") | local section_name = mw.ustring.match(line, "^==%s*(.-)%s*==$") | ||
if section_name and section_name ~= "" then | if section_name and section_name ~= "" then | ||
-- | -- Виконуємо шаблони щоб отримати реальний текст | ||
local | local processed = frame:preprocess(section_name) | ||
processed = mw.text.trim(processed) | |||
-- | -- Anchor | ||
local anchor = mw.ustring.gsub( | local anchor = mw.ustring.gsub(processed, " ", "_") | ||
if | if processed ~= "" then | ||
table.insert(sections, { | table.insert(sections, { | ||
display = | display = processed, | ||
anchor = anchor | anchor = anchor | ||
}) | }) | ||
| Рядок 75: | Рядок 69: | ||
table.insert(html_parts, '<div class="l-box" style="position:fixed; top:20px; left:20px; z-index:100; border-radius:16px; background-color:#23232c; width:220px; box-sizing:border-box; overflow:hidden;">') | table.insert(html_parts, '<div class="l-box" style="position:fixed; top:20px; left:20px; z-index:100; border-radius:16px; background-color:#23232c; width:220px; box-sizing:border-box; overflow:hidden;">') | ||
table.insert(html_parts, '<div style="padding:15px 20px; font-weight:bold; font-size:15px; color:#fff; border-bottom:1px solid rgba(255,255,255,0.1);">Зміст</div>') | table.insert(html_parts, '<div style="padding:15px 20px; font-weight:bold; font-size:15px; color:#fff; border-bottom:1px solid rgba(255,255,255,0.1);">Зміст</div>') | ||
for i, section in ipairs(sections) do | for i, section in ipairs(sections) do | ||
local border = "" | local border = "" | ||