git.iko.soy/typeable/pandoc
on master help sign in
Updated DokuWiki code and tests to work with latest code from jgm.
fdbf52bClare Macrae
src/Text/Pandoc/Writers/DokuWiki.hs+22−6
@@ -31,6 +31,7 @@ DokuWiki: <https://www.dokuwiki.org/dokuwiki>
31-}
31-}
32
32
33{-
33{-
34+ [ ] Correct handling of Span
34 [ ] Don't generate <blockquote>...
35 [ ] Don't generate <blockquote>...
35 [ ] Don't generate lists using <ol> and <ul>
36 [ ] Don't generate lists using <ol> and <ul>
36 [ ] Don't generate <div>
37 [ ] Don't generate <div>
@@ -46,6 +47,7 @@ import Text.Pandoc.Definition
46import Text.Pandoc.Options
47import Text.Pandoc.Options
47import Text.Pandoc.Shared
48import Text.Pandoc.Shared
48import Text.Pandoc.Writers.Shared
49import Text.Pandoc.Writers.Shared
50+import Text.Pandoc.Pretty (render)
49import Text.Pandoc.Templates (renderTemplate')
51import Text.Pandoc.Templates (renderTemplate')
50import Data.List ( intersect, intercalate )
52import Data.List ( intersect, intercalate )
51import Network.URI ( isURI )
53import Network.URI ( isURI )
@@ -95,6 +97,11 @@ blockToDokuWiki :: WriterOptions -- ^ Options
95
97
96blockToDokuWiki _ Null = return ""
98blockToDokuWiki _ Null = return ""
97
99
100+blockToDokuWiki opts (Div attrs bs) = do
101+ contents <- blockListToDokuWiki opts bs
102+ return $ render Nothing (tagWithAttrs "div" attrs) ++ "\n" ++
103+ contents ++ "\n" ++ "</div>"
104+
98blockToDokuWiki opts (Plain inlines) =
105blockToDokuWiki opts (Plain inlines) =
99 inlineListToDokuWiki opts inlines
106 inlineListToDokuWiki opts inlines
100
107
@@ -117,9 +124,10 @@ blockToDokuWiki opts (Para inlines) = do
117 then "<p>" ++ contents ++ "</p>"
124 then "<p>" ++ contents ++ "</p>"
118 else contents ++ if null indent then "\n" else ""
125 else contents ++ if null indent then "\n" else ""
119
126
120−blockToDokuWiki _ (RawBlock "mediawiki" str) = return str
127+blockToDokuWiki _ (RawBlock f str)
128+ | f == Format "mediawiki" = return str
121−blockToDokuWiki _ (RawBlock "html" str) = return str
129+ | f == Format "html" = return str
122−blockToDokuWiki _ (RawBlock _ _) = return ""
130+ | otherwise = return ""
123
131
124blockToDokuWiki _ HorizontalRule = return "\n----\n"
132blockToDokuWiki _ HorizontalRule = return "\n----\n"
125
133
@@ -370,6 +378,13 @@ inlineListToDokuWiki opts lst = mapM (inlineToDokuWiki opts) lst >>= return . co
370-- | Convert Pandoc inline element to DokuWiki.
378-- | Convert Pandoc inline element to DokuWiki.
371inlineToDokuWiki :: WriterOptions -> Inline -> State WriterState String
379inlineToDokuWiki :: WriterOptions -> Inline -> State WriterState String
372
380
381+inlineToDokuWiki opts (Span attrs ils) = do
382+ return ""
383+ {-
384+ contents <- inlineListToDokuWiki opts ils
385+ return $ render Nothing (tagWithAttrs "span" attrs) ++ contents ++ "</span>"
386+ -}
387+
373inlineToDokuWiki opts (Emph lst) = do
388inlineToDokuWiki opts (Emph lst) = do
374 contents <- inlineListToDokuWiki opts lst
389 contents <- inlineListToDokuWiki opts lst
375 return $ "//" ++ contents ++ "//"
390 return $ "//" ++ contents ++ "//"
@@ -419,9 +434,10 @@ inlineToDokuWiki _ (Str str) = return $ escapeString str
419inlineToDokuWiki _ (Math _ str) = return $ "<math>" ++ str ++ "</math>"
434inlineToDokuWiki _ (Math _ str) = return $ "<math>" ++ str ++ "</math>"
420 -- note: str should NOT be escaped
435 -- note: str should NOT be escaped
421
436
422−inlineToDokuWiki _ (RawInline "mediawiki" str) = return str
437+inlineToDokuWiki _ (RawInline f str)
438+ | f == Format "mediawiki" = return str
423−inlineToDokuWiki _ (RawInline "html" str) = return str
439+ | f == Format "html" = return str
424−inlineToDokuWiki _ (RawInline _ _) = return ""
440+ | otherwise = return ""
425
441
426inlineToDokuWiki _ (LineBreak) = return "\\\\ "
442inlineToDokuWiki _ (LineBreak) = return "\\\\ "
427
443
tests/writer.dokuwiki+3−9
@@ -277,7 +277,6 @@ Simple block on one line:
277<div>
277<div>
278foo
278foo
279</div>
279</div>
280−
281And nested without indentation:
280And nested without indentation:
282
281
283<div>
282<div>
@@ -290,7 +289,6 @@ foo
290bar
289bar
291</div>
290</div>
292</div>
291</div>
293−
294Interpreted markdown in a table:
292Interpreted markdown in a table:
295
293
296<table>
294<table>
@@ -309,10 +307,8 @@ And this is **strong**
309Here’s a simple block:
307Here’s a simple block:
310
308
311<div>
309<div>
312−
313foo
310foo
314</div>
311</div>
315−
316This should be a code block, though:
312This should be a code block, though:
317
313
318<code><div>
314<code><div>
@@ -324,14 +320,12 @@ As should this:
324Now, nested:
320Now, nested:
325
321
326<div>
322<div>
327− <div>
323+<div>
328− <div>
324+<div>
329−
330foo
325foo
331</div>
326</div>
332− </div>
333</div>
327</div>
334−
328+</div>
335This should just be an HTML comment:
329This should just be an HTML comment:
336
330
337<!-- Comment -->
331<!-- Comment -->