-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
commonmark-pandoc
: calculate relative cell widths for pipe tables
#128
Comments
|
Not sure I follow: the code is currently passing |
Well, how would it figure out what ColWidth to use? Another issue is that computing relative widths requires a standard for 100%. In pandoc this is adjustable using |
Ah, I understand now:
Perhaps |
This would require pandoc to be parsing the document rather than handing off parsing to |
I was imagining Pandoc would parse with If I understand the current approach, it seems like the column width of the markdown source is used to determine whether a line is long:
With
With the AST, Pandoc would then sum up an approximation of width for each cell in a row, and determine whether row exceeds Approximating the rendered width -- based on either the source markdown or the AST -- seems tricky in the presence of short commands that expand to long output and long commands that expand to short output (e.g. |
You could get a rough approximation that way, maybe. |
Is that not already an issue with the source-based approach? |
What I mean is that it could not match the behavior specified in the manual, which refers to the length of the source line -- which we could only guess about. |
I see. As a clunky but correct approach then, how about passing the source (or the source length) for each row through |
We should be able to change class HasPipeTable il bl where
pipeTable :: [ColAlignment] -> [il] -> [[il]] -> bl to something like class HasPipeTable il bl where
pipeTable :: [(ColAlignment, ColWidth)] -> [il] -> [[il]] -> bl in commonmark-extensions. We can have the extension calculate widths in the same way as pandoc. Then it would be trivial to have commonmark-pandoc use this information. The one potential drawback is that our pipe tables would sometimes render differently from GFM's -- and this might be a problem for some users. To fix that, we could make |
Pandoc's Markdown parser sets relative widths for each column in a pipe table when the table contains long rows, which allows LaTeX to wrap cells to avoid overflowing the page (implemented in jgm/pandoc@eb8aee4).
commonmark-pandoc
doesn't implement this functionality and always sets the column width to default, resulting in poor PDF rendering:commonmark-hs/commonmark-pandoc/src/Commonmark/Pandoc.hs
Lines 139 to 140 in 6ec393d
It'd be great if this feature could be implemented in
commonmark-pandoc
, but I don't have the familiarity with Haskell or the codebase to do it myself.The text was updated successfully, but these errors were encountered: