Модуль:Loc/Marking: различия между версиями

мНет описания правки
Нет описания правки
 
(не показано 20 промежуточных версий этого же участника)
Строка 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
    local enable_numeric = false
         if line and line:match("%S") then
     for _, line in ipairs(lines) do
            first_non_empty = line
         local line_unescaped = mw.ustring.gsub(line, " ", " ")
            first_non_empty_unescaped = mw.ustring.gsub(line, " ", " ")
        if mw.ustring.match(line_unescaped, "^%s*%d+%.") then
            enable_numeric = true
             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


Строка 129: Строка 123:
                 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 stars = string.rep('#', 1 + level)
                 local hashes = string.rep('#', 1 + level)
                 processed = stars .. (rest ~= "" and (" " .. rest) or "")
                 processed = hashes .. (rest ~= "" and (" " .. rest) or "")
                 table.insert(out_lines, processed)
                 table.insert(out_lines, processed)
                 handled = true
                 handled = true
Строка 156: Строка 150:
             if tip == "" and params._value and visible ~= params._value then tip = params._value end
             if tip == "" and params._value and visible ~= params._value then tip = params._value end
         end
         end
        visible = mw.ustring.gsub(visible, "|", "|")
         return "{{altTooltip|1=" .. (visible or "") .. "|2={{#invoke:Loc|GetRawString|" .. (tip or "") .. "}}}}"
        tip = mw.ustring.gsub(tip, "|", "|")
         return "{{altTooltip|" .. (visible or "") .. "|" .. (tip or "") .. "}}"
     end)
     end)
     while true do
     while true do
Строка 190: Строка 182:
             :gsub('=', '=')
             :gsub('=', '=')
             :gsub(' ', ' ')
             :gsub(' ', ' ')
            :gsub('{"', '')
            :gsub('"}', '')
             :gsub('{', '{')
             :gsub('{', '{')
             :gsub('"', '"')
             :gsub('"', '"')
Строка 200: Строка 194:
     local args = frame.args or {}
     local args = frame.args or {}
     local text = args[1] or args.text or ""
     local text = args[1] or args.text or ""
     text = mw.text.unstripNoWiki(text)
     text = mw.text.unstripNoWiki(text)
     text = process_nowiki_equals(text)
     text = process_nowiki_equals(text)
     return frame:preprocess(transform(text))
 
     return frame:preprocess('<div class="list-reset-margin">\n' .. transform(text) .. '</div>')
end
end


return p
return p