aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClare Macrae <github@cfmacrae.fastmail.co.uk>2014-06-29 21:15:17 +0100
committerClare Macrae <github@cfmacrae.fastmail.co.uk>2014-06-29 21:15:17 +0100
commitfdbf52b1cca7d923924ef5d970d946ba6369d6c5 (patch)
tree212032e0b6e5bd5795f1f2b3fe35bd4fd6f0e285
parent717e16660d1ee83f690b35d0aa9b60c8ac9d6b61 (diff)
downloadpandoc-fdbf52b1cca7d923924ef5d970d946ba6369d6c5.tar.gz
Updated DokuWiki code and tests to work with latest code from jgm.
The new code was got from inspecting changes in MediaWiki.hs This slightly changes the output of Div blocks, but I'm not convinced the original behaviour was really correct anyway. The code for handling Span does nothing for now, until I can work out the desired behaviour, and add tests for it.
-rw-r--r--src/Text/Pandoc/Writers/DokuWiki.hs28
-rw-r--r--tests/writer.dokuwiki12
2 files changed, 25 insertions, 15 deletions
diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs
index 41e4d7a8f..59c883b55 100644
--- a/src/Text/Pandoc/Writers/DokuWiki.hs
+++ b/src/Text/Pandoc/Writers/DokuWiki.hs
@@ -31,6 +31,7 @@ DokuWiki: <https://www.dokuwiki.org/dokuwiki>
-}
{-
+ [ ] Correct handling of Span
[ ] Don't generate <blockquote>...
[ ] Don't generate lists using <ol> and <ul>
[ ] Don't generate <div>
@@ -46,6 +47,7 @@ import Text.Pandoc.Definition
import Text.Pandoc.Options
import Text.Pandoc.Shared
import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Pretty (render)
import Text.Pandoc.Templates (renderTemplate')
import Data.List ( intersect, intercalate )
import Network.URI ( isURI )
@@ -95,6 +97,11 @@ blockToDokuWiki :: WriterOptions -- ^ Options
blockToDokuWiki _ Null = return ""
+blockToDokuWiki opts (Div attrs bs) = do
+ contents <- blockListToDokuWiki opts bs
+ return $ render Nothing (tagWithAttrs "div" attrs) ++ "\n" ++
+ contents ++ "\n" ++ "</div>"
+
blockToDokuWiki opts (Plain inlines) =
inlineListToDokuWiki opts inlines
@@ -117,9 +124,10 @@ blockToDokuWiki opts (Para inlines) = do
then "<p>" ++ contents ++ "</p>"
else contents ++ if null indent then "\n" else ""
-blockToDokuWiki _ (RawBlock "mediawiki" str) = return str
-blockToDokuWiki _ (RawBlock "html" str) = return str
-blockToDokuWiki _ (RawBlock _ _) = return ""
+blockToDokuWiki _ (RawBlock f str)
+ | f == Format "mediawiki" = return str
+ | f == Format "html" = return str
+ | otherwise = return ""
blockToDokuWiki _ HorizontalRule = return "\n----\n"
@@ -370,6 +378,13 @@ inlineListToDokuWiki opts lst = mapM (inlineToDokuWiki opts) lst >>= return . co
-- | Convert Pandoc inline element to DokuWiki.
inlineToDokuWiki :: WriterOptions -> Inline -> State WriterState String
+inlineToDokuWiki opts (Span attrs ils) = do
+ return ""
+ {-
+ contents <- inlineListToDokuWiki opts ils
+ return $ render Nothing (tagWithAttrs "span" attrs) ++ contents ++ "</span>"
+ -}
+
inlineToDokuWiki opts (Emph lst) = do
contents <- inlineListToDokuWiki opts lst
return $ "//" ++ contents ++ "//"
@@ -419,9 +434,10 @@ inlineToDokuWiki _ (Str str) = return $ escapeString str
inlineToDokuWiki _ (Math _ str) = return $ "<math>" ++ str ++ "</math>"
-- note: str should NOT be escaped
-inlineToDokuWiki _ (RawInline "mediawiki" str) = return str
-inlineToDokuWiki _ (RawInline "html" str) = return str
-inlineToDokuWiki _ (RawInline _ _) = return ""
+inlineToDokuWiki _ (RawInline f str)
+ | f == Format "mediawiki" = return str
+ | f == Format "html" = return str
+ | otherwise = return ""
inlineToDokuWiki _ (LineBreak) = return "\\\\ "
diff --git a/tests/writer.dokuwiki b/tests/writer.dokuwiki
index 132c2d614..b60e57f07 100644
--- a/tests/writer.dokuwiki
+++ b/tests/writer.dokuwiki
@@ -277,7 +277,6 @@ Simple block on one line:
<div>
foo
</div>
-
And nested without indentation:
<div>
@@ -290,7 +289,6 @@ foo
bar
</div>
</div>
-
Interpreted markdown in a table:
<table>
@@ -309,10 +307,8 @@ And this is **strong**
Here’s a simple block:
<div>
-
foo
</div>
-
This should be a code block, though:
<code><div>
@@ -324,14 +320,12 @@ As should this:
Now, nested:
<div>
- <div>
- <div>
-
+<div>
+<div>
foo
</div>
- </div>
</div>
-
+</div>
This should just be an HTML comment:
<!-- Comment -->