Изменения
Перейти к навигации
Перейти к поиску
Строка 71:
Строка 71:
+
+
+
Строка 92:
Строка 95:
− +
+
+
− +
+
+
Строка 104:
Строка 111:
+
+
+
Строка 109:
Строка 119:
− +
− +
− +
− +
Строка 128:
Строка 138:
− if args._template == nil then --имя вызываемого шаблона в неименованном первом параметре (или же взято из названия страницы или +
− --из именованного параметра в отсутствие неименованных — в следующей строчке вреда нет в любом случае),+
− --больше его обрабатывать не надо+
+
+
Строка 142:
Строка 154:
− +
Строка 152:
Строка 164:
− +
− --не сбивали порядок+
− +
комментарий в <small>, иначе непонятно, часть примера или нет; оформление кода
local nocat = yesno(args._nocat, false)
local nocat = yesno(args._nocat, false)
local style = args._style
local style = args._style
if style == '' then
style = nil
end
-- передаётся шаблоном {{стопка примеров}}, один разделитель на все примеры
-- передаётся шаблоном {{стопка примеров}}, один разделитель на все примеры
tag = nil
tag = nil
container = 'pre'
container = 'pre'
sep = '<div style="margin:-0.5em 50% 0.7em;"><span style="font-size:150%;">↓</span></div>\n' --содержимое шаблона {{sp↓|50%||-0.5em}}
-- содержимое шаблона {{sp↓|50%||-0.5em}}
sep = '<div style="margin:-0.5em 50% 0.7em;"><span style="font-size:150%;">↓</span></div>\n'
elseif style == '*pre↓' then
elseif style == '*pre↓' then
tag = nil
tag = nil
container = '*pre'
container = '*pre'
sep = '<div style="margin:-0.5em 50% 0.7em;"><span style="font-size:150%;">↓</span></div>\n' --содержимое шаблона {{sp↓|50%||-0.5em}}
-- содержимое шаблона {{sp↓|50%||-0.5em}}
sep = '<div style="margin:-0.5em 50% 0.7em;"><span style="font-size:150%;">↓</span></div>\n'
elseif style == 'wikitable' then
elseif style == 'wikitable' then
tag = 'tt'
tag = 'tt'
if (after ~= '') then
if (after ~= '') then
if not style then
after = '<small>' .. after .. '</small>'
end
after = comment_sep .. after
after = comment_sep .. after
end
end
local nwt
local nwt
if tag then
if tag then
nwt = mw.html.create(tag):tag(tag) --"no-wiki tag", внутри него шаблон не вызывается
nwt = mw.html.create(tag):tag(tag) -- "no-wiki tag", внутри него шаблон не вызывается
if nobr then
if nobr then
nwt:css('white-space', 'nowrap')
nwt:css('white-space', 'nowrap')
end
end
end
end
local content = nowiki(prefix) .. '{{' --для накопления содержимого тэга
local content = nowiki(prefix) .. '{{' -- для накопления содержимого тэга
local tname = args._template or args[1]
local tname = args._template or args[1]
if tname == nil then --если имя шаблона содержит знак "=" (работает, только если нет неименованных параметров)
if tname == nil then -- если имя шаблона содержит знак "=" (работает, только если нет неименованных параметров)
local nextfunc, static, cur = pairs(args)
local nextfunc, static, cur = pairs(args)
local k, v = nextfunc(static, cur)
local k, v = nextfunc(static, cur)
if k ~= nil and type(k) ~= 'number' and not k:find('^_') then --именованные параметры, исключая модификаторы внешнего вида
if k ~= nil and type(k) ~= 'number' and not k:find('^_') then -- именованные параметры, исключая модификаторы внешнего вида
tname = k .. "=" .. v
tname = k .. "=" .. v
args[k] = nil --больше этот параметр нам не пригодится
args[k] = nil --больше этот параметр нам не пригодится
tname = mw.language.new('ru'):lcfirst(mw.title.getCurrentTitle().rootText)
tname = mw.language.new('ru'):lcfirst(mw.title.getCurrentTitle().rootText)
end
end
-- Имя вызываемого шаблона в неименованном первом параметре (или же взято из названия страницы или
-- из именованного параметра в отсутствие неименованных — в следующей строчке вреда нет в любом случае),
-- больше его обрабатывать не надо
if args._template == nil then
table.remove(args,1)
table.remove(args,1)
end
end
local targs, equals_pos, param, value, left_shift = {}, 0, '', '', 0
local targs, equals_pos, param, value, left_shift = {}, 0, '', '', 0
for k, v in pairs(args) do
for k, v in pairs(args) do
if type(k) == 'number' then --неименованные параметры
if type(k) == 'number' then -- неименованные параметры
equals_pos = v:find('=')
equals_pos = v:find('=')
if equals_pos and v:find('{{=}}') == equals_pos-2 then
if equals_pos and v:find('{{=}}') == equals_pos-2 then
targs[param] = process_nowiki_equals(value)
targs[param] = process_nowiki_equals(value)
content = content .. (spaced and ' ' or '') .. '|' .. nowiki(param) .. '=' .. nowiki(value) .. endl
content = content .. (spaced and ' ' or '') .. '|' .. nowiki(param) .. '=' .. nowiki(value) .. endl
left_shift = left_shift+1 --переменная нужна, чтобы квазинумерованные параметры, переданные через "{{=}}",
left_shift = left_shift + 1 -- переменная нужна, чтобы квазинумерованные параметры, переданные через "{{=}}",
-- не сбивали порядок
else --истинно неименованные
else --истинно неименованные
targs[k - left_shift] = process_nowiki_equals(v)
targs[k - left_shift] = process_nowiki_equals(v)
content = content .. (spaced and ' ' or '') .. '|' .. nowiki(v) .. endl
content = content .. (spaced and ' ' or '') .. '|' .. nowiki(v) .. endl
end
end
elseif not k:find('^_') then --именованные параметры, исключая модификаторы внешнего вида
elseif not k:find('^_') then -- именованные параметры, исключая модификаторы внешнего вида
targs[k] = process_nowiki_equals(v)
targs[k] = process_nowiki_equals(v)
content = content .. (spaced and ' ' or '') .. '|' .. nowiki(k) .. '=' .. nowiki(v) .. endl
content = content .. (spaced and ' ' or '') .. '|' .. nowiki(k) .. '=' .. nowiki(v) .. endl