From 61f7a4f8698e9d9eb7a8af6ab8253815415156e7 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 5 Dec 2009 07:47:09 +0000 Subject: Markdown reader: Compensate for width of final table column. Resolves Issue #144. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1649 788f1e2b-df1e-0410-8736-df70ead52e1b --- src/Text/Pandoc/Readers/Markdown.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Readers/Markdown.hs') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index c6926e3c1..7d758d9ed 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -728,7 +728,17 @@ widthsFromIndices :: Int -- Number of columns on terminal -> [Double] -- Fractional relative sizes of columns widthsFromIndices _ [] = [] widthsFromIndices numColumns indices = - let lengths = zipWith (-) indices (0:indices) + let lengths' = zipWith (-) indices (0:indices) + lengths = reverse $ + case reverse lengths' of + [] -> [] + [x] -> [x] + -- compensate for the fact that intercolumn + -- spaces are counted in widths of all columns + -- but the last... + (x:y:zs) -> if x < y && y - x <= 2 + then y:y:zs + else x:y:zs totLength = sum lengths quotient = if totLength > numColumns then fromIntegral totLength -- cgit v1.2.3