diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-10-29 22:33:11 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-10-29 22:33:11 -0700 |
commit | 4fe28e947a38bffdbb4eeccb16e62dc1824b9c74 (patch) | |
tree | 31ea4c059826be29e102a23c694ff575034b086d | |
parent | c51be5dfc85024e68a4bd62c9ced748b27f968c0 (diff) | |
download | pandoc-4fe28e947a38bffdbb4eeccb16e62dc1824b9c74.tar.gz |
ZimWiki writer: remove extra indentation on lists.
Closes #4963.
-rw-r--r-- | src/Text/Pandoc/Writers/ZimWiki.hs | 16 | ||||
-rw-r--r-- | test/writer.zimwiki | 176 |
2 files changed, 96 insertions, 96 deletions
diff --git a/src/Text/Pandoc/Writers/ZimWiki.hs b/src/Text/Pandoc/Writers/ZimWiki.hs index a583b07b1..40efaa8cf 100644 --- a/src/Text/Pandoc/Writers/ZimWiki.hs +++ b/src/Text/Pandoc/Writers/ZimWiki.hs @@ -183,17 +183,13 @@ blockToZimWiki opts (Table capt aligns _ headers rows) = do unlines (map renderRow rows') blockToZimWiki opts (BulletList items) = do - indent <- gets stIndent - modify $ \s -> s { stIndent = stIndent s ++ "\t" } contents <- mapM (listItemToZimWiki opts) items - modify $ \s -> s{ stIndent = indent } -- drop 1 (stIndent s) } + indent <- gets stIndent return $ vcat contents ++ if null indent then "\n" else "" blockToZimWiki opts (OrderedList _ items) = do - indent <- gets stIndent - modify $ \s -> s { stIndent = stIndent s ++ "\t", stItemNum = 1 } contents <- mapM (orderedListItemToZimWiki opts) items - modify $ \s -> s{ stIndent = indent } -- drop 1 (stIndent s) } + indent <- gets stIndent return $ vcat contents ++ if null indent then "\n" else "" blockToZimWiki opts (DefinitionList items) = do @@ -246,16 +242,20 @@ vcat = intercalate "\n" -- | Convert bullet list item (list of blocks) to ZimWiki. listItemToZimWiki :: PandocMonad m => WriterOptions -> [Block] -> ZW m String listItemToZimWiki opts items = do - contents <- blockListToZimWiki opts items indent <- gets stIndent + modify $ \s -> s { stIndent = indent ++ "\t" } + contents <- blockListToZimWiki opts items + modify $ \s -> s{ stIndent = indent } return $ indent ++ "* " ++ contents -- | Convert ordered list item (list of blocks) to ZimWiki. orderedListItemToZimWiki :: PandocMonad m => WriterOptions -> [Block] -> ZW m String orderedListItemToZimWiki opts items = do - contents <- blockListToZimWiki opts items indent <- gets stIndent + modify $ \s -> s { stIndent = indent ++ "\t" } + contents <- blockListToZimWiki opts items + modify $ \s -> s{ stIndent = indent } itemnum <- gets stItemNum --modify $ \s -> s { stItemNum = itemnum + 1 } -- this is not strictly necessary for zim as zim does its own renumbering return $ indent ++ show itemnum ++ ". " ++ contents diff --git a/test/writer.zimwiki b/test/writer.zimwiki index 91f018b52..6e59ae8a2 100644 --- a/test/writer.zimwiki +++ b/test/writer.zimwiki @@ -61,8 +61,8 @@ E-mail style: > > A list: > -> 1. item one -> 1. item two +> 1. item one +> 1. item two > > Nested block quotes: > @@ -108,126 +108,126 @@ These should not be escaped: \$ \\ \> \[ \{ Asterisks tight: - * asterisk 1 - * asterisk 2 - * asterisk 3 +* asterisk 1 +* asterisk 2 +* asterisk 3 Asterisks loose: - * asterisk 1 - * asterisk 2 - * asterisk 3 +* asterisk 1 +* asterisk 2 +* asterisk 3 Pluses tight: - * Plus 1 - * Plus 2 - * Plus 3 +* Plus 1 +* Plus 2 +* Plus 3 Pluses loose: - * Plus 1 - * Plus 2 - * Plus 3 +* Plus 1 +* Plus 2 +* Plus 3 Minuses tight: - * Minus 1 - * Minus 2 - * Minus 3 +* Minus 1 +* Minus 2 +* Minus 3 Minuses loose: - * Minus 1 - * Minus 2 - * Minus 3 +* Minus 1 +* Minus 2 +* Minus 3 ===== Ordered ===== Tight: - 1. First - 1. Second - 1. Third +1. First +1. Second +1. Third and: - 1. One - 1. Two - 1. Three +1. One +1. Two +1. Three Loose using tabs: - 1. First - 1. Second - 1. Third +1. First +1. Second +1. Third and using spaces: - 1. One - 1. Two - 1. Three +1. One +1. Two +1. Three Multiple paragraphs: - 1. Item 1, graf one. +1. Item 1, graf one. Item 1. graf two. The quick brown fox jumped over the lazy dog’s back. - 1. Item 2. - 1. Item 3. +1. Item 2. +1. Item 3. ===== Nested ===== +* Tab * Tab * Tab - * Tab Here’s another: - 1. First - 1. Second: - * Fee - * Fie - * Foe - 1. Third +1. First +1. Second: + * Fee + * Fie + * Foe +1. Third Same thing but with paragraphs: - 1. First - 1. Second: - * Fee - * Fie - * Foe - 1. Third +1. First +1. Second: + * Fee + * Fie + * Foe +1. Third ===== Tabs and spaces ===== - * this is a list item indented with tabs - * this is a list item indented with spaces - * this is an example list item indented with tabs - * this is an example list item indented with spaces +* this is a list item indented with tabs +* this is a list item indented with spaces + * this is an example list item indented with tabs + * this is an example list item indented with spaces ===== Fancy list markers ===== - 1. begins with 2 - 1. and now 3 +1. begins with 2 +1. and now 3 with a continuation - 1. sublist with roman numerals, starting with 4 - 1. more items - 1. a subsublist - 1. a subsublist + 1. sublist with roman numerals, starting with 4 + 1. more items + 1. a subsublist + 1. a subsublist Nesting: - 1. Upper Alpha - 1. Upper Roman. - 1. Decimal start with 6 - 1. Lower alpha with paren +1. Upper Alpha + 1. Upper Roman. + 1. Decimal start with 6 + 1. Lower alpha with paren Autonumbering: - 1. Autonumber. - 1. More. - 1. Nested. +1. Autonumber. +1. More. + 1. Nested. Should not be a list item: @@ -291,8 +291,8 @@ computer * **orange** orange fruit - 1. sublist - 1. sublist +1. sublist +1. sublist ====== HTML Blocks ====== @@ -435,21 +435,21 @@ Ellipses…and…and…. ====== LaTeX ====== - * - * $2+2=4$ - * $x \in y$ - * $\alpha \wedge \omega$ - * $223$ - * $p$-Tree - * Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$ - * Here’s one that has a line break in it: $\alpha + \omega \times x^2$. +* +* $2+2=4$ +* $x \in y$ +* $\alpha \wedge \omega$ +* $223$ +* $p$-Tree +* Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$ +* Here’s one that has a line break in it: $\alpha + \omega \times x^2$. These shouldn’t be math: - * 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$. +* 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$. Here’s a LaTeX table: @@ -461,11 +461,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. @@ -572,9 +572,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: <nobody@nowhere.net> @@ -614,6 +614,6 @@ If you want, you can indent every line, but you can also be lazy and just indent > Notes can go in quotes. **{Note:** In quote.**}** - 1. And in list items. **{Note:** In list.**}** +1. And in list items. **{Note:** In list.**}** This paragraph should not be part of the note, as it is not indented. |