aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-04-05 23:29:22 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-04-05 23:29:22 -0700
commit60974538b25657c9aa37e72cc66ca3957912ddec (patch)
tree9af2fde94cb294f947668ea724c1ae2386b962a6
parent21fed4a9c2c1c4bd2aedb619c3c76e0211b77a25 (diff)
downloadpandoc-60974538b25657c9aa37e72cc66ca3957912ddec.tar.gz
Commonmark writer: Use backslash escapes for `<` and `|`...
instead of entities. Closes #7208.
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs12
-rw-r--r--test/command/7208.md6
2 files changed, 17 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 4d9f3d5b0..daf45ed53 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -67,7 +67,17 @@ writePlain opts document =
-- | Convert Pandoc to Commonmark.
writeCommonMark :: PandocMonad m => WriterOptions -> Pandoc -> m Text
writeCommonMark opts document =
- evalMD (pandocToMarkdown opts document) def{ envVariant = Commonmark } def
+ evalMD (pandocToMarkdown opts' document) def{ envVariant = Commonmark } def
+ where
+ opts' = opts{ writerExtensions =
+ -- These extensions can't be enabled or disabled
+ -- for commonmark because they're part of the core;
+ -- we set them here so that escapeText will behave
+ -- properly.
+ enableExtension Ext_all_symbols_escapable $
+ enableExtension Ext_pipe_tables $
+ enableExtension Ext_intraword_underscores $
+ writerExtensions opts }
pandocTitleBlock :: Doc Text -> [Doc Text] -> Doc Text -> Doc Text
pandocTitleBlock tit auths dat =
diff --git a/test/command/7208.md b/test/command/7208.md
new file mode 100644
index 000000000..e65943ade
--- /dev/null
+++ b/test/command/7208.md
@@ -0,0 +1,6 @@
+```
+% pandoc -t gfm
+\<hi\>
+^D
+\<hi\>
+```