aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-08-29 01:51:03 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-08-29 01:51:03 +0000
commit21a2acaac9ee59b8c63dde78e99d46262518819c (patch)
tree37329a78dad2b9c3a04c6cf6b78ffbc1ddec5f9d /src/Text/Pandoc/Readers
parent86cc8c8bf2e61c60d4aa98ed563ff36c77cfde98 (diff)
downloadpandoc-21a2acaac9ee59b8c63dde78e99d46262518819c.tar.gz
Split 'title' into 'linkTitle' and 'referenceTitle', since the
rules are slightly different. git-svn-id: https://pandoc.googlecode.com/svn/trunk@952 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc/Readers')
-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