git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: fixed bugs in simple/multiline list output.

* Previously we got overlong lists with `--wrap=none`. This is fixed. * Previously a multiline list could become a simple list (and would always become one with `--wrap=none`). Closes #3384.

commitd66b046c8a961dcb6ad08fa7ef5eea1864db4f9c authorJohn MacFarlane <jgm@berkeley.edu> dateSat 11 Mar 2017, 23:24 (10 years ago) parentbe73338
2 files changed+24−10
src/Text/Pandoc/Writers/Markdown.hs+9−10 test/command/3384.md+15
src/Text/Pandoc/Writers/Markdown.hs+9−10
@@ -673,15 +673,14 @@ pandocTable opts headless aligns widths rawHeaders rawRows = do
673673 let minNumChars = (+ 2) . maximum . map minOffset
674674 let columns = transpose (rawHeaders : rawRows)
675675 -- minimal column width without wrapping a single word
676− let noWordWrapWidth
677− | writerWrapText opts == WrapAuto
678− = fromIntegral $ maximum (map minNumChars columns)
679− | otherwise = fromIntegral $ maximum (map numChars columns)
680− let relWidth w = floor $ max (fromIntegral (writerColumns opts) * w)
681− (noWordWrapWidth * w / minimum widths)
676+ let relWidth w col =
677+ max (floor $ fromIntegral (writerColumns opts) * w)
678+ (if writerWrapText opts == WrapAuto
679+ then minNumChars col
680+ else numChars col)
682681 let widthsInChars
683682 | isSimple = map numChars columns
684− | otherwise = map relWidth widths
683+ | otherwise = zipWith relWidth widths columns
685684 let makeRow = hcat . intersperse (lblock 1 (text " ")) .
686685 (zipWith3 alignHeader aligns widthsInChars)
687686 let rows' = map makeRow rawRows
@@ -698,9 +697,9 @@ pandocTable opts headless aligns widths rawHeaders rawRows = do
698697 let head'' = if headless
699698 then empty
700699 else border <> cr <> head'
701− let body = if maxRowHeight > 1
702− then vsep rows'
703− else vcat rows'
700+ let body = if isSimple
701+ then vcat rows'
702+ else vsep rows'
704703 let bottom = if headless
705704 then underline
706705 else border
test/command/3384.mdnew file+15
@@ -0,0 +1,15 @@
1+```
2+% pandoc -t markdown --wrap=none
3+ ----- ------------------------------------------------
4+ foo bar
5+
6+ foo this is a long
7+ line of text
8+ ----- ------------------------------------------------
9+^D
10+ ------ ------------------------------------------------
11+ foo bar
12+
13+ foo this is a long line of text
14+ ------ ------------------------------------------------
15+```