diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-11-05 09:55:15 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-11-05 09:55:15 -0800 |
commit | f14396011e7a22c84f37104a7c97de530aec76f5 (patch) | |
tree | 9a988cca4c218705816c0a59dcd8cf1463a2b25e /src/Text/Pandoc/Writers | |
parent | 1269fbd03228de12d3ea1911e17bd5cb2564a245 (diff) | |
download | pandoc-f14396011e7a22c84f37104a7c97de530aec76f5.tar.gz |
CommonMark writer: make sure --ascii affects quotes, super/subscript.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/CommonMark.hs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/CommonMark.hs b/src/Text/Pandoc/Writers/CommonMark.hs index e590ceac8..c007f7734 100644 --- a/src/Text/Pandoc/Writers/CommonMark.hs +++ b/src/Text/Pandoc/Writers/CommonMark.hs @@ -264,19 +264,21 @@ inlineToNodes opts (Superscript xs) = then ((node (HTML_INLINE (T.pack "<sup>")) [] : inlinesToNodes opts xs ++ [node (HTML_INLINE (T.pack "</sup>")) []]) ++ ) else case traverse toSuperscriptInline xs of - Nothing -> + Just xs' | not (writerPreferAscii opts) + -> (inlinesToNodes opts xs' ++) + _ -> ((node (TEXT (T.pack "^(")) [] : inlinesToNodes opts xs ++ [node (TEXT (T.pack ")")) []]) ++ ) - Just xs' -> (inlinesToNodes opts xs' ++) inlineToNodes opts (Subscript xs) = if isEnabled Ext_raw_html opts then ((node (HTML_INLINE (T.pack "<sub>")) [] : inlinesToNodes opts xs ++ [node (HTML_INLINE (T.pack "</sub>")) []]) ++ ) else case traverse toSubscriptInline xs of - Nothing -> + Just xs' | not (writerPreferAscii opts) + -> (inlinesToNodes opts xs' ++) + _ -> ((node (TEXT (T.pack "_(")) [] : inlinesToNodes opts xs ++ [node (TEXT (T.pack ")")) []]) ++ ) - Just xs' -> (inlinesToNodes opts xs' ++) inlineToNodes opts (SmallCaps xs) = if isEnabled Ext_raw_html opts then ((node (HTML_INLINE (T.pack "<span class=\"smallcaps\">")) [] @@ -297,14 +299,18 @@ inlineToNodes opts (RawInline fmt xs) = (node (CUSTOM_INLINE (T.pack xs) T.empty) [] :) | otherwise = id inlineToNodes opts (Quoted qt ils) = - ((node (TEXT start) [] : - inlinesToNodes opts ils ++ [node (TEXT end) []]) ++) + ((node (HTML_INLINE start) [] : + inlinesToNodes opts ils ++ [node (HTML_INLINE end) []]) ++) where (start, end) = case qt of SingleQuote | isEnabled Ext_smart opts -> ("'","'") + | writerPreferAscii opts -> + ("‘", "’") | otherwise -> ("‘", "’") DoubleQuote | isEnabled Ext_smart opts -> ("\"", "\"") + | writerPreferAscii opts -> + ("“", "”") | otherwise -> ("“", "”") inlineToNodes _ (Code _ str) = (node (CODE (T.pack str)) [] :) inlineToNodes opts (Math mt str) = |