From d20152e01135a27decfd08dbda097fd1fda75354 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 18 Apr 2015 10:45:46 -0700 Subject: Markdown writer: improved escaping. `<` should not be escaped as `\<`, for compatibility with original Markdown. We now escape `<` and `>` with entities. Also, we now backslash-escape square brackets. Closes #2086. --- src/Text/Pandoc/Writers/Markdown.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index dee4d56a4..ef87a8603 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -246,7 +246,8 @@ noteToMarkdown opts num blocks = do -- | Escape special characters for Markdown. escapeString :: WriterOptions -> String -> String escapeString opts = escapeStringUsing markdownEscapes - where markdownEscapes = backslashEscapes specialChars + where markdownEscapes = ('<', "<") : ('>', ">") : + backslashEscapes specialChars specialChars = (if isEnabled Ext_superscript opts then ('^':) @@ -257,7 +258,7 @@ escapeString opts = escapeStringUsing markdownEscapes (if isEnabled Ext_tex_math_dollars opts then ('$':) else id) $ - "\\`*_<>#" + "\\`*_[]#" -- | Construct table of contents from list of header blocks. tableOfContents :: WriterOptions -> [Block] -> Doc -- cgit v1.2.3