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

Материал из Указатель частей и соединений РККА 1941-1945
Перейти к:навигация, поиск
 
Строка 2: Строка 2:
 
local ref = require( 'Module:Ref' )
 
local ref = require( 'Module:Ref' )
 
local lexer = require( 'Module:Lexer' )
 
local lexer = require( 'Module:Lexer' )
local redata = mw.loadData( 'Module:Redata' )
+
local redata
 
local formation
 
local formation
  
local knownBrackets  
+
local knownBrackets
 
local knownBracketsSuperOut
 
local knownBracketsSuperOut
if mw.site.server == '//en.rkka.wiki' then
+
local translation
 +
 
 +
local english = mw.site.server == '//en.rkka.wiki'
 +
if english then
 +
redata = mw.loadData( 'Module:Redata.en' )
 +
translation = {
 +
'Separate',
 +
'Guards',
 +
'“',
 +
'”',
 +
}
 +
 
 
knownBrackets = {
 
knownBrackets = {
 
['Pol.'] = 'Pol.',
 
['Pol.'] = 'Pol.',
Строка 39: Строка 50:
 
}
 
}
 
else
 
else
 +
redata = mw.loadData( 'Module:Redata' )
 +
translation = {
 +
'отд%.',
 +
'гв%.',
 +
'«',
 +
'»',
 +
}
 
