git.iko.soy/typeable/pandoc
on master help sign in
Reverted "omit blank lines after list items," better fix for #1777.
d8fde95John MacFarlane
src/Text/Pandoc/Writers/RST.hs+6−6
@@ -252,7 +252,7 @@ blockToRST (Table caption _ widths headers rows) = do
252blockToRST (BulletList items) = do
252blockToRST (BulletList items) = do
253 contents <- mapM bulletListItemToRST items
253 contents <- mapM bulletListItemToRST items
254 -- ensure that sublists have preceding blank line
254 -- ensure that sublists have preceding blank line
255− return $ blankline $$ vcat contents $$ blankline
255+ return $ blankline $$ chomp (vcat contents) $$ blankline
256blockToRST (OrderedList (start, style', delim) items) = do
256blockToRST (OrderedList (start, style', delim) items) = do
257 let markers = if start == 1 && style' == DefaultStyle && delim == DefaultDelim
257 let markers = if start == 1 && style' == DefaultStyle && delim == DefaultDelim
258 then take (length items) $ repeat "#."
258 then take (length items) $ repeat "#."
@@ -264,17 +264,17 @@ blockToRST (OrderedList (start, style', delim) items) = do
264 contents <- mapM (\(item, num) -> orderedListItemToRST item num) $
264 contents <- mapM (\(item, num) -> orderedListItemToRST item num) $
265 zip markers' items
265 zip markers' items
266 -- ensure that sublists have preceding blank line
266 -- ensure that sublists have preceding blank line
267− return $ blankline $$ vcat contents $$ blankline
267+ return $ blankline $$ chomp (vcat contents) $$ blankline
268blockToRST (DefinitionList items) = do
268blockToRST (DefinitionList items) = do
269 contents <- mapM definitionListItemToRST items
269 contents <- mapM definitionListItemToRST items
270 -- ensure that sublists have preceding blank line
270 -- ensure that sublists have preceding blank line
271− return $ blankline $$ vcat contents $$ blankline
271+ return $ blankline $$ chomp (vcat contents) $$ blankline
272
272
273-- | Convert bullet list item (list of blocks) to RST.
273-- | Convert bullet list item (list of blocks) to RST.
274bulletListItemToRST :: [Block] -> State WriterState Doc
274bulletListItemToRST :: [Block] -> State WriterState Doc
275bulletListItemToRST items = do
275bulletListItemToRST items = do
276 contents <- blockListToRST items
276 contents <- blockListToRST items
277− return $ hang 3 "- " contents
277+ return $ hang 3 "- " $ contents <> cr
278
278
279-- | Convert ordered list item (a list of blocks) to RST.
279-- | Convert ordered list item (a list of blocks) to RST.
280orderedListItemToRST :: String -- ^ marker for list item
280orderedListItemToRST :: String -- ^ marker for list item
@@ -283,7 +283,7 @@ orderedListItemToRST :: String -- ^ marker for list item
283orderedListItemToRST marker items = do
283orderedListItemToRST marker items = do
284 contents <- blockListToRST items
284 contents <- blockListToRST items
285 let marker' = marker ++ " "
285 let marker' = marker ++ " "
286− return $ hang (length marker') (text marker') contents
286+ return $ hang (length marker') (text marker') $ contents <> cr
287
287
288-- | Convert defintion list item (label, list of blocks) to RST.
288-- | Convert defintion list item (label, list of blocks) to RST.
289definitionListItemToRST :: ([Inline], [[Block]]) -> State WriterState Doc
289definitionListItemToRST :: ([Inline], [[Block]]) -> State WriterState Doc
@@ -291,7 +291,7 @@ definitionListItemToRST (label, defs) = do
291 label' <- inlineListToRST label
291 label' <- inlineListToRST label
292 contents <- liftM vcat $ mapM blockListToRST defs
292 contents <- liftM vcat $ mapM blockListToRST defs
293 tabstop <- get >>= (return . writerTabStop . stOptions)
293 tabstop <- get >>= (return . writerTabStop . stOptions)
294− return $ label' $$ nest tabstop (nestle contents)
294+ return $ label' $$ nest tabstop (nestle contents <> cr)
295
295
296-- | Convert list of Pandoc block elements to RST.
296-- | Convert list of Pandoc block elements to RST.
297blockListToRST :: [Block] -- ^ List of block elements
297blockListToRST :: [Block] -- ^ List of block elements
tests/writer.rst+23
@@ -136,7 +136,9 @@ Asterisks tight:
136Asterisks loose:
136Asterisks loose:
137
137
138- asterisk 1
138- asterisk 1
139+
139- asterisk 2
140- asterisk 2
141+
140- asterisk 3
142- asterisk 3
141
143
142Pluses tight:
144Pluses tight:
@@ -148,7 +150,9 @@ Pluses tight:
148Pluses loose:
150Pluses loose:
149
151
150- Plus 1
152- Plus 1
153+
151- Plus 2
154- Plus 2
155+
152- Plus 3
156- Plus 3
153
157
154Minuses tight:
158Minuses tight:
@@ -160,7 +164,9 @@ Minuses tight:
160Minuses loose:
164Minuses loose:
161
165
162- Minus 1
166- Minus 1
167+
163- Minus 2
168- Minus 2
169+
164- Minus 3
170- Minus 3
165
171
166Ordered
172Ordered
@@ -181,13 +187,17 @@ and:
181Loose using tabs:
187Loose using tabs:
182
188
1831. First
1891. First
190+
1842. Second
1912. Second
192+
1853. Third
1933. Third
186
194
187and using spaces:
195and using spaces:
188
196
1891. One
1971. One
198+
1902. Two
1992. Two
200+
1913. Three
2013. Three
192
202
193Multiple paragraphs:
203Multiple paragraphs:
@@ -195,7 +205,9 @@ Multiple paragraphs:
1951. Item 1, graf one.
2051. Item 1, graf one.
196
206
197 Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.
207 Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.
208+
1982. Item 2.
2092. Item 2.
210+
1993. Item 3.
2113. Item 3.
200
212
201Nested
213Nested
@@ -215,25 +227,30 @@ Here’s another:
215 - Fee
227 - Fee
216 - Fie
228 - Fie
217 - Foe
229 - Foe
230+
2183. Third
2313. Third
219
232
220Same thing but with paragraphs:
233Same thing but with paragraphs:
221
234
2221. First
2351. First
236+
2232. Second:
2372. Second:
224
238
225 - Fee
239 - Fee
226 - Fie
240 - Fie
227 - Foe
241 - Foe
242+
2283. Third
2433. Third
229
244
230Tabs and spaces
245Tabs and spaces
231---------------
246---------------
232
247
233- this is a list item indented with tabs
248- this is a list item indented with tabs
249+
234- this is a list item indented with spaces
250- this is a list item indented with spaces
235
251
236 - this is an example list item indented with tabs
252 - this is an example list item indented with tabs
253+
237 - this is an example list item indented with spaces
254 - this is an example list item indented with spaces
238
255
239Fancy list markers
256Fancy list markers
@@ -300,8 +317,10 @@ Loose:
300
317
301apple
318apple
302 red fruit
319 red fruit
320+
303orange
321orange
304 orange fruit
322 orange fruit
323+
305banana
324banana
306 yellow fruit
325 yellow fruit
307
326
@@ -311,6 +330,7 @@ Multiple blocks with italics:
311 red fruit
330 red fruit
312
331
313 contains seeds, crisp, pleasant to taste
332 contains seeds, crisp, pleasant to taste
333+
314*orange*
334*orange*
315 orange fruit
335 orange fruit
316
336
@@ -335,6 +355,7 @@ apple
335 red fruit
355 red fruit
336
356
337 computer
357 computer
358+
338orange
359orange
339 orange fruit
360 orange fruit
340
361
@@ -346,6 +367,7 @@ apple
346 red fruit
367 red fruit
347
368
348 computer
369 computer
370+
349orange
371orange
350 orange fruit
372 orange fruit
351
373
@@ -644,6 +666,7 @@ LaTeX
644- Here’s some display math:
666- Here’s some display math:
645
667
646 .. math:: \frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}
668 .. math:: \frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}
669+
647- Here’s one that has a line break in it: :math:`\alpha + \omega \times x^2`.
670- Here’s one that has a line break in it: :math:`\alpha + \omega \times x^2`.
648
671
649These shouldn’t be math:
672These shouldn’t be math: