Textile writer: Use <pre> instead of bc.. for code with blank lines.

This has fewer interaction effects.
This commit is contained in:
John MacFarlane 2011-01-23 08:49:19 -08:00
parent 1d683be414
commit 7234a79104
2 changed files with 14 additions and 7 deletions

View file

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

View file

@ -76,19 +76,23 @@ h1. Code Blocks
Code:
bc.. ---- (should be four hyphens)
<pre>
---- (should be four hyphens)
sub status {
print &quot;working&quot;;
}
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: \$ \\ \&gt; \[ \{
</pre>
<hr />