Markdown reader: Improved pipe table relative widths.

Previously pipe table columns got relative widths (based
on the header underscore lines) when the source of one of the rows was
greater in width than the column width.  This gave bad results in some
cases where much of the width of the row was due to nonprinting
material (e.g. link URLs).  Now pandoc only looks at printable
width (the width of a plain string version of the source), which
should give better results.

Thanks to John Muccigrosso for bringing up the issue.
This commit is contained in:
John MacFarlane 2015-12-03 11:02:45 -08:00
parent e5c72caf29
commit dd8df6cfbc
2 changed files with 8 additions and 7 deletions

7
README
View file

@ -2254,9 +2254,10 @@ legal (though ugly) pipe table:
The cells of pipe tables cannot contain block elements like paragraphs
and lists, and cannot span multiple lines. If a pipe table contains a
row that is wider than the column width (see `--columns`), then the cell
contents will wrap, with the relative cell widths determined by the widths
of the separator lines.
row whose printable content is wider than the column width (see
`--columns`), then the cell contents will wrap, with the
relative cell widths determined by the widths of the separator
lines.
Note: pandoc also recognizes pipe tables of the following
form, as can be produced by Emacs' orgtbl-mode:

View file

@ -1341,10 +1341,10 @@ pipeTable :: MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]])
pipeTable = try $ do
nonindentSpaces
lookAhead nonspaceChar
((heads, rawHead),(aligns, seplengths)) <- (,) <$>
withRaw pipeTableRow <*> pipeBreak
(lines', rawRows) <- unzip <$> many (withRaw pipeTableRow)
let maxlength = maximum $ map length (rawHead : rawRows)
(heads,(aligns, seplengths)) <- (,) <$> pipeTableRow <*> pipeBreak
lines' <- many pipeTableRow
let maxlength = maximum $
map (\x -> length . stringify $ runF x def) (heads : lines')
numColumns <- getOption readerColumns
let widths = if maxlength > numColumns
then map (\len ->