aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-04-18 10:45:46 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-04-18 10:58:50 -0700
commitd20152e01135a27decfd08dbda097fd1fda75354 (patch)
tree7fe7923a954877b446f3fefffa7c8d1c478db4b7 /src/Text/Pandoc
parent0b80073e7c10d7413fd40ac70ba6bd5eaf58cd45 (diff)
downloadpandoc-d20152e01135a27decfd08dbda097fd1fda75354.tar.gz
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.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs5
1 files changed, 3 insertions, 2 deletions
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 = ('<', "&lt;") : ('>', "&gt;") :
+ 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