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

Материал из Кадровый состав НКВД 1935-1939
Перейти к навигации Перейти к поиску
Нет описания правки
Нет описания правки
Строка 20: Строка 20:
content = tools.phrase( content )
content = tools.phrase( content )
end
end
result = result .. mw.getCurrentFrame():extensionTag( 'ref', content , name )  -- .. ' [' .. (name or '—').. ']'
result = result .. mw.getCurrentFrame():extensionTag( 'ref', content , { name = name } )  -- .. ' [' .. (name or '—').. ']'
end
end
end
end

Версия от 11:11, 5 февраля 2017

Для документации этого модуля может быть создана страница Модуль:RefTools/doc

local refTools = {}
local tools = 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
		if ref ~= '' then
			name, content = mw.ustring.match ( ref, '^/([^/]+)/(.*)$' )
			if not name then
				content = ref
			end
	
			if isSource then
				if content ~= '' then
					content = 'Источник: <cite>' .. content .. '</cite>'
				end
			else
				content = tools.phrase( content )
			end
			result = result .. mw.getCurrentFrame():extensionTag( 'ref', content , { name = name } )  -- .. ' [' .. (name or '—').. ']'
		end
	end
	return result
end

return refTools