Initial support for delimited code blocks in markdown reader.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1203 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
parent
769e2f3cf5
commit
b06ddad4bc
1 changed files with 27 additions and 1 deletions
|
@ -295,7 +295,33 @@ hrule = try $ do
|
|||
|
||||
indentedLine = indentSpaces >> manyTill anyChar newline >>= return . (++ "\n")
|
||||
|
||||
codeBlock = do
|
||||
codeBlock = codeBlockIndented <|> codeBlockDelimited
|
||||
|
||||
codeBlockDelimiter len = try $ do
|
||||
size <- case len of
|
||||
Just l -> count l (char '~') >> return l
|
||||
Nothing -> count 3 (char '~') >> many (char '~') >>=
|
||||
return . (+ 3) . length
|
||||
many spaceChar
|
||||
lang <- option "" classAttribute
|
||||
blankline
|
||||
return (size, lang)
|
||||
|
||||
classAttribute = try $ do
|
||||
char '{'
|
||||
many spaceChar
|
||||
char '.'
|
||||
attr <- many1 alphaNum
|
||||
many spaceChar
|
||||
char '}'
|
||||
return attr
|
||||
|
||||
codeBlockDelimited = try $ do
|
||||
(size, lang) <- codeBlockDelimiter Nothing
|
||||
contents <- manyTill anyLine (codeBlockDelimiter (Just size))
|
||||
return $ CodeBlock lang $ concat contents
|
||||
|
||||
codeBlockIndented = do
|
||||
contents <- many1 (indentedLine <|>
|
||||
try (do b <- blanklines
|
||||
l <- indentedLine
|
||||
|
|
Loading…
Add table
Reference in a new issue