# Using Babel-like shorthands in ConTeXt

I'm new to ConTeXt, and I feel very excited about its capabilities. But as soon as I've tried to make a handsome document in Russian, I've learned that ConTeXt doesn't seem to provide Babel-shorthands as (Lua/Xe/pdf)LaTeX have used to:

% pdfLaTeX code
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\begin{document}
"--* Прямая речь "--- "<после "тире"' неразрывный пробел">.
\end{document}


The code above contains a direct speech dash, a Cyrillic em-dash and two types of quote marks, and produces:

Unsurprisingly, ConTeXt recognizes none of those shorthands:

% ConTeXt code
\mainlanguage[russian]
\setupbodyfont[libertine]
\starttext
"--* Прямая речь "--- "<после "тире"' неразрывный пробел">.
\stoptext


While quote marks can be substituted with corresponding font characters (« » „ ‟) , the specific Cyrillic dash "--- (which is shorter than em-dash, and has fixed spaces around it with non-breaking one at left side) can't be, and I've yet to figure out a way of typing or implementing it.

Is there a way of enabling Babel shorthands or implementing their functionality in ConTeXt?

(Thanks and Happy New Year!)

UPD1: I've found that a nicer way to define \cyrdash symbol would be something like

\define\cyrdash{\scale[sx=0.9]{---}} % produces a smoother dash


Also here's how "--- is defined in Babel:

\def\@Acdash{\ifdim\lastskip>\z@\unskip\nobreak\hskip.2em\fi
\cyrdash\hskip.2em\ignorespaces}%


UPD2: I was able to recreate the desired behavior with translate module:

\define\cyrdash{\scale[sx=0.80]{---}}  % Cyrillic dash sign

\usemodule[translate]
\translateinput["---][\unskip\thinspace\cyrdash\thinspace\ignorespaces] % Cyrillic text em-dash
\translateinput["--*][\leavevmode\cyrdash\hskip.35em] % Cyrillic direct speech dash

\mainlanguage[russian]
\setupbodyfont[dejavu]
\starttext\enableinputtranslation
"--* Прямая речь "--- \quotation{после \quote{тире} неразрывный пробел}.
\stoptext


(Many thanks to @Aditya for suggestions)

For the quotes, you can either use:

\quotation{после \quote{тире} неразрывный пробел}.


or (as you note) directly type:

«после „тире” неразрывный пробел».


Here is a minimal example:

\mainlanguage[ru]
\setupbodyfont[dejavu]
\starttext
\quotation{после \quote{тире} неразрывный пробел}.

«после „тире” неразрывный пробел».
\stoptext


which gives:

For the em-dashes, you can use compound words: |<| and |=|. By default, they do not leave any space, but that can be modified as follows:

\define\cyrdash{\hbox to.8em{--\hss--}}
\unprotect
\setuplanguage
[\s!ru]
[
\c!midsentence=\cyrdash,
\c!leftsentence=\cyrdash,
\c!rightsentence=\cyrdash,
]
\def\beginofsubsentencespacing{\thinspace}
\def\endofsubsentencespacing{\thinspace}

% Redefine |=|
\definetextmodediscretionary =
{\endofsubsentencespacing\prewordbreak\midsentence\beginofsubsentencespacing\prewordbreak}
\protect

\mainlanguage[ru]
\setupbodyfont[dejavu]

\starttext
|=|Прямая речь|<|\quotation{после \quote{тире} неразрывный пробел}.
\stoptext


which gives

EDIT: Depending on the exact definitions that you want, you can redefine |<| and |=| (or even create new ones instead of < and =). For example:

\define\cyrdash{\dontleavehmode\scale[sx=0.80]{---}}
% Redefine |=|
\definetextmodediscretionary =
{\leavevmode\cyrdash\hskip.35em}

% Redefine |<|
\definetextmodediscretionary <
{\removeunwantedspaces\thinspace\cyrdash\thinspace\ignorespaces}


Note that \thinspace is defined (roughly) as: \kern<amount>, so it is unbreakable. If you want breakable space, use \hskip<amount>.

• As the example shows, "--- typesets a shorter dash than the em-dash, with thin (non-breaking) spaces on either side; with "--* the same dash is used, but only spaced at the right. – egreg Jan 1 '16 at 23:12
• @egreg: See my updated answer. I copied the definition of \cyrdash from another answer; I am guessing that the spaces should be \thinspace; if not, that can be changed appropriately. – Aditya Jan 2 '16 at 0:10
• @Aditya thank you very much, great take on quotes, but this modified compound word thing still doesn't leave the space? And also I was a bit wrong: "--- has a fixed non-breaking space at its left and breakable fixed space (of the same width) at its right. Could you modify the code accordingly, please? – The_Keeper Jan 2 '16 at 0:19
• @Aditya: I've figured that |=| does seem to behave like "---. Did you mean using |<| as "--* and |=| as "---? – The_Keeper Jan 2 '16 at 0:35
• @Aditya: also |=| doesn't seem to suppress source whitespaces (which might be inconvenient). I've updated the question with implementation of this dash in babel, I hope that might be helpful. – The_Keeper Jan 2 '16 at 1:03