From 0d182772f9fb6b37de7d7a198709136e6c76e0a8 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sun, 31 Dec 2006 19:22:02 +0000 Subject: Revised inline code parsing in Markdown reader to conform to Markdown.pl. Now any number of `'s can begin inline code, which will end with the same number of `'s. For example, to have two backticks as code, write ``` `` ``` git-svn-id: https://pandoc.googlecode.com/svn/trunk@360 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/Markdown.hs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 4d49e1f28..9913b60f9 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -519,7 +519,7 @@ rawLaTeXEnvironment' = do -- inline -- -text = choice [ math, strong, emph, code2, code1, str, linebreak, tabchar, +text = choice [ math, strong, emph, code, str, linebreak, tabchar, whitespace, endline ] "text" inline = choice [ rawLaTeXInline', escapedChar, special, hyphens, text, @@ -548,23 +548,15 @@ hyphens = try (do else do{ string ""; return Space } return (Str result)) --- parses inline code, between codeStart and codeEnd -code1 = try (do - char codeStart - result <- many (noneOf [codeEnd]) - char codeEnd +-- parses inline code, between n codeStarts and n codeEnds +code = try (do + starts <- many1 (char codeStart) + let num = length starts + result <- many1Till anyChar (try (count num (char codeEnd))) -- get rid of any internal newlines let result' = removeLeadingTrailingSpace $ joinWithSep " " $ lines result return (Code result')) --- parses inline code, between 2 codeStarts and 2 codeEnds -code2 = try (do - string [codeStart, codeStart] - result <- manyTill anyChar (try (string [codeEnd, codeEnd])) - let result' = removeLeadingTrailingSpace $ joinWithSep " " $ lines result - -- get rid of any internal newlines - return (Code result')) - mathWord = many1 (choice [ (noneOf (" \t\n\\" ++ [mathEnd])), (try (do c <- char '\\' -- cgit v1.2.3