2

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 \SubEmdash macro never fails?

Related

The following answers also cannot handle ampersands in parameterized text:

1 Answer 1

3

The issue is due to font features being disabled by default. Enable font features as follows:

\starttypescript [serif] [ContentBody]
  \definefontsynonym [Serif] [name:librebaskervilleregular] [features=default]
\stoptypescript

\definetypeface[ContentFont] [rm] [serif] [ContentBody] [default]
\usetypescript[ContentFont] [ec]
\setupbodyfont[ContentFont]

This should automatically output curly quotes, elongated dashes, and ligatures.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .