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)
commit2a4bbe5d4f433648be8b8ddb6079e5e09153d722 authorclaremacrae <github@cfmacrae.fastmail.co.uk> dateSat 17 Aug 2013, 22:28 (13 years ago) parent84c2c5f
2 files changed+7−2
src/Text/Pandoc/Writers/DokuWiki.hs+6−1 tests/dokuwiki-writer.dokuwiki+1−1
src/Text/Pandoc/Writers/DokuWiki.hs+6−1
@@ -85,6 +85,11 @@ pandocToDokuWiki opts (Pandoc meta blocks) = do
8585 then return $ renderTemplate' (writerTemplate opts) context
8686 else return main
8787
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+
8893-- | Convert Pandoc block element to DokuWiki.
8994blockToDokuWiki :: WriterOptions -- ^ Options
9095 -> Block -- ^ Block element
@@ -407,7 +412,7 @@ inlineToDokuWiki opts (Quoted DoubleQuote lst) = do
407412inlineToDokuWiki opts (Cite _ lst) = inlineListToDokuWiki opts lst
408413
409414inlineToDokuWiki _ (Code _ str) =
410− return $ "''" ++ str++ "''"
415+ return $ "''" ++ ( escapeString str ) ++ "''"
411416
412417inlineToDokuWiki _ (Str str) = return $ str
413418
tests/dokuwiki-writer.dokuwiki+1−1
@@ -1,3 +1,3 @@
11hello // world ** from __ me
22
3−''hello // world ** from __ me''
3+''hello %%//%% world ** from __ me''