Модуль:Loc/Marking: различия между версиями
Pok (обсуждение | вклад) мНет описания правки Метка: отменено |
Pok (обсуждение | вклад) Отмена версии 120779, сделанной Pok (обсуждение) Метки: отмена отменено |
||
| Строка 90: | Строка 90: | ||
if not s or s == "" then return s end | if not s or s == "" then return s end | ||
local lines = mw.text.split(s, "\n") | local lines = mw.text.split(s, "\n") | ||
local first_non_empty = nil | |||
local first_non_empty_unescaped = nil | |||
for i, line in ipairs(lines) do | |||
for | if line and line:match("%S") then | ||
first_non_empty = line | |||
first_non_empty_unescaped = mw.ustring.gsub(line, " ", " ") | |||
break | break | ||
end | end | ||
end | |||
local enable_numeric = false | |||
if first_non_empty_unescaped and mw.ustring.match(first_non_empty_unescaped, "^%s*%d+%.") then | |||
enable_numeric = true | |||
end | end | ||
| Строка 123: | Строка 129: | ||
local indent = mw.ustring.len(leading or "") | local indent = mw.ustring.len(leading or "") | ||
local level = math.floor(indent / 2) | local level = math.floor(indent / 2) | ||
local | local stars = string.rep('#', 1 + level) | ||
processed = | processed = stars .. (rest ~= "" and (" " .. rest) or "") | ||
table.insert(out_lines, processed) | table.insert(out_lines, processed) | ||
handled = true | handled = true | ||
| Строка 137: | Строка 143: | ||
return table.concat(out_lines, "\n") | return table.concat(out_lines, "\n") | ||
end | end | ||
local function transform(s) | local function transform(s) | ||