Add a regex replace escape for regnal numbers#1898
Conversation
The existing \N escape converts a Roman number to an Arabic number.
Given the books we work on, it's common to encounter Roman numbers which
are regnal numbers, i.e., the number in a series of monarchs (kings,
queens, popes).
This change implements a new escape (\M). I used M for Monarch, since \R
(for Regnal) was taken already. With support for numbers in the range
1-99, it will take a Roman number as input (e.g. "II", "XIV", "XXIII")
and output the regnal string prefixed by "the".
II --> the Second
XIV --> the Fourteenth
XXIII --> the Twenty-third
I'm not aware of any real-world regnal numbers higher than 23, but it
was as easy to implement the 20s as it was to go through the 90s.
|
Testing notes: I use this regular expression to find roman numbers. Use this replace for testing: The most obvious use case in my mind is for abbreviations. An example replace for that case: |
|
Finally, a reminder: if this is merged, we'd want to update the wiki documentation to add |
|
Forgot this in the testing notes: that regex can cope with either upper or lowercase roman numbers, with or without a terminating I'd be interested to hear of any other words to exclude that aren't already in the pattern, too, if you encounter any. |
Thanks for the link - I normally update the manual just before I do a release |
An alternative would be to trap Roman numeral construction more precisely than Also, if you put |
windymilla
left a comment
There was a problem hiding this comment.
Code and behavior look good to me - thanks
I'll tinker with this; I think it might need to be Dan |
The existing
\Nescape converts a Roman number to an Arabic number. Given the books we work on, it's common to encounter Roman numbers which are regnal numbers, i.e., the number in a series of monarchs (kings, queens, popes).This change implements a new escape (
\M). I used M for Monarch, since\R(for Regnal) was taken already. With support for numbers in the range 1-99, it will take a Roman number as input (e.g. "II", "XIV", "XXIII") and output the regnal string prefixed by "the".I'm not aware of any real-world regnal numbers higher than 23, but it was as easy to implement the 20s as it was to go through the 90s.