diff options
-rw-r--r-- | src/Text/Pandoc/Writers/DokuWiki.hs | 31 | ||||
-rw-r--r-- | tests/writer.dokuwiki | 46 |
2 files changed, 48 insertions, 29 deletions
diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs index 0651a8177..4b72d0f14 100644 --- a/src/Text/Pandoc/Writers/DokuWiki.hs +++ b/src/Text/Pandoc/Writers/DokuWiki.hs @@ -167,7 +167,7 @@ blockToDokuWiki opts x@(BulletList items) = do modify $ \s -> s { stUseTags = oldUseTags } return $ "<ul>\n" ++ vcat contents ++ "</ul>\n" else do - modify $ \s -> s { stListLevel = stListLevel s ++ "*" } + modify $ \s -> s { stListLevel = stListLevel s ++ " " } contents <- mapM (listItemToDokuWiki opts) items modify $ \s -> s { stListLevel = init (stListLevel s) } return $ vcat contents ++ if null listLevel then "\n" else "" @@ -179,15 +179,18 @@ blockToDokuWiki opts x@(OrderedList attribs items) = do if useTags then do modify $ \s -> s { stUseTags = True } - contents <- mapM (listItemToDokuWiki opts) items + contents <- mapM (orderedListItemToDokuWiki opts) items modify $ \s -> s { stUseTags = oldUseTags } return $ "<ol" ++ listAttribsToString attribs ++ ">\n" ++ vcat contents ++ "</ol>\n" else do - modify $ \s -> s { stListLevel = stListLevel s ++ "#" } - contents <- mapM (listItemToDokuWiki opts) items + modify $ \s -> s { stListLevel = stListLevel s ++ " " } + contents <- mapM (orderedListItemToDokuWiki opts) items modify $ \s -> s { stListLevel = init (stListLevel s) } return $ vcat contents ++ if null listLevel then "\n" else "" +-- TODO Need to decide how to make definition lists work on dokuwiki - I don't think there +-- is a specific representation of them. +-- TODO This creates double '; ; ' if there is a bullet or ordered list inside a definition list blockToDokuWiki opts x@(DefinitionList items) = do oldUseTags <- get >>= return . stUseTags listLevel <- get >>= return . stListLevel @@ -217,7 +220,7 @@ listAttribsToString (startnum, numstyle, _) = then " style=\"list-style-type: " ++ numstyle' ++ ";\"" else "") --- | Convert bullet or ordered list item (list of blocks) to DokuWiki. +-- | Convert bullet list item (list of blocks) to DokuWiki. listItemToDokuWiki :: WriterOptions -> [Block] -> State WriterState String listItemToDokuWiki opts items = do contents <- blockListToDokuWiki opts items @@ -226,7 +229,23 @@ listItemToDokuWiki opts items = do then return $ "<li>" ++ contents ++ "</li>" else do marker <- get >>= return . stListLevel - return $ marker ++ " " ++ contents + -- This marker ++ marker is an awful hack to write 2 spaces per indentation level. + -- I couldn't find a cleaner way of doing it. + return $ marker ++ marker ++ "* " ++ contents + +-- | Convert ordered list item (list of blocks) to DokuWiki. +-- | TODO Emiminate dreadful duplication of text from listItemToDokuWiki +orderedListItemToDokuWiki :: WriterOptions -> [Block] -> State WriterState String +orderedListItemToDokuWiki opts items = do + contents <- blockListToDokuWiki opts items + useTags <- get >>= return . stUseTags + if useTags + then return $ "<li>" ++ contents ++ "</li>" + else do + marker <- get >>= return . stListLevel + -- This marker ++ marker is an awful hack to write 2 spaces per indentation level. + -- I couldn't find a cleaner way of doing it. + return $ marker ++ marker ++ "- " ++ contents -- | Convert definition list item (label, list of blocks) to DokuWiki. definitionListItemToDokuWiki :: WriterOptions diff --git a/tests/writer.dokuwiki b/tests/writer.dokuwiki index 73afec027..7ffd254ef 100644 --- a/tests/writer.dokuwiki +++ b/tests/writer.dokuwiki @@ -303,8 +303,8 @@ Blank line after term, indented marker, alternate markers: : computer ; orange : orange fruit -;# sublist -;# sublist +; ; - sublist +; ; - sublist ====== HTML Blocks ====== @@ -468,21 +468,21 @@ Ellipses…and…and…. ====== LaTeX ====== -* -* <math>2+2=4</math> -* <math>x \in y</math> -* <math>\alpha \wedge \omega</math> -* <math>223</math> -* <math>p</math>-Tree -* Here’s some display math: <math>\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</math> -* Here’s one that has a line break in it: <math>\alpha + \omega \times x^2</math>. + * + * <math>2+2=4</math> + * <math>x \in y</math> + * <math>\alpha \wedge \omega</math> + * <math>223</math> + * <math>p</math>-Tree + * Here’s some display math: <math>\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</math> + * Here’s one that has a line break in it: <math>\alpha + \omega \times x^2</math>. These shouldn’t be math: -* To get the famous equation, write <code>$e = mc^2$</code>. -* $22,000 is a //lot// of money. So is $34,000. (It worked if “lot” is emphasized.) -* Shoes ($20) and socks ($5). -* Escaped <code>$</code>: $73 //this should be emphasized// 23$. + * To get the famous equation, write <code>$e = mc^2$</code>. + * $22,000 is a //lot// of money. So is $34,000. (It worked if “lot” is emphasized.) + * Shoes ($20) and socks ($5). + * Escaped <code>$</code>: $73 //this should be emphasized// 23$. Here’s a LaTeX table: @@ -494,11 +494,11 @@ Here’s a LaTeX table: Here is some unicode: -* I hat: Î -* o umlaut: ö -* section: § -* set membership: ∈ -* copyright: © + * I hat: Î + * o umlaut: ö + * section: § + * set membership: ∈ + * copyright: © AT&T has an ampersand in their name. @@ -606,9 +606,9 @@ Here’s an [[script?foo=1&bar=2|inline link in pointy braces]]. With an ampersand: http://example.com/?foo=1&bar=2 -* In a list? -* http://example.com/ -* It should. + * In a list? + * http://example.com/ + * It should. An e-mail address: [[mailto:nobody@nowhere.net|nobody@nowhere.net]] @@ -646,7 +646,7 @@ If you want, you can indent every line, but you can also be lazy and just indent <blockquote>Notes can go in quotes.<ref>In quote. </ref> </blockquote> -# And in list items.<ref>In list.</ref> + - And in list items.<ref>In list.</ref> This paragraph should not be part of the note, as it is not indented. |