aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index ad224e212..eb566491d 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -168,10 +168,20 @@ referenceKey = try $ do
optional (char '<')
src <- many (noneOf "> \n\t")
optional (char '>')
- tit <- option "" title
+ tit <- option "" referenceTitle
blanklines
return $ KeyBlock label (removeTrailingSpace src, tit)
+referenceTitle = try $ do
+ skipSpaces
+ optional newline
+ skipSpaces
+ tit <- (charsInBalanced '(' ')' >>= return . unwords . words)
+ <|> do delim <- char '\'' <|> char '"'
+ manyTill anyChar (try (char delim >> skipSpaces >>
+ notFollowedBy (noneOf ")\n")))
+ return $ decodeCharacterReferences tit
+
noteMarker = string "[^" >> manyTill (noneOf " \t\n") (char ']')
rawLine = try $ do
@@ -793,25 +803,20 @@ source = try $ do
optional (char '<')
src <- many (noneOf ")> \t\n")
optional (char '>')
- tit <- option "" title
+ tit <- option "" linkTitle
skipSpaces
char ')'
return (removeTrailingSpace src, tit)
-titleWith startChar endChar = try $ do
- leadingSpace <- many1 (oneOf " \t\n")
- if length (filter (=='\n') leadingSpace) > 1
- then fail "title must be separated by space and on same or next line"
- else return ()
- char startChar
- tit <- manyTill anyChar (try (char endChar >> skipSpaces >>
- notFollowedBy (noneOf ")\n")))
+linkTitle = try $ do
+ skipSpaces
+ optional newline
+ skipSpaces
+ delim <- char '\'' <|> char '"'
+ tit <- manyTill anyChar (try (char delim >> skipSpaces >>
+ notFollowedBy (noneOf ")\n")))
return $ decodeCharacterReferences tit
-title = choice [ titleWith '(' ')',
- titleWith '"' '"',
- titleWith '\'' '\''] <?> "title"
-
link = try $ do
label <- reference
src <- source <|> referenceLink label