From c9cb313a479f3d134d5df1cffe5e340034fb44b4 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 13 May 2015 09:50:16 -0700 Subject: 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. --- src/Text/Pandoc/Readers/Markdown.hs | 3 ++- tests/markdown-reader-more.native | 2 ++ tests/markdown-reader-more.txt | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) 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*]... -- cgit v1.2.3