Background
I am trying to substitute an em-dash for double-hyphens (--) whenever they occur in user-generated text. The fonts that I am using (Chivo and Gentium Basic) result in double-hyphens added to the document, rather than \emdash{} (—).
Problem
The substitution code resembles:
\def\SubEmdash#1{%
\ctxlua{context(string.gsub("#1", "[-][-]", "\\emdash{}"))}
}
\starttext
\SubEmdash{Escaping ampersands -- \& -- is troublesome.}
\stoptext
This fails for strings that contain ampersands.
Question
An answer to either of these questions would be tremendously helpful:
- How do you force
--to produce em-dashes throughout the text, regardless of font? - How would you escape user-generated text so that the
\SubEmdashmacro never fails?
Related
The following answers also cannot handle ampersands in parameterized text: