Перейти к содержанию

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

м
нет описания правки
мНет описания правки
мНет описания правки
Строка 19: Строка 19:
function common.page_id( frame )
function common.page_id( frame )
local vNum = frame.args['volume']
local vNum = frame.args['volume']
local pNum = frame.args['page']
local nFormat = '%.3d'
local nFormat = '%.3d'
local pNum = string.format(nFormat, frame.args['page'])
 
-- If we deal with regular number then for v.1, p.17 return 1:017
-- Check if we should alter default values
if not isempty(frame.args['page_number_type']) then
if not isempty(frame.args['volume_digits']) then
nFormat = '%.'.. frame.args['volume_digits'] ..'d'
vNum = string.format(nFormat, frame.args['volume'])
end
if not isempty(frame.args['page_digits']) then
nFormat = '%.'.. frame.args['page_digits'] ..'d'
pNum = string.format(nFormat, frame.args['page'])
pNum = string.format(nFormat, frame.args['page'])
-- Check if we should alter default values
if not isempty(frame.args['volume_digits']) then
nFormat = '%.'.. frame.args['volume_digits'] ..'d'
vNum = string.format(nFormat, frame.args['volume'])
end
if not isempty(frame.args['page_digits']) then
nFormat = '%.'.. frame.args['page_digits'] ..'d'
pNum = string.format(nFormat, frame.args['page'])
end
end
end
-- Check if we deal with Roman number
-- If we deal with Roman number then for v.1, p.xvii return 1:000017(xvii)
if frame.args['page_number_type'] == 'roman' then
if frame.args['page_number_type'] == 'roman' then
-- 1. Fill with zeros all places for arabic digits for correct sorting.
-- 1. Fill with zeros all places for arabic digits for correct sorting.
Строка 53: Строка 58:
-- 4. Add original Roman number after Arabic
-- 4. Add original Roman number after Arabic
pNum = pNum .. pArabic ..'('.. frame.args['page_digits'] ..')'
pNum = pNum .. pArabic ..'('.. frame.args['page'] ..')'
end
end