From 60974538b25657c9aa37e72cc66ca3957912ddec Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 5 Apr 2021 23:29:22 -0700 Subject: Commonmark writer: Use backslash escapes for `<` and `|`... instead of entities. Closes #7208. --- src/Text/Pandoc/Writers/Markdown.hs | 12 +++++++++++- test/command/7208.md | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/command/7208.md 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 +\ +^D +\ +``` -- cgit v1.2.3