git.iko.soy/typeable/pandoc
on master help sign in
ZimWiki writer: remove extra indentation on lists.

Closes #4963.

commit4fe28e947a38bffdbb4eeccb16e62dc1824b9c74 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 29 Oct 2018, 22:33 (8 years ago) parentc51be5d
2 files changed+96−96
src/Text/Pandoc/Writers/ZimWiki.hs+8−8 test/writer.zimwiki+88−88
src/Text/Pandoc/Writers/ZimWiki.hs+8−8
@@ -183,17 +183,13 @@ blockToZimWiki opts (Table capt aligns _ headers rows) = do
183183 unlines (map renderRow rows')
184184
185185blockToZimWiki opts (BulletList items) = do
186− indent <- gets stIndent
187− modify $ \s -> s { stIndent = stIndent s ++ "\t" }
188186 contents <- mapM (listItemToZimWiki opts) items
189− modify $ \s -> s{ stIndent = indent } -- drop 1 (stIndent s) }
187+ indent <- gets stIndent
190188 return $ vcat contents ++ if null indent then "\n" else ""
191189
192190blockToZimWiki opts (OrderedList _ items) = do
193− indent <- gets stIndent
194− modify $ \s -> s { stIndent = stIndent s ++ "\t", stItemNum = 1 }
195191 contents <- mapM (orderedListItemToZimWiki opts) items
196− modify $ \s -> s{ stIndent = indent } -- drop 1 (stIndent s) }
192+ indent <- gets stIndent
197193 return $ vcat contents ++ if null indent then "\n" else ""
198194
199195blockToZimWiki opts (DefinitionList items) = do
@@ -246,16 +242,20 @@ vcat = intercalate "\n"
246242-- | Convert bullet list item (list of blocks) to ZimWiki.
247243listItemToZimWiki :: PandocMonad m => WriterOptions -> [Block] -> ZW m String
248244listItemToZimWiki opts items = do
249− contents <- blockListToZimWiki opts items
250245 indent <- gets stIndent
246+ modify $ \s -> s { stIndent = indent ++ "\t" }
247+ contents <- blockListToZimWiki opts items
248+ modify $ \s -> s{ stIndent = indent }
251249 return $ indent ++ "* " ++ contents
252250
253251-- | Convert ordered list item (list of blocks) to ZimWiki.
254252orderedListItemToZimWiki :: PandocMonad m
255253 => WriterOptions -> [Block] -> ZW m String
256254orderedListItemToZimWiki opts items = do
257− contents <- blockListToZimWiki opts items
258255 indent <- gets stIndent
256+ modify $ \s -> s { stIndent = indent ++ "\t" }
257+ contents <- blockListToZimWiki opts items
258+ modify $ \s -> s{ stIndent = indent }
259259 itemnum <- gets stItemNum
260260 --modify $ \s -> s { stItemNum = itemnum + 1 } -- this is not strictly necessary for zim as zim does its own renumbering
261261 return $ indent ++ show itemnum ++ ". " ++ contents
test/writer.zimwiki+88−88
@@ -61,8 +61,8 @@ E-mail style:
6161>
6262> A list:
6363>
64−> 1. item one
65−> 1. item two
64+> 1. item one
65+> 1. item two
6666>
6767> Nested block quotes:
6868>
@@ -108,126 +108,126 @@ These should not be escaped: \$ \\ \> \[ \{
108108
109109Asterisks tight:
110110
111− * asterisk 1
112− * asterisk 2
113− * asterisk 3
111+* asterisk 1
112+* asterisk 2
113+* asterisk 3
114114
115115Asterisks loose:
116116
117− * asterisk 1
118− * asterisk 2
119− * asterisk 3
117+* asterisk 1
118+* asterisk 2
119+* asterisk 3
120120
121121Pluses tight:
122122
123− * Plus 1
124− * Plus 2
125− * Plus 3
123+* Plus 1
124+* Plus 2
125+* Plus 3
126126
127127Pluses loose:
128128
129− * Plus 1
130− * Plus 2
131− * Plus 3
129+* Plus 1
130+* Plus 2
131+* Plus 3
132132
133133Minuses tight:
134134
135− * Minus 1
136− * Minus 2
137− * Minus 3
135+* Minus 1
136+* Minus 2
137+* Minus 3
138138
139139Minuses loose:
140140
141− * Minus 1
142− * Minus 2
143− * Minus 3
141+* Minus 1
142+* Minus 2
143+* Minus 3
144144
145145===== Ordered =====
146146
147147Tight:
148148
149− 1. First
150− 1. Second
151− 1. Third
149+1. First
150+1. Second
151+1. Third
152152
153153and:
154154
155− 1. One
156− 1. Two
157− 1. Three
155+1. One
156+1. Two
157+1. Three
158158
159159Loose using tabs:
160160
161− 1. First
162− 1. Second
163− 1. Third
161+1. First
162+1. Second
163+1. Third
164164
165165and using spaces:
166166
167− 1. One
168− 1. Two
169− 1. Three
167+1. One
168+1. Two
169+1. Three
170170
171171Multiple paragraphs:
172172
173− 1. Item 1, graf one.
173+1. Item 1, graf one.
174174Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.
175− 1. Item 2.
176− 1. Item 3.
175+1. Item 2.
176+1. Item 3.
177177
178178===== Nested =====
179179
180+* Tab
180181 * Tab
181182 * Tab
182− * Tab
183183
184184Here’s another:
185185
186− 1. First
187− 1. Second:
188− * Fee
189− * Fie
190− * Foe
191− 1. Third
186+1. First
187+1. Second:
188+ * Fee
189+ * Fie
190+ * Foe
191+1. Third
192192
193193Same thing but with paragraphs:
194194
195− 1. First
196− 1. Second:
197− * Fee
198− * Fie
199− * Foe
200− 1. Third
195+1. First
196+1. Second:
197+ * Fee
198+ * Fie
199+ * Foe
200+1. Third
201201
202202===== Tabs and spaces =====
203203
204− * this is a list item indented with tabs
205− * this is a list item indented with spaces
206− * this is an example list item indented with tabs
207− * this is an example list item indented with spaces
204+* this is a list item indented with tabs
205+* this is a list item indented with spaces
206+ * this is an example list item indented with tabs
207+ * this is an example list item indented with spaces
208208
209209===== Fancy list markers =====
210210
211− 1. begins with 2
212− 1. and now 3
211+1. begins with 2
212+1. and now 3
213213with a continuation
214− 1. sublist with roman numerals, starting with 4
215− 1. more items
216− 1. a subsublist
217− 1. a subsublist
214+ 1. sublist with roman numerals, starting with 4
215+ 1. more items
216+ 1. a subsublist
217+ 1. a subsublist
218218
219219Nesting:
220220
221− 1. Upper Alpha
222− 1. Upper Roman.
223− 1. Decimal start with 6
224− 1. Lower alpha with paren
221+1. Upper Alpha
222+ 1. Upper Roman.
223+ 1. Decimal start with 6
224+ 1. Lower alpha with paren
225225
226226Autonumbering:
227227
228− 1. Autonumber.
229− 1. More.
230− 1. Nested.
228+1. Autonumber.
229+1. More.
230+ 1. Nested.
231231
232232Should not be a list item:
233233
@@ -291,8 +291,8 @@ computer
291291
292292* **orange** orange fruit
293293
294− 1. sublist
295− 1. sublist
294+1. sublist
295+1. sublist
296296
297297====== HTML Blocks ======
298298
@@ -435,21 +435,21 @@ Ellipses…and…and….
435435
436436====== LaTeX ======
437437
438− *
439− * $2+2=4$
440− * $x \in y$
441− * $\alpha \wedge \omega$
442− * $223$
443− * $p$-Tree
444− * Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
445− * Here’s one that has a line break in it: $\alpha + \omega \times x^2$.
438+*
439+* $2+2=4$
440+* $x \in y$
441+* $\alpha \wedge \omega$
442+* $223$
443+* $p$-Tree
444+* Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
445+* Here’s one that has a line break in it: $\alpha + \omega \times x^2$.
446446
447447These shouldn’t be math:
448448
449− * To get the famous equation, write ''$e = mc^2$''.
450− * $22,000 is a //lot// of money. So is $34,000. (It worked if “lot” is emphasized.)
451− * Shoes ($20) and socks ($5).
452− * Escaped ''$'': $73 //this should be emphasized// 23$.
449+* To get the famous equation, write ''$e = mc^2$''.
450+* $22,000 is a //lot// of money. So is $34,000. (It worked if “lot” is emphasized.)
451+* Shoes ($20) and socks ($5).
452+* Escaped ''$'': $73 //this should be emphasized// 23$.
453453
454454Here’s a LaTeX table:
455455
@@ -461,11 +461,11 @@ Here’s a LaTeX table:
461461
462462Here is some unicode:
463463
464− * I hat: Î
465− * o umlaut: ö
466− * section: §
467− * set membership: ∈
468− * copyright: ©
464+* I hat: Î
465+* o umlaut: ö
466+* section: §
467+* set membership: ∈
468+* copyright: ©
469469
470470AT&T has an ampersand in their name.
471471
@@ -572,9 +572,9 @@ Here’s an [[script?foo=1&bar=2|inline link in pointy braces]].
572572
573573With an ampersand: http://example.com/?foo=1&bar=2
574574
575− * In a list?
576− * http://example.com/
577− * It should.
575+* In a list?
576+* http://example.com/
577+* It should.
578578
579579An e-mail address: <nobody@nowhere.net>
580580
@@ -614,6 +614,6 @@ If you want, you can indent every line, but you can also be lazy and just indent
614614
615615> Notes can go in quotes. **{Note:** In quote.**}**
616616
617− 1. And in list items. **{Note:** In list.**}**
617+1. And in list items. **{Note:** In list.**}**
618618
619619This paragraph should not be part of the note, as it is not indented.