From 288329044a63331658079aa9db57b46fe204b6b9 Mon Sep 17 00:00:00 2001
From: claremacrae <github@cfmacrae.fastmail.co.uk>
Date: Sun, 18 Aug 2013 09:15:33 +0100
Subject: [PATCH] Stop plain text ** and __ becoming formatting in dokuwiki
 writer (#386)

---
 src/Text/Pandoc/Writers/DokuWiki.hs | 2 +-
 tests/dokuwiki-writer.dokuwiki      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs
index 4e7e79441..ec22a5a82 100644
--- a/src/Text/Pandoc/Writers/DokuWiki.hs
+++ b/src/Text/Pandoc/Writers/DokuWiki.hs
@@ -87,7 +87,7 @@ pandocToDokuWiki opts (Pandoc meta blocks) = do
 
 -- | Escape special characters for MediaWiki.
 escapeString :: String -> String
-escapeString str = substitute "//" "%%//%%" str
+escapeString str = substitute "__" "%%__%%" ( substitute "**" "%%**%%" ( substitute "//" "%%//%%" str ) )
 
 -- | Convert Pandoc block element to DokuWiki.
 blockToDokuWiki :: WriterOptions -- ^ Options
diff --git a/tests/dokuwiki-writer.dokuwiki b/tests/dokuwiki-writer.dokuwiki
index 2e5d2fc1c..6ddacc480 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%%''