git.iko.soy/typeable/pandoc
on master help sign in
AsciiDoc writer: Fixed code blocks.

Closes #1861.

commitb20ecbedc4e09a40aa42fe4e505c0cd097f23ee7 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 23 Nov 2015, 21:29 (11 years ago) parent4361dc0
2 files changed+26−27
src/Text/Pandoc/Writers/AsciiDoc.hs+6−7 tests/writer.asciidoc+20−20
src/Text/Pandoc/Writers/AsciiDoc.hs+6−7
@@ -160,13 +160,12 @@ blockToAsciiDoc opts (Header level (ident,_,_) inlines) = do
160160 _ -> empty) <> blankline
161161 else
162162 identifier $$ text (replicate level '=') <> space <> contents <> blankline)
163−blockToAsciiDoc _ (CodeBlock (_,classes,_) str) = return $
164− flush (attrs <> dashes <> space <> attrs <> cr <> text str <>
165− cr <> dashes) <> blankline
166− where dashes = text $ replicate (maximum $ map length $ lines str) '-'
167− attrs = if null classes
168− then empty
169− else text $ intercalate "," $ "code" : classes
163+blockToAsciiDoc _ (CodeBlock (_,classes,_) str) = return $ (flush $
164+ if null classes
165+ then "...." $$ text str $$ "...."
166+ else attrs $$ "----" $$ text str $$ "----")
167+ <> blankline
168+ where attrs = "[" <> text (intercalate "," ("source" : classes)) <> "]"
170169blockToAsciiDoc opts (BlockQuote blocks) = do
171170 contents <- blockListToAsciiDoc opts blocks
172171 let isBlock (BlockQuote _) = True
tests/writer.asciidoc+20−20
@@ -80,11 +80,11 @@ ______________________
8080--
8181Code in a block quote:
8282
83−--------------------
83+....
8484sub status {
8585 print "working";
8686}
87−--------------------
87+....
8888
8989A list:
9090
@@ -116,7 +116,7 @@ Code Blocks
116116
117117Code:
118118
119−--------------------------------------
119+....
120120---- (should be four hyphens)
121121
122122sub status {
@@ -124,15 +124,15 @@ sub status {
124124}
125125
126126this code block is indented by one tab
127−--------------------------------------
127+....
128128
129129And:
130130
131−--------------------------------------------
131+....
132132 this code block is indented by two tabs
133133
134134These should not be escaped: \$ \\ \> \[ \{
135−--------------------------------------------
135+....
136136
137137'''''
138138
@@ -325,9 +325,9 @@ _apple_::
325325_orange_::
326326 orange fruit
327327 +
328−---------------------
328+....
329329{ orange code block }
330−---------------------
330+....
331331 +
332332 __________________
333333 orange block quote
@@ -393,17 +393,17 @@ foo
393393
394394This should be a code block, though:
395395
396−-------
396+....
397397<div>
398398 foo
399399</div>
400−-------
400+....
401401
402402As should this:
403403
404−--------------
404+....
405405<div>foo</div>
406−--------------
406+....
407407
408408Now, nested:
409409
@@ -415,17 +415,17 @@ Multiline:
415415
416416Code block:
417417
418−----------------
418+....
419419<!-- Comment -->
420−----------------
420+....
421421
422422Just plain comment, with trailing spaces on the line:
423423
424424Code:
425425
426−------
426+....
427427<hr />
428−------
428+....
429429
430430Hr’s:
431431
@@ -616,9 +616,9 @@ Indented link:/url[thrice].
616616
617617This should [not][] be a link.
618618
619−-----------
619+....
620620[not]: /url
621−-----------
621+....
622622
623623Foo link:/url/[bar].
624624
@@ -654,9 +654,9 @@ ________________________________
654654
655655Auto-links should not occur here: `<http://example.com/>`
656656
657−------------------------------
657+....
658658or here: <http://example.com/>
659−------------------------------
659+....
660660
661661'''''
662662