git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: Improved definition lists.

* Use `:` form instead of `~`, for better compatibility with other markdown implementations. * Don't wrap the term, because it breaks definition lists.

commit4991852edbb1ad286518ca0d58c4b1082587969f authorJohn MacFarlane <fiddlosopher@gmail.com> dateWed 16 May 2012, 13:07 (14 years ago) parent4e35c67
2 files changed+24−24
src/Text/Pandoc/Writers/Markdown.hs+2−2 tests/writer.markdown+22−22
src/Text/Pandoc/Writers/Markdown.hs+2−2
@@ -355,13 +355,13 @@ definitionListItemToMarkdown opts (label, defs) = do
355355 labelText <- inlineListToMarkdown opts label
356356 let tabStop = writerTabStop opts
357357 st <- get
358− let leader = if stPlain st then " " else " ~"
358+ let leader = if stPlain st then " " else ": "
359359 let sps = case writerTabStop opts - 3 of
360360 n | n > 0 -> text $ replicate n ' '
361361 _ -> text " "
362362 defs' <- mapM (mapM (blockToMarkdown opts)) defs
363363 let contents = vcat $ map (\d -> hang tabStop (leader <> sps) $ vcat d <> cr) defs'
364− return $ labelText <> cr <> contents <> cr
364+ return $ nowrap labelText <> cr <> contents <> cr
365365
366366-- | Convert list of Pandoc block elements to markdown.
367367blockListToMarkdown :: WriterOptions -- ^ Options
tests/writer.markdown+22−22
@@ -272,41 +272,41 @@ Definition Lists
272272Tight using spaces:
273273
274274apple
275− ~ red fruit
275+: red fruit
276276orange
277− ~ orange fruit
277+: orange fruit
278278banana
279− ~ yellow fruit
279+: yellow fruit
280280
281281Tight using tabs:
282282
283283apple
284− ~ red fruit
284+: red fruit
285285orange
286− ~ orange fruit
286+: orange fruit
287287banana
288− ~ yellow fruit
288+: yellow fruit
289289
290290Loose:
291291
292292apple
293− ~ red fruit
293+: red fruit
294294
295295orange
296− ~ orange fruit
296+: orange fruit
297297
298298banana
299− ~ yellow fruit
299+: yellow fruit
300300
301301Multiple blocks with italics:
302302
303303*apple*
304− ~ red fruit
304+: red fruit
305305
306306 contains seeds, crisp, pleasant to taste
307307
308308*orange*
309− ~ orange fruit
309+: orange fruit
310310
311311 { orange code block }
312312
@@ -315,33 +315,33 @@ Multiple blocks with italics:
315315Multiple definitions, tight:
316316
317317apple
318− ~ red fruit
319− ~ computer
318+: red fruit
319+: computer
320320orange
321− ~ orange fruit
322− ~ bank
321+: orange fruit
322+: bank
323323
324324Multiple definitions, loose:
325325
326326apple
327− ~ red fruit
327+: red fruit
328328
329− ~ computer
329+: computer
330330
331331orange
332− ~ orange fruit
332+: orange fruit
333333
334− ~ bank
334+: bank
335335
336336Blank line after term, indented marker, alternate markers:
337337
338338apple
339− ~ red fruit
339+: red fruit
340340
341− ~ computer
341+: computer
342342
343343orange
344− ~ orange fruit
344+: orange fruit
345345
346346 1. sublist
347347 2. sublist