From 845a658affdd370c3b8395b1f57754dbb32995dd Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Wed, 29 Aug 2007 16:38:41 +0000 Subject: Fixed markdown inline code parsing so it better accords with Markdown.pl: the marker for the end of the code section is a clump of the same number of `'s with which the section began, followed by a non-` character. So, for example, ` h ``` i ` -> h ``` i. git-svn-id: https://pandoc.googlecode.com/svn/trunk@954 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/Markdown.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 8dc82446e..13345c6a9 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -666,10 +666,12 @@ symbol = do -- parses inline code, between n `s and n `s code = try $ do starts <- many1 (char '`') - let num = length starts - result <- many1Till anyChar (try (count num (char '`'))) - -- get rid of any internal newlines - return $ Code $ removeLeadingTrailingSpace $ joinWithSep " " $ lines result + skipSpaces + result <- many1Till (many1 (noneOf "`\n") <|> many1 (char '`') <|> + (char '\n' >> return " ")) + (try (skipSpaces >> count (length starts) (char '`') >> + notFollowedBy (char '`'))) + return $ Code $ removeLeadingTrailingSpace $ concat result mathWord = many1 ((noneOf " \t\n\\$") <|> (try (char '\\') >>~ notFollowedBy (char '$'))) -- cgit v1.2.3