diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-08-29 01:51:03 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-08-29 01:51:03 +0000 |
commit | 21a2acaac9ee59b8c63dde78e99d46262518819c (patch) | |
tree | 37329a78dad2b9c3a04c6cf6b78ffbc1ddec5f9d /src/Text/Pandoc | |
parent | 86cc8c8bf2e61c60d4aa98ed563ff36c77cfde98 (diff) | |
download | pandoc-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')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 33 |
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 |