git.iko.soy/typeable/pandoc
on master help sign in
DokuWiki writer: Use proper `<code>` tags for code blocks.

Closes #2213.

commit7b4f077652c774d8c366c9ac2aa3e6ca7ad708f2 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 7 Jun 2015, 11:29 (11 years ago) parentcb7dd44
2 files changed+41−19
src/Text/Pandoc/Writers/DokuWiki.hs+4−4 tests/writer.dokuwiki+37−15
src/Text/Pandoc/Writers/DokuWiki.hs+4−4
@@ -172,10 +172,10 @@ blockToDokuWiki _ (CodeBlock (_,classes,_) str) = do
172172 "python", "qbasic", "rails", "reg", "robots", "ruby", "sas", "scheme", "sdlbasic",
173173 "smalltalk", "smarty", "sql", "tcl", "", "thinbasic", "tsql", "vb", "vbnet", "vhdl",
174174 "visualfoxpro", "winbatch", "xml", "xpp", "z80"]
175− let (beg, end) = if null at
176− then ("<code" ++ if null classes then ">" else " class=\"" ++ unwords classes ++ "\">", "</code>")
177− else ("<source lang=\"" ++ head at ++ "\">", "</source>")
178− return $ beg ++ str ++ end
175+ return $ "<code" ++
176+ (case at of
177+ [] -> ">\n"
178+ (x:_) -> " " ++ x ++ ">\n") ++ str ++ "\n</code>"
179179
180180blockToDokuWiki opts (BlockQuote blocks) = do
181181 contents <- blockListToDokuWiki opts blocks
tests/writer.dokuwiki+37−15
@@ -51,9 +51,11 @@ E-mail style:
5151<HTML><blockquote>
5252Code in a block quote:
5353
54−<code>sub status {
54+<code>
55+sub status {
5556 print "working";
56−}</code>
57+}
58+</code>
5759A list:
5860
5961 - item one
@@ -76,18 +78,22 @@ And a following paragraph.
7678
7779Code:
7880
79−<code>---- (should be four hyphens)
81+<code>
82+---- (should be four hyphens)
8083
8184sub status {
8285 print "working";
8386}
8487
85−this code block is indented by one tab</code>
88+this code block is indented by one tab
89+</code>
8690And:
8791
88−<code> this code block is indented by two tabs
92+<code>
93+ this code block is indented by two tabs
8994
90−These should not be escaped: \$ \\ \> \[ \{</code>
95+These should not be escaped: \$ \\ \> \[ \{
96+</code>
9197
9298----
9399
@@ -268,7 +274,9 @@ Multiple blocks with italics:
268274<HTML><p></HTML>contains seeds, crisp, pleasant to taste<HTML></p></HTML><HTML></dd></HTML>
269275<HTML><dt></HTML>//orange//<HTML></dt></HTML>
270276<HTML><dd></HTML><HTML><p></HTML>orange fruit<HTML></p></HTML>
271−<code>{ orange code block }</code>
277+<code>
278+{ orange code block }
279+</code>
272280> <HTML><p></HTML>orange block quote<HTML></p></HTML>
273281<HTML></dd></HTML><HTML></dl></HTML>
274282
@@ -330,12 +338,16 @@ foo
330338
331339This should be a code block, though:
332340
333−<code><div>
341+<code>
342+<div>
334343 foo
335−</div></code>
344+</div>
345+</code>
336346As should this:
337347
338−<code><div>foo</div></code>
348+<code>
349+<div>foo</div>
350+</code>
339351Now, nested:
340352
341353foo
@@ -360,7 +372,9 @@ Blah
360372</HTML>
361373Code block:
362374
363−<code><!-- Comment --></code>
375+<code>
376+<!-- Comment -->
377+</code>
364378Just plain comment, with trailing spaces on the line:
365379
366380<HTML>
@@ -368,7 +382,9 @@ Just plain comment, with trailing spaces on the line:
368382</HTML>
369383Code:
370384
371−<code><hr /></code>
385+<code>
386+<hr />
387+</code>
372388Hr’s:
373389
374390<HTML>
@@ -556,7 +572,9 @@ Indented [[url|thrice]].
556572
557573This should [not][] be a link.
558574
559−<code>[not]: /url</code>
575+<code>
576+[not]: /url
577+</code>
560578Foo [[url/|bar]].
561579
562580Foo [[url/|biz]].
@@ -585,7 +603,9 @@ An e-mail address: <nobody@nowhere.net>
585603
586604Auto-links should not occur here: ''%%<http://example.com/>%%''
587605
588−<code>or here: <http://example.com/></code>
606+<code>
607+or here: <http://example.com/>
608+</code>
589609
590610----
591611
@@ -607,7 +627,9 @@ Here is a footnote reference,((Here is the footnote. It can go anywhere after th
607627
608628Subsequent blocks are indented to show that they belong to the footnote (as with list items).
609629
610−<code> { <code> }</code>
630+<code>
631+ { <code> }
632+</code>
611633If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.
612634)) This should //not// be a footnote reference, because it contains a space.[^my note] Here is an inline note.((This is //easier// to type. Inline notes may contain [[http://google.com|links]] and ''%%]%%'' verbatim characters, as well as [bracketed text].
613635))