aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorClare Macrae <github@cfmacrae.fastmail.co.uk>2014-07-08 22:05:04 +0100
committerClare Macrae <github@cfmacrae.fastmail.co.uk>2014-07-08 22:05:04 +0100
commitc7431283d673829741cbfdcd5d5e548077648e5b (patch)
treeeefdf4a86803cd3c78fd8db2238d8f47fc3e2f15 /src/Text/Pandoc
parent5769f178e1d5d0dcbdd9d97e968579b30c74e275 (diff)
downloadpandoc-c7431283d673829741cbfdcd5d5e548077648e5b.tar.gz
DokuWiki writer: Remove broken formatting from headings (#1398)
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Writers/DokuWiki.hs12
1 files changed, 11 insertions, 1 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"