aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 35ceb7807..ba4274c1c 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -696,17 +696,23 @@ endline = try (do
-- links
--
--- a reference label for a link
-reference = do
+rawLabel = try $ do
char labelStart
- notFollowedBy (char noteStart)
-- allow for embedded brackets:
- label <- manyTill ((do{res <- reference;
- return $ [Str "["] ++ res ++ [Str "]"]}) <|>
- count 1 inline)
- (char labelEnd)
- return (normalizeSpaces (concat label))
+ raw <- manyTill (do{res <- rawLabel; return ("[" ++ res ++ "]")} <|>
+ count 1 anyChar) (char labelEnd)
+ return $ concat raw
+-- a reference label for a link
+reference = try $ do
+ notFollowedBy (try (do{char labelStart; char noteStart}))
+ raw <- rawLabel
+ oldInput <- getInput
+ setInput raw
+ label <- many inline
+ setInput oldInput
+ return (normalizeSpaces label)
+
-- source for a link, with optional title
source = try (do
char srcStart