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:
fiddlosopher 2008-02-09 03:18:54 +00:00
parent 769e2f3cf5
commit b06ddad4bc

View file

@ -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