aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-05-13 09:50:16 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-05-13 10:16:06 -0700
commitc9cb313a479f3d134d5df1cffe5e340034fb44b4 (patch)
tree3c8aeb05ec1eb6703acd37d120e6e8f9aa97083d
parent70df1b572bc6859a50f43f00850bec16bff354c7 (diff)
downloadpandoc-c9cb313a479f3d134d5df1cffe5e340034fb44b4.tar.gz
Fixed regression in charsInBalancedBrackets.
Introduced by e9d7504. This regression caused link and image references containing raw tex not to parse correctly. Added test. Closes #2150.
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs3
-rw-r--r--tests/markdown-reader-more.native2
-rw-r--r--tests/markdown-reader-more.txt4
3 files changed, 8 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index cc5521a62..e697febf6 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -177,9 +177,10 @@ charsInBalancedBrackets openBrackets =
(char '[' >> charsInBalancedBrackets (openBrackets + 1))
<|> (char ']' >> charsInBalancedBrackets (openBrackets - 1))
<|> (( (() <$ code)
- <|> (() <$ escapedChar')
+ <|> (() <$ (escapedChar'))
<|> (newline >> notFollowedBy blankline)
<|> skipMany1 (noneOf "[]`\n\\")
+ <|> (() <$ count 1 (oneOf "`\\"))
) >> charsInBalancedBrackets openBrackets)
--
diff --git a/tests/markdown-reader-more.native b/tests/markdown-reader-more.native
index 96204898e..8fee4953e 100644
--- a/tests/markdown-reader-more.native
+++ b/tests/markdown-reader-more.native
@@ -150,6 +150,8 @@
,Para [Link [Str "link"] ("/hi(there)","")]
,Para [Link [Str "link"] ("/hithere)","")]
,Para [Link [Str "linky"] ("hi_(there_(nested))","")]
+,Header 2 ("backslashes-in-link-references",[],[]) [Str "Backslashes",Space,Str "in",Space,Str "link",Space,Str "references"]
+,Para [Link [Str "*",RawInline (Format "tex") "\\a"] ("b","")]
,Header 2 ("reference-link-fallbacks",[],[]) [Str "Reference",Space,Str "link",Space,Str "fallbacks"]
,Para [Str "[",Emph [Str "not",Space,Str "a",Space,Str "link"],Str "]",Space,Str "[",Emph [Str "nope"],Str "]\8230"]
,Header 2 ("reference-link-followed-by-a-citation",[],[]) [Str "Reference",Space,Str "link",Space,Str "followed",Space,Str "by",Space,Str "a",Space,Str "citation"]
diff --git a/tests/markdown-reader-more.txt b/tests/markdown-reader-more.txt
index 99e9ec7e8..4a476adf0 100644
--- a/tests/markdown-reader-more.txt
+++ b/tests/markdown-reader-more.txt
@@ -258,6 +258,10 @@ Empty cells
[linky]: hi_(there_(nested))
+## Backslashes in link references
+
+[\*\a](b)
+
## Reference link fallbacks
[*not a link*] [*nope*]...