diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-04-05 23:29:22 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-04-05 23:29:22 -0700 |
commit | 60974538b25657c9aa37e72cc66ca3957912ddec (patch) | |
tree | 9af2fde94cb294f947668ea724c1ae2386b962a6 | |
parent | 21fed4a9c2c1c4bd2aedb619c3c76e0211b77a25 (diff) | |
download | pandoc-60974538b25657c9aa37e72cc66ca3957912ddec.tar.gz |
Commonmark writer: Use backslash escapes for `<` and `|`...
instead of entities. Closes #7208.
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 12 | ||||
-rw-r--r-- | test/command/7208.md | 6 |
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\> +``` |