Модуль:RefTools — различия между версиями
StasR (обсуждение | вклад) (¶) |
StasR (обсуждение | вклад) |
||
Строка 3: | Строка 3: | ||
function refTools.makeRef( para, isSource ) | function refTools.makeRef( para, isSource ) | ||
− | local refs = mw.text.split( para, '¶' ) | + | local refs = mw.text.split( para or '', '¶' ) |
− | |||
local result = '' | local result = '' | ||
local name, content | local name, content | ||
for _, ref in pairs( refs ) do | for _, ref in pairs( refs ) do | ||
− | name, content = mw.ustring.match ( ref, '^/([^/]+)/(.*)$' ) | + | name, content = mw.ustring.match ( ref, '^/([^/]+)/(.*)$' ) |
if not name then | if not name then | ||
content = ref | content = ref | ||
end | end | ||
− | + | ||
if isSource then | if isSource then | ||
content = 'Источник: <cite>' .. content .. '</cite>' | content = 'Источник: <cite>' .. content .. '</cite>' |
Версия 10:14, 5 февраля 2017
Для документации этого модуля может быть создана страница Модуль:RefTools/doc
local refTools = {}
tools = tools or require( 'Module:Tools' )
function refTools.makeRef( para, isSource )
local refs = mw.text.split( para or '', '¶' )
local result = ''
local name, content
for _, ref in pairs( refs ) do
name, content = mw.ustring.match ( ref, '^/([^/]+)/(.*)$' )
if not name then
content = ref
end
if isSource then
content = 'Источник: <cite>' .. content .. '</cite>'
else
content = tools.phrase( content )
end
result = result .. mw.getCurrentFrame():extensionTag( 'ref', content, name )
end
return result
end
return refTools