AsciiDoc writer: Fixed code blocks.

Closes #1861.
This commit is contained in:
John MacFarlane 2015-11-23 21:29:21 -08:00
parent 4361dc0245
commit b20ecbedc4
2 changed files with 26 additions and 27 deletions

View file

@ -160,13 +160,12 @@ blockToAsciiDoc opts (Header level (ident,_,_) inlines) = do
_ -> empty) <> blankline
else
identifier $$ text (replicate level '=') <> space <> contents <> blankline)
blockToAsciiDoc _ (CodeBlock (_,classes,_) str) = return $
flush (attrs <> dashes <> space <> attrs <> cr <> text str <>
cr <> dashes) <> blankline
where dashes = text $ replicate (maximum $ map length $ lines str) '-'
attrs = if null classes
then empty
else text $ intercalate "," $ "code" : classes
blockToAsciiDoc _ (CodeBlock (_,classes,_) str) = return $ (flush $
if null classes
then "...." $$ text str $$ "...."
else attrs $$ "----" $$ text str $$ "----")
<> blankline
where attrs = "[" <> text (intercalate "," ("source" : classes)) <> "]"
blockToAsciiDoc opts (BlockQuote blocks) = do
contents <- blockListToAsciiDoc opts blocks
let isBlock (BlockQuote _) = True

View file

@ -80,11 +80,11 @@ ______________________
--
Code in a block quote:
--------------------
....
sub status {
print "working";
}
--------------------
....
A list:
@ -116,7 +116,7 @@ Code Blocks
Code:
--------------------------------------
....
---- (should be four hyphens)
sub status {
@ -124,15 +124,15 @@ sub status {
}
this code block is indented by one tab
--------------------------------------
....
And:
--------------------------------------------
....
this code block is indented by two tabs
These should not be escaped: \$ \\ \> \[ \{
--------------------------------------------
....
'''''
@ -325,9 +325,9 @@ _apple_::
_orange_::
orange fruit
+
---------------------
....
{ orange code block }
---------------------
....
+
__________________
orange block quote
@ -393,17 +393,17 @@ foo
This should be a code block, though:
-------
....
<div>
foo
</div>
-------
....
As should this:
--------------
....
<div>foo</div>
--------------
....
Now, nested:
@ -415,17 +415,17 @@ Multiline:
Code block:
----------------
....
<!-- Comment -->
----------------
....
Just plain comment, with trailing spaces on the line:
Code:
------
....
<hr />
------
....
Hrs:
@ -616,9 +616,9 @@ Indented link:/url[thrice].
This should [not][] be a link.
-----------
....
[not]: /url
-----------
....
Foo link:/url/[bar].
@ -654,9 +654,9 @@ ________________________________
Auto-links should not occur here: `<http://example.com/>`
------------------------------
....
or here: <http://example.com/>
------------------------------
....
'''''