Textile reader: Added code blocks with bc.

This commit is contained in:
John MacFarlane 2011-01-23 00:05:35 -08:00
parent 9f99c39caf
commit 50d08ec2c3
3 changed files with 15 additions and 2 deletions

View file

@ -135,9 +135,18 @@ blockParsers = [ codeBlock
block :: GenParser Char ParserState Block
block = choice blockParsers <?> "block"
-- | Code Blocks in Textile are between <pre> and </pre>
codeBlock :: GenParser Char ParserState Block
codeBlock = try $ do
codeBlock = codeBlockBc <|> codeBlockPre
codeBlockBc :: GenParser Char ParserState Block
codeBlockBc = try $ do
string "bc. "
contents <- manyTill anyLine blanklines
return $ CodeBlock ("",[],[]) $ unlines contents
-- | Code Blocks in Textile are between <pre> and </pre>
codeBlockPre :: GenParser Char ParserState Block
codeBlockPre = try $ do
htmlTag (tagOpen (=="pre") null)
result' <- manyTill anyChar (try $ htmlTag (tagClose (=="pre")) >> blockBreak)
-- drop leading newline if any

View file

@ -24,6 +24,7 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
,CodeBlock ("",[],[]) " ---- (should be four hyphens)\n\n sub status {\n print \"working\";\n }\n\n this code block is indented by one tab"
,Para [Str "And",Str ":"]
,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{"
,CodeBlock ("",[],[]) "Code block with .bc\n continued\n @</\\\n"
,Header 1 [Str "Lists"]
,Header 2 [Str "Unordered"]
,Para [Str "Asterisks",Space,Str "tight",Str ":"]

View file

@ -62,6 +62,9 @@ And:
These should not be escaped: \$ \\ \> \[ \{
</pre>
bc. Code block with .bc
continued
@</\
h1. Lists