git.iko.soy/typeable/pandoc
on master help sign in
Asciidoc writer: use proper smart quotes with asciidoctor.

Asciidoctor has a different format for smart quotes. Closes #5487.

commit5affa30e8ad8b5c6ce31240ecd271fd4cccab219 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 5 May 2019, 21:47 (7 years ago) parent548ffa3
2 files changed+18−12
src/Text/Pandoc/Writers/AsciiDoc.hs+10−4 test/writer.asciidoctor+8−8
src/Text/Pandoc/Writers/AsciiDoc.hs+10−4
@@ -425,10 +425,16 @@ inlineToAsciiDoc opts (Subscript lst) = do
425425 contents <- inlineListToAsciiDoc opts lst
426426 return $ "~" <> contents <> "~"
427427inlineToAsciiDoc opts (SmallCaps lst) = inlineListToAsciiDoc opts lst
428−inlineToAsciiDoc opts (Quoted SingleQuote lst) =
429− inlineListToAsciiDoc opts (Str "`" : lst ++ [Str "'"])
430−inlineToAsciiDoc opts (Quoted DoubleQuote lst) =
431− inlineListToAsciiDoc opts (Str "``" : lst ++ [Str "''"])
428+inlineToAsciiDoc opts (Quoted qt lst) = do
429+ isAsciidoctor <- gets asciidoctorVariant
430+ inlineListToAsciiDoc opts $
431+ case qt of
432+ SingleQuote
433+ | isAsciidoctor -> [Str "'`"] ++ lst ++ [Str "`'"]
434+ | otherwise -> [Str "`"] ++ lst ++ [Str "'"]
435+ DoubleQuote
436+ | isAsciidoctor -> [Str "\"`"] ++ lst ++ [Str "`\""]
437+ | otherwise -> [Str "``"] ++ lst ++ [Str "''"]
432438inlineToAsciiDoc _ (Code _ str) = return $
433439 text "`" <> text (escapeStringUsing (backslashEscapes "`") str) <> "`"
434440inlineToAsciiDoc _ (Str str) = return $ text $ escapeString str
test/writer.asciidoctor+8−8
@@ -439,16 +439,16 @@ spaces: a^b c^d, a~b c~d.
439439
440440== Smart quotes, ellipses, dashes
441441
442−``Hello,'' said the spider. ```Shelob' is my name.''
442+"`Hello,`" said the spider. "`'`Shelob`' is my name.`"
443443
444−`A', `B', and `C' are letters.
444+'`A`', '`B`', and '`C`' are letters.
445445
446−`Oak,' `elm,' and `beech' are names of trees. So is `pine.'
446+'`Oak,`' '`elm,`' and '`beech`' are names of trees. So is '`pine.`'
447447
448−`He said, ``I want to go.''' Were you alive in the 70’s?
448+'`He said, "`I want to go.`"`' Were you alive in the 70’s?
449449
450−Here is some quoted ``code`' and a ``http://example.com/?foo=1&bar=2[quoted
451−link]''.
450+Here is some quoted '``code``' and a "`http://example.com/?foo=1&bar=2[quoted
451+link]`".
452452
453453Some dashes: one—two — three—four — five.
454454
@@ -478,7 +478,7 @@ latexmath:[\alpha + \omega \times x^2].
478478These shouldn’t be math:
479479
480480* To get the famous equation, write `$e = mc^2$`.
481−* $22,000 is a _lot_ of money. So is $34,000. (It worked if ``lot'' is
481+* $22,000 is a _lot_ of money. So is $34,000. (It worked if "`lot`" is
482482emphasized.)
483483* Shoes ($20) and socks ($5).
484484* Escaped `$`: $73 _this should be emphasized_ 23$.
@@ -621,7 +621,7 @@ or here: <http://example.com/>
621621
622622== Images
623623
624−From ``Voyage dans la Lune'' by Georges Melies (1902):
624+From "`Voyage dans la Lune`" by Georges Melies (1902):
625625
626626image:lalune.jpg[lalune,title="Voyage dans la Lune"]
627627