git.iko.soy/typeable/pandoc
on master help sign in
Textile reader: Added code blocks with bc.
commit50d08ec2c3892076bde53b66f1b728e4bf23ab97 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 23 Jan 2011, 00:05 (16 years ago) parent9f99c39
3 files changed+15−2
src/Text/Pandoc/Readers/Textile.hs+11−2 tests/textile-reader.native+1 tests/textile-reader.textile+3
src/Text/Pandoc/Readers/Textile.hs+11−2
@@ -135,9 +135,18 @@ blockParsers = [ codeBlock
135135block :: GenParser Char ParserState Block
136136block = choice blockParsers <?> "block"
137137
138−-- | Code Blocks in Textile are between <pre> and </pre>
139138codeBlock :: GenParser Char ParserState Block
140−codeBlock = try $ do
139+codeBlock = codeBlockBc <|> codeBlockPre
140+
141+codeBlockBc :: GenParser Char ParserState Block
142+codeBlockBc = try $ do
143+ string "bc. "
144+ contents <- manyTill anyLine blanklines
145+ return $ CodeBlock ("",[],[]) $ unlines contents
146+
147+-- | Code Blocks in Textile are between <pre> and </pre>
148+codeBlockPre :: GenParser Char ParserState Block
149+codeBlockPre = try $ do
141150 htmlTag (tagOpen (=="pre") null)
142151 result' <- manyTill anyChar (try $ htmlTag (tagClose (=="pre")) >> blockBreak)
143152 -- drop leading newline if any
tests/textile-reader.native+1
@@ -24,6 +24,7 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
2424,CodeBlock ("",[],[]) " ---- (should be four hyphens)\n\n sub status {\n print \"working\";\n }\n\n this code block is indented by one tab"
2525,Para [Str "And",Str ":"]
2626,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{"
27+,CodeBlock ("",[],[]) "Code block with .bc\n continued\n @</\\\n"
2728,Header 1 [Str "Lists"]
2829,Header 2 [Str "Unordered"]
2930,Para [Str "Asterisks",Space,Str "tight",Str ":"]
tests/textile-reader.textile+3
@@ -62,6 +62,9 @@ And:
6262 These should not be escaped: \$ \\ \> \[ \{
6363</pre>
6464
65+bc. Code block with .bc
66+ continued
67+ @</\
6568
6669h1. Lists
6770