Модуль:DocTools

Материал из Кадровый состав НКВД 1935-1939
Перейти к навигации Перейти к поиску

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

local doctools = {}

function doctools.endRecord( args, noRef )
	local reference = args['сноска']
	if reference and not noRef then
		reference = mw.getCurrentFrame():extensionTag{ name ='ref', content = tools.phrase( reference ) }
	else
		reference = nil
	end
	local comment = args['комментарий']
	local canceledBy = args['отмена']
	if canceledBy then
		if mw.ustring.sub( canceledBy, 1, 9 ) == 'Документ:' then
			canceledBy = mw.ustring.sub( canceledBy, 10, -1 )
		end
		comment = '<b>Отменено:</b> [[Документ:' .. canceledBy .. '|' 
			.. canceledBy .. ']]. ' .. (comment or '')
	end
	if comment then
		comment = '<div class="nkvd-doc-comment">' 
			.. tools.phrase( comment )  .. '</div>'
	end
	return (reference or '') .. '</p>' .. (comment or '')
end

function doctools.abbr( text, tab )
	if not text then
		return nil
	end
	
	local u = mw.text.split( text, ' ', true )
	local z
	for i, v in ipairs( u ) do
		z = tab[v]
		if z then
			u[i] = z
		end
	end
	return table.concat( u, ' ' )
end

return doctools