From 50d08ec2c3892076bde53b66f1b728e4bf23ab97 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sun, 23 Jan 2011 00:05:35 -0800 Subject: [PATCH] Textile reader: Added code blocks with bc. --- src/Text/Pandoc/Readers/Textile.hs | 13 +++++++++++-- tests/textile-reader.native | 1 + tests/textile-reader.textile | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index c3b2e69a2..05bcd6108 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -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 diff --git a/tests/textile-reader.native b/tests/textile-reader.native index f571c149a..a00507282 100644 --- a/tests/textile-reader.native +++ b/tests/textile-reader.native @@ -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 ":"] diff --git a/tests/textile-reader.textile b/tests/textile-reader.textile index 64545c2c0..9fa90bb32 100644 --- a/tests/textile-reader.textile +++ b/tests/textile-reader.textile @@ -62,6 +62,9 @@ And: These should not be escaped: \$ \\ \> \[ \{ </pre> +bc. Code block with .bc + continued + @</\ h1. Lists