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

Нет описания правки
Нет описания правки
 
Строка 141: Строка 141:
end
end


local function transform(s)
local function transform(s, noFormat)
     s = s or ""
     s = s or ""
     s = mw.ustring.gsub(s, "%[tooltip([^%]]*)%]", function(raw_attrs)
     s = mw.ustring.gsub(s, "%[tooltip([^%]]*)%]", function(raw_attrs)
Строка 155: Строка 155:
         return "{{altTooltip|1=" .. (visible or "") .. "|2=<span style='white-space:pre-wrap;'>{{#invoke:Loc|GetRawString|noFormat=1|" .. (tip or "") .. "}}</span>}}"
         return "{{altTooltip|1=" .. (visible or "") .. "|2=<span style='white-space:pre-wrap;'>{{#invoke:Loc|GetRawString|noFormat=1|" .. (tip or "") .. "}}</span>}}"
     end)
     end)
     while true do
     while true do
         local c_s, c_e, c_tag = mw.ustring.find(s, "%[/([%w_]+)%]")
         local c_s, c_e, c_tag = mw.ustring.find(s, "%[/([%w_]+)%]")
Строка 176: Строка 177:
         end
         end
     end
     end
     s = mw.ustring.gsub(s, "%[/?[%w_]+[^%]]*%]", "")
     s = mw.ustring.gsub(s, "%[/?[%w_]+[^%]]*%]", "")
     s = convert_lists(s)
 
     if not noFormat then
        s = convert_lists(s)
    end
 
     return s
     return s
end
end
Строка 203: Строка 209:


     local class = noFormat and "ts-loc-format" or ""
     local class = noFormat and "ts-loc-format" or ""
     local content = transform(text)
     local content = transform(text, noFormat)
     if mw.ustring.find(content, '^[ \t]*[#%*;%:]+') then
     if mw.ustring.find(content, '^[ \t]*[#%*;%:]+') then
         content = '\n' .. content
         content = '\n' .. content