git.iko.soy/typeable/pandoc
on master help sign in
Nasty hack to stop C comments in inline code becoming italics in dokuwiki writer (#386)
2a4bbe5claremacrae
src/Text/Pandoc/Writers/DokuWiki.hs+6−1
@@ -85,6 +85,11 @@ pandocToDokuWiki opts (Pandoc meta blocks) = do
85 then return $ renderTemplate' (writerTemplate opts) context
85 then return $ renderTemplate' (writerTemplate opts) context
86 else return main
86 else return main
87
87
88+-- | Escape special characters for MediaWiki.
89+escapeString :: String -> String
90+-- The spaces around // are to prevent touching in URLs inside inline code blocks
91+escapeString str = substitute " // " " %%//%% " str
92+
88-- | Convert Pandoc block element to DokuWiki.
93-- | Convert Pandoc block element to DokuWiki.
89blockToDokuWiki :: WriterOptions -- ^ Options
94blockToDokuWiki :: WriterOptions -- ^ Options
90 -> Block -- ^ Block element
95 -> Block -- ^ Block element
@@ -407,7 +412,7 @@ inlineToDokuWiki opts (Quoted DoubleQuote lst) = do
407inlineToDokuWiki opts (Cite _ lst) = inlineListToDokuWiki opts lst
412inlineToDokuWiki opts (Cite _ lst) = inlineListToDokuWiki opts lst
408
413
409inlineToDokuWiki _ (Code _ str) =
414inlineToDokuWiki _ (Code _ str) =
410− return $ "''" ++ str++ "''"
415+ return $ "''" ++ ( escapeString str ) ++ "''"
411
416
412inlineToDokuWiki _ (Str str) = return $ str
417inlineToDokuWiki _ (Str str) = return $ str
413
418
tests/dokuwiki-writer.dokuwiki+1−1
@@ -1,3 +1,3 @@
1hello // world ** from __ me
1hello // world ** from __ me
2
2
3−''hello // world ** from __ me''
3+''hello %%//%% world ** from __ me''