aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/DokuWiki.hs12
-rw-r--r--tests/writer.dokuwiki6
2 files changed, 14 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs
index c5f09db5a..61f548b0c 100644
--- a/src/Text/Pandoc/Writers/DokuWiki.hs
+++ b/src/Text/Pandoc/Writers/DokuWiki.hs
@@ -44,6 +44,7 @@ import Text.Pandoc.Options
import Text.Pandoc.Shared
import Text.Pandoc.Writers.Shared
import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.Walk (query)
import Data.List ( intersect, intercalate )
import Network.URI ( isURI )
import Control.Monad.State
@@ -85,6 +86,15 @@ pandocToDokuWiki opts (Pandoc meta blocks) = do
escapeString :: String -> String
escapeString str = substitute "__" "%%__%%" ( substitute "**" "%%**%%" ( substitute "//" "%%//%%" str ) )
+-- | Remove unsupported formatting from headings
+unfancy :: [Inline] -> [Inline]
+unfancy = query plainContent
+
+plainContent :: Inline -> [Inline]
+plainContent (Str x) = [Str x]
+plainContent Space = [Space]
+plainContent _ = []
+
-- | Convert Pandoc block element to DokuWiki.
blockToDokuWiki :: WriterOptions -- ^ Options
-> Block -- ^ Block element
@@ -126,7 +136,7 @@ blockToDokuWiki _ (RawBlock f str)
blockToDokuWiki _ HorizontalRule = return "\n----\n"
blockToDokuWiki opts (Header level _ inlines) = do
- contents <- inlineListToDokuWiki opts inlines
+ contents <- inlineListToDokuWiki opts ( unfancy inlines )
let eqs = replicate ( 7 - level ) '='
return $ eqs ++ " " ++ contents ++ " " ++ eqs ++ "\n"
diff --git a/tests/writer.dokuwiki b/tests/writer.dokuwiki
index eff4bed7b..ea27699cb 100644
--- a/tests/writer.dokuwiki
+++ b/tests/writer.dokuwiki
@@ -5,9 +5,9 @@ This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
====== Headers ======
-===== Level 2 with an [[url|embedded link]] =====
+===== Level 2 with an embedded link =====
-==== Level 3 with //emphasis// ====
+==== Level 3 with emphasis ====
=== Level 4 ===
@@ -15,7 +15,7 @@ This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
====== Level 1 ======
-===== Level 2 with //emphasis// =====
+===== Level 2 with emphasis =====
==== Level 3 ====