From 2ae2fcde2f52266d8c8f36225c718ff2a2caea73 Mon Sep 17 00:00:00 2001 From: claremacrae Date: Sat, 17 Aug 2013 18:53:01 +0100 Subject: Add extra pair of test files for dokuwiki writer (#386) I've found some incorrect behaviours with the dokuwiki output, for which extra test cases will be needed - that aren't covered by the standard pandoc test input files. --- tests/dokuwiki-writer.dokuwiki | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/dokuwiki-writer.dokuwiki (limited to 'tests/dokuwiki-writer.dokuwiki') diff --git a/tests/dokuwiki-writer.dokuwiki b/tests/dokuwiki-writer.dokuwiki new file mode 100644 index 000000000..98412b904 --- /dev/null +++ b/tests/dokuwiki-writer.dokuwiki @@ -0,0 +1 @@ +hello // world -- cgit v1.2.3 From 84c2c5f01d82008be2a3248ff8e58d2b9bacc8bc Mon Sep 17 00:00:00 2001 From: claremacrae Date: Sat, 17 Aug 2013 19:03:58 +0100 Subject: Add more tests for dokuwiki writer (#386) --- tests/dokuwiki-writer.dokuwiki | 4 +++- tests/dokuwiki-writer.native | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'tests/dokuwiki-writer.dokuwiki') diff --git a/tests/dokuwiki-writer.dokuwiki b/tests/dokuwiki-writer.dokuwiki index 98412b904..d6ab65d66 100644 --- a/tests/dokuwiki-writer.dokuwiki +++ b/tests/dokuwiki-writer.dokuwiki @@ -1 +1,3 @@ -hello // world +hello // world ** from __ me + +''hello // world ** from __ me'' diff --git a/tests/dokuwiki-writer.native b/tests/dokuwiki-writer.native index 1cdad17d2..fc24451bc 100644 --- a/tests/dokuwiki-writer.native +++ b/tests/dokuwiki-writer.native @@ -1 +1,2 @@ -[Para [Str "hello",Space,Str "//",Space,Str "world"]] +[Para [Str "hello",Space,Str "//",Space,Str "world",Space,Str "**",Space,Str "from",Space,Str "__",Space,Str "me"] +,Para [Code ("",[],[]) "hello // world ** from __ me"]] -- cgit v1.2.3 From 2a4bbe5d4f433648be8b8ddb6079e5e09153d722 Mon Sep 17 00:00:00 2001 From: claremacrae Date: Sat, 17 Aug 2013 22:28:07 +0100 Subject: Nasty hack to stop C comments in inline code becoming italics in dokuwiki writer (#386) --- src/Text/Pandoc/Writers/DokuWiki.hs | 7 ++++++- tests/dokuwiki-writer.dokuwiki | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'tests/dokuwiki-writer.dokuwiki') 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'' -- cgit v1.2.3 From 6d484bc55e2bc8d318b0727bcd88e4ceea795329 Mon Sep 17 00:00:00 2001 From: claremacrae Date: Sun, 18 Aug 2013 08:13:34 +0100 Subject: Treat inline code blocks like instead of in dokuwiki writer (#386) Done because I noticed that in the Autolinks section of writer.dokuwiki, the URL in inlined code was getting auto-linked, when it wasn't supposed to. This also meant that any inline code examples that had text that looked like dokuwiki syntax could break the formatting of later text. --- src/Text/Pandoc/Writers/DokuWiki.hs | 11 ++++++++++- tests/dokuwiki-writer.dokuwiki | 2 +- tests/writer.dokuwiki | 12 ++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) (limited to 'tests/dokuwiki-writer.dokuwiki') diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs index 9ac35ebd6..a38a54953 100644 --- a/src/Text/Pandoc/Writers/DokuWiki.hs +++ b/src/Text/Pandoc/Writers/DokuWiki.hs @@ -412,7 +412,16 @@ inlineToDokuWiki opts (Quoted DoubleQuote lst) = do inlineToDokuWiki opts (Cite _ lst) = inlineListToDokuWiki opts lst inlineToDokuWiki _ (Code _ str) = - return $ "''" ++ ( escapeString str ) ++ "''" + -- In dokuwiki, text surrounded by '' is really just a font statement, i.e. , + -- and so other formatting can be present inside. + -- However, in pandoc, and markdown, inlined code doesn't contain formatting. + -- So I have opted for using %% to disable all formatting inside inline code blocks. + -- This gives the best results when converting from other formats to dokuwiki, even if + -- the resultand code is a little ugly, for short strings that don't contain formatting + -- characters. + -- It does mean that if pandoc could ever read dokuwiki, and so round-trip the format, + -- any formatting inside inlined code blocks would be lost, or presented incorrectly. + return $ "''%%" ++ str ++ "%%''" inlineToDokuWiki _ (Str str) = return $ str diff --git a/tests/dokuwiki-writer.dokuwiki b/tests/dokuwiki-writer.dokuwiki index dbffb7a0e..44f06f777 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%%'' diff --git a/tests/writer.dokuwiki b/tests/writer.dokuwiki index 8aeb52bd6..9855f30dd 100644 --- a/tests/writer.dokuwiki +++ b/tests/writer.dokuwiki @@ -433,7 +433,7 @@ So is **//this//** word. So is **//this//** word. -This is code: ''>'', ''$'', ''\'', ''\$'', ''''. +This is code: ''%%>%%'', ''%%$%%'', ''%%\%%'', ''%%\$%%'', ''%%%%''. This is //strikeout//. @@ -456,7 +456,7 @@ These should not be superscripts or subscripts, because of the unescaped spaces: ‘He said, “I want to go.”’ Were you alive in the 70’s? -Here is some quoted ‘''code''’ and a “[[http://example.com/?foo=1&bar=2|quoted link]]”. +Here is some quoted ‘''%%code%%''’ and a “[[http://example.com/?foo=1&bar=2|quoted link]]”. Some dashes: one—two — three—four — five. @@ -480,10 +480,10 @@ Ellipses…and…and…. These shouldn’t be math: - * To get the famous equation, write ''$e = mc^2$''. + * To get the famous equation, write ''%%$e = mc^2$%%''. * $22,000 is a //lot// of money. So is $34,000. (It worked if “lot” is emphasized.) * Shoes ($20) and socks ($5). - * Escaped ''$'': $73 //this should be emphasized// 23$. + * Escaped ''%%$%%'': $73 //this should be emphasized// 23$. Here’s a LaTeX table: @@ -615,7 +615,7 @@ An e-mail address: [[mailto:nobody@nowhere.net|nobody@nowhere.net]]
Blockquoted: http://example.com/
-Auto-links should not occur here: '''' +Auto-links should not occur here: ''%%%%'' or here: @@ -641,7 +641,7 @@ Subsequent blocks are indented to show that they belong to the footnote (as with { } If you want, you can indent every line, but you can also be lazy and just indent the first line of each block. -)) This should //not// be a footnote reference, because it contains a space.[^my note] Here is an inline note.((This is //easier// to type. Inline notes may contain [[http://google.com|links]] and '']'' verbatim characters, as well as [bracketed text]. +)) This should //not// be a footnote reference, because it contains a space.[^my note] Here is an inline note.((This is //easier// to type. Inline notes may contain [[http://google.com|links]] and ''%%]%%'' verbatim characters, as well as [bracketed text]. ))
Notes can go in quotes.((In quote. -- cgit v1.2.3 From b5b622f5b821ed5624b0ce2f29d1bddd0100bd04 Mon Sep 17 00:00:00 2001 From: claremacrae Date: Sun, 18 Aug 2013 08:57:32 +0100 Subject: Stop plain text // becoming an italic marker in dokuwiki writer (#386) When the original document had text containing //, this was previously included, unchanged, in the dokuwiki output, and this interacted badly with later, intended, formating text. --- src/Text/Pandoc/Writers/DokuWiki.hs | 5 ++--- tests/dokuwiki-writer.dokuwiki | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'tests/dokuwiki-writer.dokuwiki') diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs index a38a54953..4e7e79441 100644 --- a/src/Text/Pandoc/Writers/DokuWiki.hs +++ b/src/Text/Pandoc/Writers/DokuWiki.hs @@ -87,8 +87,7 @@ pandocToDokuWiki opts (Pandoc meta blocks) = do -- | 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 +escapeString str = substitute "//" "%%//%%" str -- | Convert Pandoc block element to DokuWiki. blockToDokuWiki :: WriterOptions -- ^ Options @@ -423,7 +422,7 @@ inlineToDokuWiki _ (Code _ str) = -- any formatting inside inlined code blocks would be lost, or presented incorrectly. return $ "''%%" ++ str ++ "%%''" -inlineToDokuWiki _ (Str str) = return $ str +inlineToDokuWiki _ (Str str) = return $ escapeString str inlineToDokuWiki _ (Math _ str) = return $ "" ++ str ++ "" -- note: str should NOT be escaped diff --git a/tests/dokuwiki-writer.dokuwiki b/tests/dokuwiki-writer.dokuwiki index 44f06f777..2e5d2fc1c 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%%'' -- cgit v1.2.3 From 288329044a63331658079aa9db57b46fe204b6b9 Mon Sep 17 00:00:00 2001 From: claremacrae Date: Sun, 18 Aug 2013 09:15:33 +0100 Subject: 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(-) (limited to 'tests/dokuwiki-writer.dokuwiki') 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%%'' -- cgit v1.2.3