Модуль:Loc/Marking: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| (не показаны 3 промежуточные версии этого же участника) | |||
| Строка 16: | Строка 16: | ||
elseif t == "head" then | elseif t == "head" then | ||
local level = params and tonumber(params._value) or 1 | local level = params and tonumber(params._value) or 1 | ||
return '< | level = math.max(1, math.min(3, level)) | ||
local defaultSize = 100 | |||
local size = math.ceil(defaultSize * 2 / math.sqrt(level)) | |||
return '<span style="font-weight:bold; font-size:' .. size .. '%;">' .. inner .. '</span>' | |||
elseif t == "font" then | elseif t == "font" then | ||
local family = params and params._value or nil | local family = params and params._value or nil | ||
| Строка 138: | Строка 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) | ||
| Строка 152: | Строка 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_]+)%]") | ||
| Строка 173: | Строка 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 | ||
| Строка 200: | Строка 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 | ||
| Строка 211: | Строка 220: | ||
{ src = 'Модуль:Loc/styles.css' } | { src = 'Модуль:Loc/styles.css' } | ||
) .. | ) .. | ||
'< | '<span class="list-reset-margin ' .. class .. '">' .. content .. '</span>' | ||
) | ) | ||
end | end | ||
return p | return p | ||