aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-06-07 11:29:47 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-06-07 11:29:47 -0700
commit7b4f077652c774d8c366c9ac2aa3e6ca7ad708f2 (patch)
tree6e45b727f1a7c17af8c74fabf04969337618942a
parentcb7dd4469d420aea1a296079b7002aa5452fb481 (diff)
downloadpandoc-7b4f077652c774d8c366c9ac2aa3e6ca7ad708f2.tar.gz
DokuWiki writer: Use proper `<code>` tags for code blocks.
Closes #2213.
-rw-r--r--src/Text/Pandoc/Writers/DokuWiki.hs8
-rw-r--r--tests/writer.dokuwiki52
2 files changed, 41 insertions, 19 deletions
diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs
index 94f3a02cc..7164c6e86 100644
--- a/src/Text/Pandoc/Writers/DokuWiki.hs
+++ b/src/Text/Pandoc/Writers/DokuWiki.hs
@@ -172,10 +172,10 @@ blockToDokuWiki _ (CodeBlock (_,classes,_) str) = do
"python", "qbasic", "rails", "reg", "robots", "ruby", "sas", "scheme", "sdlbasic",
"smalltalk", "smarty", "sql", "tcl", "", "thinbasic", "tsql", "vb", "vbnet", "vhdl",
"visualfoxpro", "winbatch", "xml", "xpp", "z80"]
- let (beg, end) = if null at
- then ("<code" ++ if null classes then ">" else " class=\"" ++ unwords classes ++ "\">", "</code>")
- else ("<source lang=\"" ++ head at ++ "\">", "</source>")
- return $ beg ++ str ++ end
+ return $ "<code" ++
+ (case at of
+ [] -> ">\n"
+ (x:_) -> " " ++ x ++ ">\n") ++ str ++ "\n</code>"
blockToDokuWiki opts (BlockQuote blocks) = do
contents <- blockListToDokuWiki opts blocks
diff --git a/tests/writer.dokuwiki b/tests/writer.dokuwiki
index 2c3c9b1b5..e984d391e 100644
--- a/tests/writer.dokuwiki
+++ b/tests/writer.dokuwiki
@@ -51,9 +51,11 @@ E-mail style:
<HTML><blockquote>
Code in a block quote:
-<code>sub status {
+<code>
+sub status {
print "working";
-}</code>
+}
+</code>
A list:
- item one
@@ -76,18 +78,22 @@ And a following paragraph.
Code:
-<code>---- (should be four hyphens)
+<code>
+---- (should be four hyphens)
sub status {
print "working";
}
-this code block is indented by one tab</code>
+this code block is indented by one tab
+</code>
And:
-<code> this code block is indented by two tabs
+<code>
+ this code block is indented by two tabs
-These should not be escaped: \$ \\ \> \[ \{</code>
+These should not be escaped: \$ \\ \> \[ \{
+</code>
----
@@ -268,7 +274,9 @@ Multiple blocks with italics:
<HTML><p></HTML>contains seeds, crisp, pleasant to taste<HTML></p></HTML><HTML></dd></HTML>
<HTML><dt></HTML>//orange//<HTML></dt></HTML>
<HTML><dd></HTML><HTML><p></HTML>orange fruit<HTML></p></HTML>
-<code>{ orange code block }</code>
+<code>
+{ orange code block }
+</code>
> <HTML><p></HTML>orange block quote<HTML></p></HTML>
<HTML></dd></HTML><HTML></dl></HTML>
@@ -330,12 +338,16 @@ foo
This should be a code block, though:
-<code><div>
+<code>
+<div>
foo
-</div></code>
+</div>
+</code>
As should this:
-<code><div>foo</div></code>
+<code>
+<div>foo</div>
+</code>
Now, nested:
foo
@@ -360,7 +372,9 @@ Blah
</HTML>
Code block:
-<code><!-- Comment --></code>
+<code>
+<!-- Comment -->
+</code>
Just plain comment, with trailing spaces on the line:
<HTML>
@@ -368,7 +382,9 @@ Just plain comment, with trailing spaces on the line:
</HTML>
Code:
-<code><hr /></code>
+<code>
+<hr />
+</code>
Hr’s:
<HTML>
@@ -556,7 +572,9 @@ Indented [[url|thrice]].
This should [not][] be a link.
-<code>[not]: /url</code>
+<code>
+[not]: /url
+</code>
Foo [[url/|bar]].
Foo [[url/|biz]].
@@ -585,7 +603,9 @@ An e-mail address: <nobody@nowhere.net>
Auto-links should not occur here: ''%%<http://example.com/>%%''
-<code>or here: <http://example.com/></code>
+<code>
+or here: <http://example.com/>
+</code>
----
@@ -607,7 +627,9 @@ Here is a footnote reference,((Here is the footnote. It can go anywhere after th
Subsequent blocks are indented to show that they belong to the footnote (as with list items).
-<code> { <code> }</code>
+<code>
+ { <code> }
+</code>
If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.
)) 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].
))