diff options
| author | claremacrae <github@cfmacrae.fastmail.co.uk> | 2013-08-17 22:28:07 +0100 |
|---|---|---|
| committer | claremacrae <github@cfmacrae.fastmail.co.uk> | 2013-08-17 22:28:07 +0100 |
| commit | 2a4bbe5d4f433648be8b8ddb6079e5e09153d722 (patch) | |
| tree | 8739c292b3ffa118447e7243bfab1804d8910ee5 | |
| parent | 84c2c5f01d82008be2a3248ff8e58d2b9bacc8bc (diff) | |
| download | pandoc-2a4bbe5d4f433648be8b8ddb6079e5e09153d722.tar.gz | |
Nasty hack to stop C comments in inline code becoming italics in dokuwiki writer (#386)
| -rw-r--r-- | src/Text/Pandoc/Writers/DokuWiki.hs | 7 | ||||
| -rw-r--r-- | tests/dokuwiki-writer.dokuwiki | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs index 3f4efb1b3..9ac35ebd6 100644 --- a/src/Text/Pandoc/Writers/DokuWiki.hs +++ b/src/Text/Pandoc/Writers/DokuWiki.hs @@ -85,6 +85,11 @@ pandocToDokuWiki opts (Pandoc meta blocks) = do then return $ renderTemplate' (writerTemplate opts) context else return main +-- | Escape special characters for MediaWiki. +escapeString :: String -> String +-- The spaces around // are to prevent touching in URLs inside inline code blocks +escapeString str = substitute " // " " %%//%% " str + -- | Convert Pandoc block element to DokuWiki. blockToDokuWiki :: WriterOptions -- ^ Options -> Block -- ^ Block element @@ -407,7 +412,7 @@ inlineToDokuWiki opts (Quoted DoubleQuote lst) = do inlineToDokuWiki opts (Cite _ lst) = inlineListToDokuWiki opts lst inlineToDokuWiki _ (Code _ str) = - return $ "''" ++ str++ "''" + return $ "''" ++ ( escapeString str ) ++ "''" inlineToDokuWiki _ (Str str) = return $ str diff --git a/tests/dokuwiki-writer.dokuwiki b/tests/dokuwiki-writer.dokuwiki index d6ab65d66..dbffb7a0e 100644 --- a/tests/dokuwiki-writer.dokuwiki +++ b/tests/dokuwiki-writer.dokuwiki @@ -1,3 +1,3 @@ hello // world ** from __ me -''hello // world ** from __ me'' +''hello %%//%% world ** from __ me'' |
