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
diff --git a/tests/Tests/Writers/Markdown.hs b/tests/Tests/Writers/Markdown.hs
index dce40ddcb..8ffd7a8c0 100644
--- a/tests/Tests/Writers/Markdown.hs
+++ b/tests/Tests/Writers/Markdown.hs
@@ -84,13 +84,13 @@ shortcutLinkRefsTests =
]
, "Reference link is followed by text in brackets"
=: (para ((link "/url" "" "link") <> "[text in brackets]"))
- =?> unlines [ "[link][][text in brackets]"
+ =?> unlines [ "[link][]\\[text in brackets\\]"
, ""
, " [link]: /url"
]
, "Reference link is followed by space and text in brackets"
=: (para ((link "/url" "" "link") <> " [text in brackets]"))
- =?> unlines [ "[link][] [text in brackets]"
+ =?> unlines [ "[link][] \\[text in brackets\\]"
, ""
, " [link]: /url"
]
diff --git a/tests/writer.markdown b/tests/writer.markdown
index 7276b31c7..6a0b9801c 100644
--- a/tests/writer.markdown
+++ b/tests/writer.markdown
@@ -80,7 +80,7 @@ E-mail style:
>
> > nested
-This should not be a block quote: 2 \> 1.
+This should not be a block quote: 2 > 1.
And a following paragraph.
@@ -581,9 +581,9 @@ AT&T is another way to write it.
This & that.
-4 \< 5.
+4 < 5.
-6 \> 5.
+6 > 5.
Backslash: \\
@@ -597,15 +597,15 @@ Left brace: {
Right brace: }
-Left bracket: [
+Left bracket: \[
-Right bracket: ]
+Right bracket: \]
Left paren: (
Right paren: )
-Greater-than: \>
+Greater-than: >
Hash: \#
@@ -652,7 +652,7 @@ Foo [bar](/url/).
Foo [bar](/url/).
-With [embedded [brackets]](/url/).
+With [embedded \[brackets\]](/url/).
[b](/url/) by itself should be a link.
@@ -662,7 +662,7 @@ Indented [twice](/url).
Indented [thrice](/url).
-This should [not][] be a link.
+This should \[not\]\[\] be a link.
[not]: /url
@@ -716,8 +716,8 @@ Footnotes
=========
Here is a footnote reference,[^1] and another.[^2] This should *not* be a
-footnote reference, because it contains a space.[\^my note] Here is an inline
-note.[^3]
+footnote reference, because it contains a space.\[\^my note\] Here is an
+inline note.[^3]
> Notes can go in quotes.[^4]
@@ -740,7 +740,7 @@ This paragraph should not be part of the note, as it is not indented.
[^3]: This is *easier* to type. Inline notes may contain
[links](http://google.com) and `]` verbatim characters, as well as
- [bracketed text].
+ \[bracketed text\].
[^4]: In quote.
diff --git a/tests/writer.opml b/tests/writer.opml
index 8f79e842c..c10ca44c8 100644
--- a/tests/writer.opml
+++ b/tests/writer.opml
@@ -26,7 +26,7 @@
-
+
@@ -52,12 +52,12 @@
-
+
-
+
@@ -66,7 +66,7 @@
-
+