Skip to content
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

Table column widths clarification #7864

Closed
kysko opened this issue Jan 24, 2022 · 3 comments
Closed

Table column widths clarification #7864

kysko opened this issue Jan 24, 2022 · 3 comments
Labels

Comments

@kysko
Copy link

kysko commented Jan 24, 2022

I made a comment last month, but at the wrong place, so it got lost (my bad), so here it is again:

(it could be a "bug" in the docs, or not)

In the Lua filter guide under ColSpec, table column width is defined as "a fraction of the total table width". But I've seen it has been corrected elsewhere, in a Haskell context, as "a percentage of the text width".

This can be checked with a grid table with one row of two cells, 20 chars wide each, and rendering (eg to native) by setting --columns=N to different values.

+-------------------+-------------------+
|                   |                   |
+-------------------+-------------------+

With N > 40, you get widths inferior to 0.5, diminishing as N increases. With N < 40, you always get 0.5. So the values seem to be percentages relative to the max between page width and table width. (Seems to be confirmed in the code, but I'm no good at Haskell)

That being said, it does make some sense of defining table column widths relative to table width, especially if the Table structure is inspired from HTML for which it is the case... but then again a markdown doc isn't a web page.

This also has a direct incidence on the html writer which directly treats the col widths as relative to the table, which can give weird results if a high N is used for columns... but I guess that would be for another issue.

So I'd like a clarification of this detail, since setting these values in a filter//custom reader/writer depend upon the interpretation/situation.

@kysko kysko added the bug label Jan 24, 2022
@mb21
Copy link
Collaborator

mb21 commented Jan 24, 2022

AFAIK, a table's column width unit has never been defined precisely. Pandoc's document AST stores some number between zero and one (to be interpreted as a percentage with 1 being 100%), but it's up to the different writers to do something meaningful with the number, depending on which output format we're writing to (e.g. the HTML writer just outputs CSS %, but what that's relative to depends on the rest of the CSS that's loaded, which is customizable).

@jgm
Copy link
Owner

jgm commented Jan 24, 2022

The number indicates the width of the column relative to the total page width (as defined by --columns -- default is 72, though perhaps this could change, #7641 (comment)).

The intention is for writers to interpret these widths as relative to page width, not table width. I will fix the Lua documentation.

The other issue you raised concerns the HTML writer. Currently we use percentages. I figured these would be interpreted relative to the width of the enclosing container, not the table. And indeed that's what I'm seeing in the browser with a quick test....

So, anything left to do on this?

@kysko
Copy link
Author

kysko commented Jan 24, 2022

The other issue you raised concerns the HTML writer. Currently we use percentages. I figured these would be interpreted relative to the width of the enclosing container, not the table.

Except that usually those html percentages are relative to their parent, here the table... but the browsers adjust/stretch these values anyways...
As long as it looks ok though, that's what counts for now.

I'll raise a separate issue, or question on discuss board, if I have anything else about that.

So, anything left to do on this?

Not for the main issue.

@jgm jgm closed this as completed Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants