Add centuries.lua

This commit is contained in:
Bastien Dumont
2022-02-08 22:27:34 +01:00
parent 82e25014bb
commit 9575922941
9 changed files with 887 additions and 0 deletions

View File

@ -0,0 +1,75 @@
---
cty-default-unit-form: sg
cty-default-era: christian
cty-other-eras:
- name: hijra
before-zero: ''
after-zero: ' AH'
unspecified: ''
cty-unit-sg: ' century'
cty-unit-pl: ' centuries'
cty-numeral-type: arabic
cty-numeral-style: lowercase
cty-ordinal-suffix-pos: normal
cty-ordinal-suffixes:
- rst
- nd
- rd
- th
cty-number-part-for-ordinal-suffix: 'last-digit'
cty-spelled-out-ordinals:
- first
- second
- third
- fourth
- fifth
- sixth
- seventh
- eighth
- ninth
- tenth
- eleventh
- twelfth
- thirteenth
- fourteenth
- fifteenth
- sixteenth
- seventeenth
- eighteenth
- nineteenth
- twentieth
- twenty-first
cty-parts-order:
- number
- suffix
- unit
- era
---
<!--
The metadata of this file corresponds to
the built-in default configuration,
except for the additional "hijra" era.
-->
[1]{.cty}
[-1]{.cty}
[5]{.cty}
[20]{.cty}
[21]{.cty}
[+5]{.cty}
[-5]{.cty}
from the [5]{.cty ctyunit=none} to the [8]{.cty}
[5]{.cty ctyunit=none}[8]{.cty ctyunit=pl}
[+3]{.cty ctyera=hijra}
[2]{.cty ctyera=hijra ctyunit=none}/[8]{.cty}

View File

@ -0,0 +1,82 @@
[ RawBlock
(Format "html")
"<!--\n The metadata of this file corresponds to\n the built-in default configuration,\n except for the additional \"hijra\" era.\n-->"
, Para
[ Span
( "" , [ "cty" ] , [] )
[ Str "1" , Str "rst" , Str " century" , Str "" ]
]
, Para
[ Span
( "" , [ "cty" ] , [] )
[ Str "1" , Str "rst" , Str " century" , Str " BC" ]
]
, Para
[ Span
( "" , [ "cty" ] , [] )
[ Str "5" , Str "th" , Str " century" , Str "" ]
]
, Para
[ Span
( "" , [ "cty" ] , [] )
[ Str "20" , Str "th" , Str " century" , Str "" ]
]
, Para
[ Span
( "" , [ "cty" ] , [] )
[ Str "21" , Str "rst" , Str " century" , Str "" ]
]
, Para
[ Span
( "" , [ "cty" ] , [] )
[ Str "5" , Str "th" , Str " century" , Str " AD" ]
]
, Para
[ Span
( "" , [ "cty" ] , [] )
[ Str "5" , Str "th" , Str " century" , Str " BC" ]
]
, Para
[ Str "from"
, Space
, Str "the"
, Space
, Span
( "" , [ "cty" ] , [ ( "ctyunit" , "none" ) ] )
[ Str "5" , Str "th" , Str "" , Str "" ]
, Space
, Str "to"
, Space
, Str "the"
, Space
, Span
( "" , [ "cty" ] , [] )
[ Str "8" , Str "th" , Str " century" , Str "" ]
]
, Para
[ Span
( "" , [ "cty" ] , [ ( "ctyunit" , "none" ) ] )
[ Str "5" , Str "th" , Str "" , Str "" ]
, Str "\8211"
, Span
( "" , [ "cty" ] , [ ( "ctyunit" , "pl" ) ] )
[ Str "8" , Str "th" , Str " centuries" , Str "" ]
]
, Para
[ Span
( "" , [ "cty" ] , [ ( "ctyera" , "hijra" ) ] )
[ Str "3" , Str "rd" , Str " century" , Str " AH" ]
]
, Para
[ Span
( ""
, [ "cty" ]
, [ ( "ctyera" , "hijra" ) , ( "ctyunit" , "none" ) ]
)
[ Str "2" , Str "nd" , Str "" , Str "" ]
, Str "/"
, Span
( "" , [ "cty" ] , [] )
[ Str "8" , Str "th" , Str " century" , Str "" ]
]
]

View File

@ -0,0 +1,64 @@
---
cty-default-unit-form: sg
cty-default-era: christ
cty-other-eras:
- name: christ
before-zero: '&#x20;av. J.-C.'
after-zero: '&#x20;ap. J.-C.'
unspecified: ''
- name: hegire
before-zero: ''
after-zero: '&#x20;A. H.'
unspecified: ''
cty-unit-sg: ' siècle'
cty-unit-pl: ' siècles'
cty-numeral-type: roman
cty-numeral-style: smallcaps
cty-ordinal-suffix-pos: exponent
cty-ordinal-suffixes:
- er
- e
cty-number-part-for-ordinal-suffix: 'whole'
cty-spelled-out-ordinals:
- premier
- deuxième
- troisième
- quatrième
- cinquième
- sixième
- septième
- huitième
- neuvième
- dixième
- onzième
- douzième
- treizième
- quatorzième
- quinzième
- seizième
- dix-septième
- dix-huitième
- dix-neuvième
- vingtième
- vingt-et-unième
---
[1]{.cty}
[-1]{.cty}
[5]{.cty}
[21]{.cty}
[+5]{.cty}
[-5]{.cty}
du [5]{.cty ctyunit=none} au [8]{.cty}
[5]{.cty ctyunit=none}-[8]{.cty ctyunit=pl}
[+3]{.cty ctyera=hegire}
[2]{.cty ctyera=hegire ctyunit=none}/[8]{.cty}

View File

@ -0,0 +1,122 @@
[ Para
[ Span
( "" , [ "cty" ] , [] )
[ SmallCaps [ Str "i" ]
, Superscript [ Str "er" ]
, Str "\160si\232cle"
, Str ""
]
]
, Para
[ Span
( "" , [ "cty" ] , [] )
[ SmallCaps [ Str "i" ]
, Superscript [ Str "er" ]
, Str "\160si\232cle"
, Str " av.\160J.-C."
]
]
, Para
[ Span
( "" , [ "cty" ] , [] )
[ SmallCaps [ Str "v" ]
, Superscript [ Str "e" ]
, Str "\160si\232cle"
, Str ""
]
]
, Para
[ Span
( "" , [ "cty" ] , [] )
[ SmallCaps [ Str "xxi" ]
, Superscript [ Str "e" ]
, Str "\160si\232cle"
, Str ""
]
]
, Para
[ Span
( "" , [ "cty" ] , [] )
[ SmallCaps [ Str "v" ]
, Superscript [ Str "e" ]
, Str "\160si\232cle"
, Str " ap.\160J.-C."
]
]
, Para
[ Span
( "" , [ "cty" ] , [] )
[ SmallCaps [ Str "v" ]
, Superscript [ Str "e" ]
, Str "\160si\232cle"
, Str " av.\160J.-C."
]
]
, Para
[ Str "du"
, Space
, Span
( "" , [ "cty" ] , [ ( "ctyunit" , "none" ) ] )
[ SmallCaps [ Str "v" ]
, Superscript [ Str "e" ]
, Str ""
, Str ""
]
, Space
, Str "au"
, Space
, Span
( "" , [ "cty" ] , [] )
[ SmallCaps [ Str "viii" ]
, Superscript [ Str "e" ]
, Str "\160si\232cle"
, Str ""
]
]
, Para
[ Span
( "" , [ "cty" ] , [ ( "ctyunit" , "none" ) ] )
[ SmallCaps [ Str "v" ]
, Superscript [ Str "e" ]
, Str ""
, Str ""
]
, Str "-"
, Span
( "" , [ "cty" ] , [ ( "ctyunit" , "pl" ) ] )
[ SmallCaps [ Str "viii" ]
, Superscript [ Str "e" ]
, Str "\160si\232cles"
, Str ""
]
]
, Para
[ Span
( "" , [ "cty" ] , [ ( "ctyera" , "hegire" ) ] )
[ SmallCaps [ Str "iii" ]
, Superscript [ Str "e" ]
, Str "\160si\232cle"
, Str " A.\160H."
]
]
, Para
[ Span
( ""
, [ "cty" ]
, [ ( "ctyera" , "hegire" ) , ( "ctyunit" , "none" ) ]
)
[ SmallCaps [ Str "ii" ]
, Superscript [ Str "e" ]
, Str ""
, Str ""
]
, Str "/"
, Span
( "" , [ "cty" ] , [] )
[ SmallCaps [ Str "viii" ]
, Superscript [ Str "e" ]
, Str "\160si\232cle"
, Str ""
]
]
]

View File

@ -0,0 +1,65 @@
restore_default_config()
assert(metadata_to_config('cty-suffix-sg') == 'suffix_sg')
assert(metadata_to_config('last-digit') == 'last_digit')
local output = metalist_to_configlist(pandoc.MetaList({
pandoc.MetaInlines(pandoc.Str('number')),
pandoc.MetaInlines(pandoc.Str('suffix')),
pandoc.MetaInlines(pandoc.Str('unit')),
pandoc.MetaInlines(pandoc.Str('era'))}))
assert(output[1] == 'number'
and output[2] == 'suffix'
and output[3] == 'unit'
and output[4] == 'era')
local output = metalist_to_configlist(pandoc.MetaList({
pandoc.MetaInlines({
pandoc.Str('the'),
pandoc.Space(),
pandoc.Str('third')})}))
assert(output[1] == 'the third')
assert(format_century_number(6) == pandoc.Str('6'))
config.numeral_type = 'spelled_out'
assert(format_century_number(6) == pandoc.Str('sixth'))
config.numeral_type = 'roman'
config.numeral_style = 'smallcaps'
assert(format_century_number(6) == pandoc.SmallCaps(pandoc.Str('vi')))
assert(format_century_number(-6) == pandoc.SmallCaps(pandoc.Str('vi')))
config.numeral_style = 'uppercase'
assert(format_century_number(6) == pandoc.Str('VI'))
restore_default_config('numeral_type')
restore_default_config('numeral_style')
assert(get_last_digit(235) == 5)
assert(get_last_digit(5) == 5)
assert(get_raw_ordinal_suffix('1') == 'rst')
assert(get_raw_ordinal_suffix('+1') == 'rst')
assert(get_raw_ordinal_suffix('-1') == 'rst')
assert(get_raw_ordinal_suffix('2') == 'nd')
assert(get_raw_ordinal_suffix('9') == 'th')
assert(get_raw_ordinal_suffix('20') == 'th')
assert(get_raw_ordinal_suffix('21') == 'rst')
config.number_part_for_ordinal_suffix = 'whole'
assert(get_raw_ordinal_suffix('21') == 'th')
assert(get_raw_ordinal_suffix('25') == 'th')
config.numeral_type = 'spelled_out'
assert(get_raw_ordinal_suffix('1') == '')
restore_default_config('numberal_type')
restore_default_config('number_part_for_ordinal_suffix')
assert(get_era_indication('+6', 'christian') == pandoc.Str(' AD'))
assert(get_era_indication('-6', 'christian') == pandoc.Str(' BC'))
assert(get_era_indication('6', 'christian') == pandoc.Str(''))
config.parts_order = { 'unit', 'era', 'number', 'suffix' }
local input = { '3', 'rd', 'century', 'CE' }
local output = reorder_parts(input)
assert(output[1] == 'century'
and output[2] == 'CE'
and output[3] == '3'
and output[4] == 'rd')
restore_default_config('parts_order')