end
end
else -- navy
if parentBC then BCdisp = ' '..BCe end
navy = navy..'*<b>'..year..BCdisp..'</b>\n'
end  
i = i + 1
end  
isolatedcat
if listall then
return listalllinks
else
return navy..'|}'
end
end  
--=========================================================  
local function nav_roman( , firstpart, roman, lastpart, minimumrom, maximumrom )
local toarabic = require('Module:ConvertNumeric').roman_to_numeral
local toroman = require('Module:Roman').main  
--sterilize/convert rom/num
local num = tonumber(toarabic(roman))
local rom = toroman({ [1] = num })
if num == nil or rom == nil then --out of range or some other error
errors = p.errorclass('Function nav_roman can\'t recognize one or more of "'..(num or 'nil')..'" & "'..
(rom or 'nil')..'" in category "'..firstpart..' '..roman..' '..lastpart..'".')
return p.failedcat(errors, 'R')
end  
--sterilize min/max
local minrom = tonumber(minimumrom or *) or tonumber(toarabic(minimumrom or *))
local maxrom = tonumber(maximumrom or *) or tonumber(toarabic(maximumrom or *))
if minrom < 1 then minrom = 1 end --toarabic returns -1 on error
if maxrom < 1 then maxrom = 9999 end --toarabic returns -1 on error
if minrom > num then minrom = num end
if maxrom < num then maxrom = num end  
--begin navroman
local navr = '{|\n'..'|\n'  
local i = -5 --nav position
while i <= 5 do
local n = num + i  
if n >= 1 then
local r = toroman({ [1] = n })
if i ~= 0 then --/ navr
local catlink = catlinkfollowr( , firstpart..' '..r..' '..lastpart, r )
if minrom <= n and n <= maxrom then
if catlink.rtarget then --a was followed
trackcat(22, 'Navseasoncats roman numeral redirected')
end
navr = navr..'*'..catlink.navelement..'\n'
else
local hidden = '<span>'..r..'</span>'
navr = navr..'*'..hidden..'\n'
if listall then
tlistall[#tlistall] = tlistall[#tlistall]..' ('..hidden..')'
end
end
else -- navr
navr = navr..'*<b>'..r..'</b>\n'
end
else
navr = navr..'*<span>'..'I'..'</span>\n'
end  
i = i + 1
end  
isolatedcat
if listall then
return listalllinks
else
return navr..'|}'
end
end  
--======================================================  
local function nav_nordinal( , firstpart, ord, lastpart, minimumord, maximumord )
local nord = tonumber(ord)
local minord = tonumber(string.match(minimumord or '', '(-?%d+)[snrt]?[tdh]?')) or -9999 --allow full ord & +/- qualifier
local maxord = tonumber(string.match(maximumord or '', '(-?%d+)[snrt]?[tdh]?')) or 9999 --allow full ord & +/- qualifier
if string.match(minimumord or '', 'BC') then minord = -math.abs(minord) end --allow BC qualifier (AD otherwise assumed)
if string.match(maximumord or '', 'BC') then maxord = -math.abs(maxord) end --allow BC qualifier (AD otherwise assumed)  
local temporal = string.match(lastpart, 'century') or
string.match(lastpart, 'millennium')  
local tspace = ' ' --assume a trailing space after ordinal
if string.match(lastpart, '^-') then tspace = '' end --DNE for "19th-century"-type cats  
--AD/BC switches & vars  
local ordBCElastparts = { --needed for parent = AD 1-5, when the BC/E format is unknown
--lists the lastpart of valid BCE cats
--"BCE" removed to match both AD & BCE cats; easier & faster than multiple string.matchs
['-century Hebrew people'] = 'BCE', --WP:CFD/Log/2016 June 21#Category:11th-century BC Hebrew people
['-century Jews'] = 'BCE', --co-nominated
['-century Judaism'] = 'BCE', --co-nominated
['-century rabbis'] = 'BCE', --co-nominated
['-century High Priests of Israel'] = 'BCE',
}
local parentBC = mw.ustring.match(lastpart, '%s(BCE?)') --"1st-century BC" format
local lastpartNoBC = mw.ustring.gsub(lastpart, '%sBCE?', '') --easier than splitting lastpart up in 2; AD never used
local BCe = parentBC or ordBCElastparts[lastpartNoBC] or 'BC' --"BC" default  
local switchADBC = 1 -- 1=AD parent
if parentBC then switchADBC = -1 end -- -1=BC parent; possibly adjusted later
local O = 0 --secondary iterator for AD-on-a-BC-parent  
if not temporal and minord < 1 then minord = 1 end --nothing before "1st parliament", etc.
if minord > nord*switchADBC then minord = nord*switchADBC end --input error; minord should be <= parent
if maxord < nord*switchADBC then maxord = nord*switchADBC end --input error; maxord should be >= parent  
--begin navnordinal
local bnb = '' --/no
if navborder == false then --for Navseasoncats decade and century
bnb = ' -style: ; background-color: transparent;'
end
local navo = '{|\n'..'|\n'  
local i = -5 --nav position
while i <= 5 do
local o = nord + i*switchADBC
local BC = ''
local BCdisp = ''
if parentBC then
if switchADBC == -1 then --parentBC looking at the BC side
if o >= 1 then --the common case
BC = ' '..BCe
elseif o == 0 then --switch to the AD side
BC = ''
switchADBC = 1
end
end
if switchADBC == 1 then --displayed o is now in the AD regime
O = O + 1 --skip o = 0 (DNE)
o = O --easiest solution: start another iterator for these AD o's displayed on a BC year parent
end
elseif o <= 0 then --parentAD looking at BC side
BC = ' '..BCe
o = math.abs(o - 1) --skip o = 0 (DNE)
end
if BC ~= '' and nord <= 5 then --only show 'BC' for parent ords <= 5: saves room, easier to read,
BCdisp = ' '..BCe --and 6 is the first/last nav ord that doesn't need a disambiguator;
end --the /parent ord will always show BC, so no need to show it another 10x  
--populate / navo
local oth = p.addord(o)
local osign = o --use o for display & osign for logic
if BC ~= '' then osign = -osign end
local hidden = '<span>'..oth..'</span>'
if temporal then --e.g. "3rd-century BC"
local lastpart = lastpartNoBC --lest we recursively add multiple "BC"s
if BC ~= '' then
lastpart = string.gsub(lastpart, temporal, temporal..BC) --replace BC if needed
end
local catlink = catlinkfollowr( , firstpart..' '..oth..tspace..lastpart, oth..BCdisp )
if (minord <= osign) and (osign <= maxord) then
if catlink.rtarget then --a was followed
trackcat(23, 'Navseasoncats nordinal redirected')
end
navo = navo..navcenter(i, catlink)
else
navo = navo..'*'..hidden..'\n'
if listall then
tlistall[#tlistall] = tlistall[#tlistall]..' ('..hidden..')'
end
end
elseif BC == '' and minord <= osign and osign <= maxord then --e.g. >= "1st parliament"
local catlink = catlinkfollowr( , firstpart..' '..oth..tspace..lastpart, oth )
if catlink.rtarget then --a was followed
trackcat(23, 'Navseasoncats nordinal redirected')
end
navo = navo..navcenter(i, catlink)
else --either out-of-range (hide), or non-temporal + BC = something might be wrong (2nd X parliament BC?); handle exceptions if/as they arise
navo = navo..'*'..hidden..'\n'
end  
i = i + 1
end  
isolatedcat
if listall then
return listalllinks
else
return navo..'|}'
end
end  
--======================================================  
local function nav_wordinal( , firstpart, word, lastpart, minimumword, maximumword, ordinal, )
--Module:ConvertNumeric.numeral_to_english flags:
-- ordinal == 'on': 'second' is output instead of 'two'
-- ordinal ~= 'on': 'two' is output instead of 'second'
local ord2eng = require('Module:ConvertNumeric').numeral_to_english
local eng2ord = require('Module:ConvertNumeric').english_to_ordinal
local th = 'th'
if ordinal ~= 'on' then
th = ''
eng2ord = require('Module:ConvertNumeric').english_to_numeral
end
local sc = string.match(word, '^%u') --sentence-case check
local lc = string.lower(word) --operate on/with lc, and restore any sc later
local nord = eng2ord(lc)
local case = nil
if sc then case = 'U' end  
local lspace = ' ' --assume a leading space (most common)
local tspace = ' ' --assume a trailing space (most common)
if string.match(firstpart, '[%-%(]$') then lspace = '' end --DNE for "Straight-eight engines"-type cats
if string.match(lastpart, '^[%-%)]' ) then tspace = '' end --DNE for "Nine-cylinder engines"-type cats  
--sterilize min/max
local minword = 1
local maxword = 99
if minimumword then
local num = tonumber(minimumword)
if num and 0 < num and num < maxword then
minword = num
else
local ord = eng2ord(minimumword)
if 0 < ord and ord < maxword then
minword = ord
end
end
end
if maximumword then