# Helper functions for preventing conversion of Roman Numerals.

# requires: brackets.foma

# From PHP: Roman numerals
# Note that this matches the empty string!
define ROMAN M^{0,4} [ C[D|M]|(D)C^{0,3} ] [ X[L|C]|(L)X^{0,3} ] [ I[V|X]|(V)I^{0,3} ];

# This will add brackets around roman numerals; the BREAK parameter should be
# a regex for a "not a word" character.  (Roughly [^\w], but it varies a bit
# for different scripts.)
define BRACKETROMAN(break) [
  [ROMAN & ?+] @-> "[[" ... "]]" || [ break | .#. ] _ [ .#. | break ]
];

# Variant originally from LanguageCrh: remove the brackets if it's a single
# character followed by a period.
define BRACKETROMAN'CRH(break) BRACKETROMAN(break) .o. [
  "[[" -> 0 || _ \BRACKETS "]]" "." ,,
  "]]" -> 0 || "[[" \BRACKETS _ "."
];
