diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2006-12-31 19:22:02 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2006-12-31 19:22:02 +0000 |
commit | 0d182772f9fb6b37de7d7a198709136e6c76e0a8 (patch) | |
tree | 2943dd56f64aa61b6eaadabd77099950658e50b0 /src/Text | |
parent | 7f7b456d9621f1a109cc2e15315677ad1d19f1bf (diff) | |
download | pandoc-0d182772f9fb6b37de7d7a198709136e6c76e0a8.tar.gz |
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
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 20 |
1 files changed, 6 insertions, 14 deletions
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 '\\' |