knownBrackets = {
 
knownBrackets = {
 
['Войско Польское'] = 'Войско Польское',
 
['Войско Польское'] = 'Войско Польское',
Строка 296: Строка 314:
  
 
local function acheck( u, plural )
 
local function acheck( u, plural )
local descr = redata.Descr[u]
+
if english then
if not descr then
+
if not plural then
return nil
+
return u
 +
end
 +
local body2, top = string.match( u, '^(.-) of( .+)$' )
 +
if not body2 then
 +
body2, top = u, ''
 +
end
 +
local words = mw.text.split( body2, ' ' )
 +
local main, plw
 +
for i = #words, 1, -1 do
 +
plw = redata.Plurals[words[i]]
 +
if plw then
 +
main = i
 +
break
 +
end
 +
end
 +
if not main then
 +
return nil
 +
end
 +
local pre, post
 +
if main ~= 1 then
 +
pre = table.concat( words, ' ', 1, main-1 ) .. ' ' .. plw
 +
else
 +
pre = plw
 +
end
 +
if main ~= #words then
 +
post = ' ' .. table.concat( words, ' ', main+1 )
 +
else
 +
post = ''
 +
end
 +
return pre .. post .. top
 +
else
 +
local descr = redata.Descr[u]
 +
if not descr then
 +
return nil
 +
end
 +
if plural then
 +
return descr[2] or descr[1]
 +
end
 +
return descr[1]
 
end
 
end
if plural then
 
return descr[2] or descr[1]
 
end
 
return descr[1]
 
 
end
 
end
  
Строка 345: Строка 397:
 
end
 
end
  
b, quotes = string.match( a, '^(.+)( «.+»)$' )
+
b, quotes = string.match( a, '^(.+)( ' .. translation[3] .. '.+' .. translation[4] .. ')$' )
 
if b then
 
if b then
 
a = b
 
a = b
Строка 364: Строка 416:
  
  
name, otd, gv, b = string.match( a, '^(.*)(отд%. )(гв%. )(.+)$' )
+
-- name, otd, gv, b = string.match( a, '^(.*)(отд%. )(гв%. )(.+)$' )
 +
name, otd, gv, b = string.match( a, '^(.*)(' .. translation[1] .. ' )(' .. translation[2] .. ' )(.+)$' )
 
if name then
 
if name then
 
abbr = acheck( otd .. b, plural )
 
abbr = acheck( otd .. b, plural )
Строка 377: Строка 430:
 
end
 
end
  
name, otd, b = string.match( a, '^(.*)(отд%. )(.+)$' )
+
name, otd, b = string.match( a, '^(.*)(' .. translation[1] .. ' )(.+)$' )
 
if name then
 
if name then
 
abbr = acheck( otd .. b, plural )
 
abbr = acheck( otd .. b, plural )
Строка 390: Строка 443:
 
end
 
end
  
name, gv, b = string.match( a, '^(.*)(гв%. )(.+)$' )
+
name, gv, b = string.match( a, '^(.*)(' .. translation[2] .. ' )(.+)$' )
 
if name then
 
if name then
 
abbr = acheck( b, plural )
 
abbr = acheck( b, plural )
Строка 583: Строка 636:
 
.. date .. '</span>'
 
.. date .. '</span>'
 
end
 
end
 +
 +
function report.printDateWithLink( row )
 +
local basepage, date, part, page, bookpage
 +
if ( row.bookpage or '' ) == '' then
 +
bookpage = ''
 +
else
 +
bookpage = '#p' .. row.bookpage
 +
end
 +
page = row.page
 +
if page then
 +
basepage, part = string.match( page, '^(.+)/(%d)$' )
 +
assert( basepage )
 +
if english then
 +
date = row.date
 +
else
 +
date = string.sub( row.date, 9, 10 ) .. '.' .. string.sub( row.date, 6, 7 ) .. '.'
 +
.. string.sub( row.date, 1, 4 )
 +
end
 +
date = '[[' .. basepage .. bookpage .. '|' .. date .. ']]'
 +
else
 +
date = '&nbsp;'
 +
part = ''
 +
end
 +
return '<span class="oobdate date-field" data-part="' .. part .. '">'
 +
.. date .. '</span>'
 +
end
 +
  
 
return report
 
return report

Текущая версия на 18:31, 21 мая 2020

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

local report = {}
local ref = require( 'Module:Ref' )
local lexer = require( 'Module:Lexer' )
local redata
local formation

local knownBrackets
local knownBracketsSuperOut
local translation

local english = mw.site.server == '//en.rkka.wiki'
if english then
	redata = mw.loadData( 'Module:Redata.en' )
	translation = {
		'Separate',
		'Guards',
		'“',
		'”',
	}

	knownBrackets = {
		['Pol.'] = 'Pol.',
		['Fr.'] = 'Fr.',
		['Hung.'] = 'Hung.',
		['Czech.'] = 'Czech.',
		['Yug.'] = 'Yug.',
		['Rom.'] = 'Rom.',
		['Bulg.'] = 'Bulg.',
		['Mong.'] = 'Mong.',
		['I'] = 1,
		['II'] = 2,
		['III'] = 3,
		['IV'] = 4,
		['V'] = 5,
		['VI'] = 6,
		['I formation'] = 1,
		['II formation'] = 2,
		['III formation'] = 3,
		['IV formation'] = 4,
		['V formation'] = 5,
		['VI formation'] = 6,
	}
	knownBracketsSuperOut = {
		'I formation',
		'II formation',
		'III formation',
		'IV formation',
		'V formation',
		'VI formation',
	}
else
	redata = mw.loadData( 'Module:Redata' )
	translation = {
		'отд%.',
		'гв%.',
		'«',
		'»',
	}
	knownBrackets = {
		['Войско Польское'] = 'Войско Польское',
		['ВП'] = 'Войско Польское',
		['фр.'] = 'фр.',
		['венг.'] = 'венг.',
		['чех.'] = 'чех.',
		['югосл.'] = 'югосл.',
		['рум.'] = 'рум.',
		['болг.'] = 'болг.',
		['монг.'] = 'монг.',
		['I'] = 1,
		['II'] = 2,
		['III'] = 3,
		['IV'] = 4,
		['V'] = 5,
		['VI'] = 6,
		['I формирования'] = 1,
		['II формирования'] = 2,
		['III формирования'] = 3,
		['IV формирования'] = 4,
		['V формирования'] = 5,
		['VI формирования'] = 6,
	}
	knownBracketsSuperOut = {
		'I формирования',
		'II формирования',
		'III формирования',
		'IV формирования',
		'V формирования',
		'VI формирования',
	}
end



report.knownBrackets = knownBrackets

local buffer = {}
local  bufferCommon, bufferCommonN, bufferCommonAdd, bufferCommonForm, bufferCommonStruct, bufferCommonHq, bufferCommonGene

report.space = '&nbsp;'
report.pageMode = true

function report.simplecat( str ) -- использует очищенное от скобок наименование
	local a = ( string.match( str, '^(.+)( «.+»)$' ) ) or str

	local b = mw.ustring.match( a, '[гГ]в%. (.+)$' )
	if b then
		if string.find( ' ' .. b, ' минометн' ) then
			a = 'гв. ' .. b
		else
			a = b
		end
	else
		b = string.match( a, '[оО]тд%. (.+)$' )
		if b then
			a = b
		else
			a = ( string.match( a, '^%d[^ ]* (.+)$' ) ) or a
		end
	end
	return a

end

function report.fuller( str, badAbbr )
	badAbbr = badAbbr or {}
	if badAbbr[str] or redata.Full[str] then
		return badAbbr[str] or redata.Full[str]
	end
	local num, a = string.match( str, '^(%d[^ ]* )(.+)$' )
	if num then
		local gv, otd, otdInc
		a, gv = string.gsub( a, 'гв. ', '' )
		if gv == 1 then
			gv = 'гв. '
		else
			gv = ''
		end
		a, otd = string.gsub( a, 'отд. ', '' )
		if otd == 1 then
			otd = 'отд. '
		else
			otd = ''
		end
		a = badAbbr[a] or redata.Full[a]
		if a then
			a, otdInc = string.gsub( a, 'отд. ', '' )
			if otdInc == 1 then
				otd = 'отд. '
			end
			return num .. otd .. gv .. a
		end
	else
		num, a = string.match( str, '^([^ ]* )(.+)$' )
		if badAbbr[a] or redata.Full[a] then
			return num .. ( badAbbr[a] or redata.Full[a] )
		end
	end
	return str
end

--function report.bigfuller( str, badAbbr )
--	local stored = {}
--	local n
--	repeat
--		str, n = string.gsub( str, ' %(([^()]+)%)', function ( u )
--				if knownBracketsBig[u] then
--					table.insert( stored, knownBracketsBig[u] )
--					return '&' .. string.char( 96 + #stored )
--				else
--					local parts = mw.text.split( mw.text.trim( u ), '%s*,%s*' )
--					for i, part in ipairs( parts ) do
--						local body, ending = string.match( part, '^([^&]+)(.*)$' )
--						parts[i] = lexer.declension( report.fuller( body ), 1, true ) .. ending
--					end
--					table.insert( stored, table.concat( parts, ', ' ) )
--				end
--				return '&' .. string.char( 96 + #stored )
--			end	)
--	until n == 0
--	local body, ending = string.match( str, '^([^&]+)(.*)$' )
--	str = report.fuller( body, badAbbr ) .. ending
--	repeat
--		str, n = string.gsub( str, '&(.)', function ( u )
--				return ' (' .. stored[string.byte( u ) - 96] .. ')'
--			end )
--	until n == 0
--	return str
--end

function report.bigfuller( str, badAbbr, parentsCollection )
	local body = str
	local shorted, parent, generation, foreign
	repeat
		local  el
		shorted, el = string.match( body, '^(.-)%s+(%b())$' )
		if shorted then
			body = shorted
			el = mw.text.trim( string.sub( el, 2, -2 ) )
			local u = knownBrackets[el]
			if u then
				if type( u ) == 'number' then
					generation = knownBracketsSuperOut[u]
				else
					foreign = u
				end
			else
				parent = el
			end
		end
	until not shorted

	if parent then
		local stored = {}
		parent = string.gsub( parent, '%b()', function( a )
				table.insert( stored, a )
				return '&' .. string.char( 96 + #stored )
			end )
		local parts = mw.text.split( parent, '%s*,%s*' )
		for i, part in ipairs( parts ) do
			local lexxx
			part = report.bigfuller( ( string.gsub( part, '&(.)', function ( u )
					return stored[string.byte( u ) - 96]
				end ) ) )
			parts[i], lexxx = lexer.declension( part, 1, true )
			if parentsCollection then
				if not lexxx then
					part = ''
				end
				table.insert( parentsCollection, part )
			end
		end
		parent = ' (' .. string.gsub( table.concat( parts, ', ' ), ' формирования%)', '%)' ) .. ')'
	end

	if foreign then
		foreign =  ' (' .. foreign .. ')'
	end
	if generation then
		generation =  ' (' .. generation .. ')'
	end
	body = report.fuller( body, badAbbr )
	return body .. ( foreign or '' ) .. ( parent or '' ) .. ( generation or '' ), body .. ( generation or '' )
end


--function report.bigfuller( str, badAbbr, classfunc )
--	classfunc = classfunc or function () return '' end
--	local body = str
--	local shorted, parent, showParent, generation, foreign
--	repeat
--		local  el
--		shorted, el = string.match( body, '^(.-)%s+(%b())$' )
--		if shorted then
--			body = shorted
--			el = mw.text.trim( string.sub( el, 2, -2 ) )
--			local u = knownBrackets[el]
--			if u then
--				if type( u ) == 'number' then
--					generation = knownBracketsSuperOut[u]
--				else
--					foreign = u
--				end
--			else
--				parent = el
--			end
--		end
--	until not shorted

--	if parent then
--		local stored = {}
--		local showed = {}
--		parent = string.gsub( parent, '%b()', function( a )
--				table.insert( stored, a )
--				return '&' .. string.char( 96 + #stored )
--			end )
--		local parts = mw.text.split( parent, '%s*,%s*' )
--		for i, part in ipairs( parts ) do
--			local lexxx
--			part = string.gsub( part, '&(.)', function ( u )
--					return stored[string.byte( u ) - 96]
--				end )
--			part = report.bigfuller( part )
--			parts[i], lexxx = string.gsub( lexer.declension( part, 1, true ), ' формирования%)', '%)' )
--			if lexxx then
--				table.insert( showed, '<span class="unit-top ' .. classfunc( part ) .. '">[[' .. part .. '|' .. parts[i] .. ']]</span>' )
--			else
--				table.insert( showed, part )
--			end
--		end
--		parent = ' (' .. table.concat( parts, ', ' ) .. ')'
--		showParent = ' (' .. table.concat( showed, ', ' ) .. ')'
--	end

--	if foreign then
--		foreign =  ' (' .. foreign .. ')'
--	end
--	if generation then
--		generation =  ' (' .. generation .. ')'
--	end
--	local a = report.fuller( body, badAbbr ) .. ( foreign or '' )
--	local u = a .. ( parent or '' ) .. ( generation or '' )
--	local spanu = classfunc( u )
--	if spanu ~= '' then
--		a = '<span class="' .. spanu .. '">' .. a .. '</span>'
--	end
--	return u, a, showParent, generation
--end

function report.shorter( str, plural )
	-- отделяем хвосты
	local brackets, quotes, numb, name, otd, gv
	local a, b
	local abbr

	local function acheck( u, plural )
		if english then
			if not plural then
				return u
			end
			local body2, top = string.match( u, '^(.-) of( .+)$' )
			if not body2 then
				body2, top = u, ''
			end
			local words = mw.text.split( body2, ' ' )
			local main, plw
			for i = #words, 1, -1 do
				plw = redata.Plurals[words[i]]
				if plw then
					main = i
					break
				end
			end
			if not main then
				return nil
			end
			local pre, post
			if main ~= 1 then
				pre = table.concat( words, ' ', 1, main-1 ) .. ' ' .. plw
			else
				pre = plw
			end
			if main ~= #words then
				post = ' ' .. table.concat( words, ' ', main+1 )
			else
				post = ''
			end
			return pre .. post .. top
		else
			local descr = redata.Descr[u]
			if not descr then
				return nil
			end
			if plural then
				return descr[2] or descr[1]
			end
			return descr[1]
		end
	end

	a, brackets = string.match( str, '^(.+) %((.+)%)$' )
	local owngene
	if not a then
		a = str
		brackets = ''
	else
		local bracketsA = mw.text.split( brackets, ') (', true )
		brackets = ''
--		for i = 1, #bracketsA do
--			if knownBrackets[bracketsA[i]] then
--				brackets = brackets .. ' (' .. bracketsA[i] .. ')'
--			end
--		end
		for _, bra in ipairs( bracketsA ) do
			local known = knownBrackets[bra]
			if known then
				if type( known ) == 'string' then
					if report.gene then
						if known ~= report.gene then
							error( 'Межнациональная рознь: ' .. report.gene .. ' содержит ' .. known )
						else
							owngene = known
						end
					else
						owngene = known
						brackets = brackets .. ' (' .. known .. ')'
					end
				else
					brackets = brackets .. ' (' .. bra .. ')'
				end
			end
		end
	end
	if report.gene and not owngene then
		brackets = brackets .. ' (РККА)'
	else
		report.gene = owngene
	end

	b, quotes = string.match( a, '^(.+)( ' .. translation[3] .. '.+' .. translation[4] .. ')$' )
	if b then
		a = b
	else
		quotes = ''
	end

	numb, b = string.match( a, '^(%d+%-?[абв]?) (.+)$' )
	if numb then
		numb = numb .. report.space
		a = b
	end

	-- ИИИ отд. гв. ТТТ: (отд. ТТТ), (ТТТ)
	-- ИИИ отд. ТТТ: (отд. ТТТ), (ТТТ)
	-- ИИИ гв. ТТТ: (ТТТ)
	-- ИИИ ТТТ: (ИИИ ТТТ), (ТТТ)


--	name, otd, gv, b = string.match( a, '^(.*)(отд%. )(гв%. )(.+)$' )
	name, otd, gv, b = string.match( a, '^(.*)(' .. translation[1] .. ' )(' .. translation[2] .. ' )(.+)$' )
	if name then
		abbr = acheck( otd .. b, plural )
		if abbr then
			return ( numb or '' ) .. name .. gv .. abbr .. quotes .. brackets
		end
		abbr = acheck( b, plural )
		if abbr then
			return ( numb or '' ) .. name .. otd .. gv .. abbr .. quotes .. brackets
		end
		return str
	end

	name, otd, b = string.match( a, '^(.*)(' .. translation[1] .. ' )(.+)$' )
	if name then
		abbr = acheck( otd .. b, plural )
		if abbr then
			return ( numb or '' ) .. name .. abbr .. quotes .. brackets
		end
		abbr = acheck( b, plural )
		if abbr then
			return ( numb or '' ) .. name .. otd .. abbr .. quotes .. brackets
		end
		return str
	end

	name, gv, b = string.match( a, '^(.*)(' .. translation[2] .. ' )(.+)$' )
	if name then
		abbr = acheck( b, plural )
		if abbr then
			return ( numb or '' ) .. name .. gv .. abbr .. quotes .. brackets
		end
		return str
	end

	abbr = acheck( a, plural )
	if abbr then
		return ( numb or '' ) .. abbr .. quotes .. brackets
	end

	name, b = string.match( a, '^([^ ]+ )(.+)$' )
	if name then
		abbr = acheck( b, plural )
		if abbr then
			return ( numb or '' ) .. name .. abbr .. quotes .. brackets
		end
	end

	return str
end

function report.outPart( showMode, link, unit, addendum, reference, inFormation, hq )
	-- showMode = false/nil не показывать, 1 кратко, 2 полностью; string — текст, показываемый вместо названия юнита (для буферизации)
	-- link = true — превращать в ссылку (игнор при mode=false/nil)
	local res = {}
	if link and showMode then
		table.insert( res, '[[' .. unit )
		if showMode == 1 then
			table.insert( res, '|' .. report.shorter( unit ) )
		elseif type( showMode ) == 'string' then
			table.insert( res, '|' .. showMode )
		end
		table.insert( res, ']]' )
	elseif showMode == 2 then
		table.insert( res, unit )
	elseif showMode == 1 then
		table.insert( res, report.shorter( unit ) )
	end
	if reference ~= '' then
		table.insert( res, ref.use( reference, report.pageMode ) )
	end
	if type( showMode ) ~= 'string' then
		if ( hq or '' ) ~= '' then
			table.insert( res, ' (<span title="Управление без войск">&empty;</span>)' )
		end
		if addendum ~= '' then
			table.insert( res, ' <i>(' .. addendum .. ')</i>' )
		end
		if inFormation ~= '' then
			formation = formation or mw.loadData( 'Module:Formation' )
			table.insert( res, ' — <i>на ' .. formation.FUP[tonumber( inFormation )] .. '</i>')
		end
	end
	return table.concat( res )
end

function report.outEl( tab, n, showMode, link, compact )
	local res = ''
	local unit = tab['id'..n]
	if unit ~= '' then
		if unit == 'Действующая армия' then
			return nil
		elseif unit == 'Военные округа и недействующие фронты' then
			if string.match( tab['id'..(n -1)], 'военный округ$' ) then
				return nil
			else
				return '<i>(недействующие войска)</i>'
			end
		elseif unit == 'Войска ПВО на территории военных округов и недействующих фронтов' then
			if string.match( tab['id'..(n -1)], 'фронт — войска ПВО$' ) then
				res = '<i>(недействующий фронт)</i> / '
			end
			unit = 'Войска ПВО территории страны'
		elseif unit == 'Войска ПВО, прикрывавшие объекты действующей армии' then
			if string.match( tab['id'..(n -1)], 'округ — войска ПВО$' ) then
				res = '<i>(Действующая армия)</i> / '
			end
			unit = 'Войска ПВО территории страны'
		end
		if compact then
			return report.toBuffer( tab, n )
		end
		res = res .. report.outPart( showMode, link, unit, tab['add'..n], tab['ref'..n], tab['form'..n], tab['hq'..n] )
		if tab['s_id'..n] ~= '' then
			res = res .. ' [<i></i>' .. report.outPart( showMode, true, tab['s_id'..n], tab['s_add'..n], tab['s_ref'..n], '', '' ) .. ']'
		end
		return res
	end
end

function report.toBuffer( tab, n )
	local unit = tab['id'..n]
	local x, u = string.match( unit, '^([^ ]+) (.+)$' )
	local res
	if not x then
		x = unit
		u = ''
	end
--	assert( x, unit )
	if bufferCommon and
	( u ~= bufferCommon or tab['add'..n] ~= bufferCommonAdd
		or tab['form'..n] ~= bufferCommonForm  or tab['s_id'..n] ~= bufferCommonStruct
		or bufferCommonGene ~= report.gene or tab['hq'..n] ~= bufferCommonHq ) then
		res = report.popBuffer()
	end
	if not bufferCommon then
--		bufferTab = tab
		bufferCommon = u
		bufferCommonAdd = tab['add'..n]
		bufferCommonForm = tab['form'..n]
		bufferCommonStruct = tab['s_id'..n]
		bufferCommonHq = tab['hq'..n]
		bufferCommonN = n
		bufferCommonGene = report.gene
	end
	table.insert( buffer, { n, x, tab } )
	return res
end

function report.popBuffer()
	if bufferCommon then
		local savedGene = report.gene
		report.gene = bufferCommonGene
		if #buffer == 1 then
			local n, utab = buffer[1][1], buffer[1][3]
			buffer = {}
			bufferCommon = nil
			local res = report.outEl( utab, n, 1, true )
			report.gene = savedGene
			return res
		end
		local res = {}
		for _, el in ipairs( buffer ) do
			local n, unumb, utab = el[1], el[2], el[3]
			table.insert( res, report.outPart( unumb, true, utab['id'..n], bufferCommonAdd, utab['ref'..n], bufferCommonForm, bufferCommonHq ) )
			-- в реальности add, form, hq тут игнорируются
		end
		res = { table.concat( res, ', ' ) .. report.space .. report.shorter( bufferCommon, true ) }
		if ( bufferCommonHq or '' ) ~= '' then
			table.insert( res, ' (<span title="Управление без войск">&empty;</span>)' )
		end
		if bufferCommonAdd ~= '' then
			table.insert( res, '<i>(' .. bufferCommonAdd .. ')</i>' )
		end
		if bufferCommonForm ~= '' then
			formation = formation or mw.loadData( 'Module:Formation' )
			table.insert( res, '— <i>на ' .. formation.FUP[tonumber( bufferCommonForm )] .. '</i>' )
		end
		local btab = buffer[1][3]
		if bufferCommonStruct ~= '' then
			table.insert( res, '[<i></i>' .. report.outPart( 1, true, bufferCommonStruct, btab['s_add'..bufferCommonN], btab['s_ref'..bufferCommonN], '' ) .. ']' )
		end
		buffer = {}
		bufferCommon = nil
		report.gene = savedGene
		return table.concat( res, ' ' )
	else
		return nil
	end
end


function report.printDate( str )
	if ( str or '' ) ~= '' then
		return '<span class=date-field>'
		.. string.sub( str, 9, 10 ) .. '.' .. string.sub( str, 6, 7 ) .. '.'
		.. string.sub( str, 1, 4 ) .. '</span>'
	end
	return '<span class=date-field>&nbsp;</span>'
end

function report.printDateLink( page, bookpage, text )
	local basepage, date, part
	if ( bookpage or '' ) == '' then
		bookpage = ''
	else
		bookpage = '#p' .. bookpage
	end
	if page then
		basepage, date, part = string.match( page, '^(.+ (%d%d%.%d%d%.%d%d%d%d))/(%d)$' )
		assert( basepage )
		date = '[[' .. basepage .. bookpage .. '|' .. ( text or date ) .. ']]'
	else
		date = '&nbsp;'
		part = ''
	end
	return '<span class="oobdate date-field" data-part="' .. part .. '">'
		.. date .. '</span>'
end

function report.printDateWithLink( row )
	local basepage, date, part, page, bookpage
	if ( row.bookpage or '' ) == '' then
		bookpage = ''
	else
		bookpage = '#p' .. row.bookpage
	end
	page = row.page
	if page then
		basepage, part = string.match( page, '^(.+)/(%d)$' )
		assert( basepage )
		if english then
			date = row.date
		else
			date = string.sub( row.date, 9, 10 ) .. '.' .. string.sub( row.date, 6, 7 ) .. '.'
				.. string.sub( row.date, 1, 4 )
		end
		date = '[[' .. basepage .. bookpage .. '|' .. date .. ']]'
	else
		date = '&nbsp;'
		part = ''
	end
	return '<span class="oobdate date-field" data-part="' .. part .. '">'
		.. date .. '</span>'
end


return report