diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2011-01-23 08:49:19 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2011-01-23 08:49:55 -0800 |
| commit | 7234a79104ab8cf8358bdab153d5eefbcefc2e9a (patch) | |
| tree | 8539cc17cf1dc50cbdeab163e92006fb6f7f36b6 | |
| parent | 1d683be4146678c5d674ecd9ea365943c385774c (diff) | |
| download | pandoc-7234a79104ab8cf8358bdab153d5eefbcefc2e9a.tar.gz | |
Textile writer: Use <pre> instead of bc.. for code with blank lines.
This has fewer interaction effects.
| -rw-r--r-- | src/Text/Pandoc/Writers/Textile.hs | 13 | ||||
| -rw-r--r-- | tests/writer.textile | 8 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs index cb8f20a0a..4aaee0a32 100644 --- a/src/Text/Pandoc/Writers/Textile.hs +++ b/src/Text/Pandoc/Writers/Textile.hs @@ -118,15 +118,18 @@ blockToTextile opts (Header level inlines) = do let prefix = 'h' : (show level ++ ". ") return $ prefix ++ contents ++ "\n" +blockToTextile _ (CodeBlock (_,classes,_) str) | any (all isSpace) (lines str) = + return $ "<pre" ++ classes' ++ ">\n" ++ escapeStringForXML str ++ + "\n</pre>\n" + where classes' = if null classes + then "" + else " class=\"" ++ unwords classes ++ "\"" + blockToTextile _ (CodeBlock (_,classes,_) str) = - return $ "bc" ++ classes' ++ dots ++ escapeStringForXML str ++ "\n" + return $ "bc" ++ classes' ++ ". " ++ escapeStringForXML str ++ "\n" where classes' = if null classes then "" else "(" ++ unwords classes ++ ")" - dots = if any isBlank (lines str) - then ".. " - else ". " - isBlank = all isSpace blockToTextile opts (BlockQuote bs@[Para _]) = do contents <- blockListToTextile opts bs diff --git a/tests/writer.textile b/tests/writer.textile index f0ff383f0..ee67a7f33 100644 --- a/tests/writer.textile +++ b/tests/writer.textile @@ -76,19 +76,23 @@ h1. Code Blocks Code: -bc.. ---- (should be four hyphens) +<pre> +---- (should be four hyphens) sub status { print "working"; } this code block is indented by one tab +</pre> And: -bc.. this code block is indented by two tabs +<pre> + this code block is indented by two tabs These should not be escaped: \$ \\ \> \[ \{ +</pre> <hr /> |
