Hi list,
I'm looking to perform text replacements.
\definereplacement[SubstPostmeridian][
match={[Pp].[Mm].]},
replace={\cap{pm}}
]
The \replaceword command doesn't handle periods well. The translate module doesn't seem flexible enough to cover edge cases. Consider the following example document containing both sample inputs and sample outputs:
\starttext
{\bf Markdown Input}
Our grandmother clock rang 11 p.m. and we fled.
Our grandmother clock rang 11 p.m., so we fled.
Our grandmother clock rang 11 p.m. We fled.
\blank[big]
{\bf \ConTeXt{} Output}
Our grandmother clock rang 11 \cap{pm} and we fled.
Our grandmother clock rang 11 \cap{pm}, so we fled.
Our grandmother clock rang 11 \cap{pm}. We fled.
\stoptext
It would be most convenient to write:
% Strip periods from p.m.
\definereplacement[SubstPostmeridianLowercase][
match={[Pp].[Mm]. ([^:upper:])},
replace={\cap{pm} \1}
]
% Preserve terminal period for p.m. (e.e. cummings notwithstanding)
\definereplacement[SubstPostmeridianTerminal][
match={[Pp].[Mm]. ([:upper:])},
replace={\cap{pm}. \1}
]
% Apply a macron for lowercase 'c' (McAnulty, McGenius, etc.)
replace={M\macronbelow{c}\1}
]
The \1 may be problematic. Other sigils include $1 and #1, which may also have issues.
Thank you!