git.iko.soy/typeable/pandoc
on master help sign in
Split 'title' into 'linkTitle' and 'referenceTitle', since the
21a2acafiddlosopher
src/Text/Pandoc/Readers/Markdown.hs+19−14
@@ -168,10 +168,20 @@ referenceKey = try $ do
168 optional (char '<')
168 optional (char '<')
169 src <- many (noneOf "> \n\t")
169 src <- many (noneOf "> \n\t")
170 optional (char '>')
170 optional (char '>')
171− tit <- option "" title
171+ tit <- option "" referenceTitle
172 blanklines
172 blanklines
173 return $ KeyBlock label (removeTrailingSpace src, tit)
173 return $ KeyBlock label (removeTrailingSpace src, tit)
174
174
175+referenceTitle = try $ do
176+ skipSpaces
177+ optional newline
178+ skipSpaces
179+ tit <- (charsInBalanced '(' ')' >>= return . unwords . words)
180+ <|> do delim <- char '\'' <|> char '"'
181+ manyTill anyChar (try (char delim >> skipSpaces >>
182+ notFollowedBy (noneOf ")\n")))
183+ return $ decodeCharacterReferences tit
184+
175noteMarker = string "[^" >> manyTill (noneOf " \t\n") (char ']')
185noteMarker = string "[^" >> manyTill (noneOf " \t\n") (char ']')
176
186
177rawLine = try $ do
187rawLine = try $ do
@@ -793,25 +803,20 @@ source = try $ do
793 optional (char '<')
803 optional (char '<')
794 src <- many (noneOf ")> \t\n")
804 src <- many (noneOf ")> \t\n")
795 optional (char '>')
805 optional (char '>')
796− tit <- option "" title
806+ tit <- option "" linkTitle
797 skipSpaces
807 skipSpaces
798 char ')'
808 char ')'
799 return (removeTrailingSpace src, tit)
809 return (removeTrailingSpace src, tit)
800
810
801−titleWith startChar endChar = try $ do
811+linkTitle = try $ do
802− leadingSpace <- many1 (oneOf " \t\n")
812+ skipSpaces
803− if length (filter (=='\n') leadingSpace) > 1
813+ optional newline
804− then fail "title must be separated by space and on same or next line"
814+ skipSpaces
805− else return ()
815+ delim <- char '\'' <|> char '"'
806− char startChar
807− tit <- manyTill anyChar (try (char endChar >> skipSpaces >>
816+ tit <- manyTill anyChar (try (char delim >> skipSpaces >>
808− notFollowedBy (noneOf ")\n")))
817+ notFollowedBy (noneOf ")\n")))
809 return $ decodeCharacterReferences tit
818 return $ decodeCharacterReferences tit
810
819
811−title = choice [ titleWith '(' ')',
812− titleWith '"' '"',
813− titleWith '\'' '\''] <?> "title"
814−
815link = try $ do
820link = try $ do
816 label <- reference
821 label <- reference
817 src <- source <|> referenceLink label
822 src <- source <|> referenceLink label