From f6bcbe1554f9ee62709607ce5c9ecafb23ef4748 Mon Sep 17 00:00:00 2001 From: Christoph Jaeger Date: Mon, 17 Nov 2014 13:36:22 -0500 Subject: [PATCH] Fix and enhance en/em dash translation Depending on the back-end being used, '--' gets currently translated either to an em dash (HTML, for instance) or an en dash (LaTeX). To allow convenient usage of both types of dashes and resolve this inconsistency, translate (in sync with LaTeX) '--' to en dash and '---' to em dash. In order to avoid "breaking" existing documents, introduce an attribute named 'compat-mode' that is defined by default and must be undefined to enable the en/em dash translation described above. Signed-off-by: Christoph Jaeger --- asciidoc.conf | 17 +++++++++++++++++ latex.conf | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/asciidoc.conf b/asciidoc.conf index cb9fb5b..134d7fc 100644 --- a/asciidoc.conf +++ b/asciidoc.conf @@ -52,6 +52,7 @@ lsquo=‘ rsquo=’ ldquo=“ rdquo=” +compat-mode= [titles] subs=specialcharacters,quotes,replacements,macros,attributes,replacements2 @@ -124,6 +125,22 @@ monospacedwords= (\w)--(\w)=\1—\2 \\--(?!-)=-- +ifndef::compat-mode[] +# --- Spaced and unspaced em dashes (entity reference —). +# Space on both sides is translated to thin space characters. +(^--- )=—  +(\n--- )|( --- )|( ---\n)= —  +(\w)---(\w)=\1—\2 +\\---(?!-)=--- + +# -- Spaced and unspaced en dashes (entity reference –). +# Space on both sides is translated to thin space characters. +(^-- )=–  +(\n-- )|( -- )|( --\n)= –  +(\w)--(\w)=\1–\2 +\\--(?!-)=-- +endif::compat-mode[] + # Replace vertical typewriter apostrophe with punctuation apostrophe. (\w)'(\w)=\1’\2 (\w)\\'(\w)=\1'\2 diff --git a/latex.conf b/latex.conf index f8b7b17..a4cf13b 100644 --- a/latex.conf +++ b/latex.conf @@ -70,7 +70,10 @@ _=\_{} # Line break. (?m)^(.*)\s\+$=\1 !..backslash..!newline!..braceleft..!!..braceright..! -# -- Spaced em dashes (entity reference —) +# --- Spaced em dashes (entity reference —) +(^|[^-\\])---($|[^-])=\1---\2 + +# -- Spaced en dashes (entity reference –) (^|[^-\\])--($|[^-])=\1--\2