Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enable :widths: option in table directives.#795

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
jhcole wants to merge1 commit intoexecutablebooks:master
base:master
Choose a base branch
Loading
fromjhcole:table_widths

Conversation

jhcole
Copy link
Contributor

Closes#793

The output frommyst-docutils-html5 differs from the results I'm getting fromjupyter-book build and I'm still tracking down where the difference are coming from.

There are 4 possible states for the width option of a table directive (not set, "auto", "grid", or a list of integers).

The results frommyst-docutils-html5 are as follows:

OptionPrevious behaviorNew behavior
Not set (default)no class or colspecsno class or colspecs
autono class or colspecsno class or colspecs
gridno class or colspecsAdd colgroup with column widths set equal to each other.
a list of integersno class or colspecsAdd colgroup with column widths set in proportion to the integers given.

The results fromjupyter-book build are as follows:

OptionPrevious behaviorNew behavior
Not set (default)Add the class "colwidths-auto" to the table and not set any column widths.Set equal proportion widths to each column. This is a regression I hope to fix.
autoAdd the class "colwidths-auto" to the table and not set any column widths.Add the class "colwidths-auto" to the table and not set any column widths (no change in behavior).
gridAdd the classes "colwidths-auto" and "colwidths-given" to the table, and not set any column widths.Add the class "colwidths-given" to the table, and set equal widths to each column. The documentation claims this option will set widths based on column contents, but it just sets them all equal.
a list of integersAdd the classes "colwidths-auto" and "colwidths-given" to the table, and not set any column widths.Add the class "colwidths-given" to the table and set columns widths in proportion to the integers given.

@codecov
Copy link

codecovbot commentedJul 23, 2023
edited
Loading

Codecov Report

Patch coverage has no change and project coverage change:-0.01⚠️

Comparison is base(350c633) 90.26% compared to head(7cf70b4) 90.26%.

Additional details and impacted files
@@            Coverage Diff             @@##           master     #795      +/-   ##==========================================- Coverage   90.26%   90.26%   -0.01%==========================================  Files          23       23                Lines        2970     2969       -1     ==========================================- Hits         2681     2680       -1  Misses        289      289
FlagCoverage Δ
pytests90.26% <ø> (-0.01%)⬇️

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
myst_parser/mdit_to_docutils/base.py93.51% <ø> (-0.01%)⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment?Let us know in this issue.

@chrisjsewell
Copy link
Member

chrisjsewell commentedJul 23, 2023
edited
Loading

The output from myst-docutils-html5 differs from the results I'm getting from jupyter-book build and I'm still tracking down where the difference are coming from.

To note, this shouldn't have anything to do with jupyter-book, since jupyter-book is just a thin wrapper on top of sphinx+myst-parser, that does not change its behaviour
If there is a difference, it would either be between docutils vs. sphinx behaviour, or a change in behaviour between versions of docutils/sphinx.

This is the code for the table directive:https://github.com/live-clones/docutils/blob/6de53a0de5415174d58e775110d89e13dd76fc83/docutils/docutils/parsers/rst/directives/tables.py#L134

This is where it used in the HTML conversion:https://github.com/live-clones/docutils/blob/6de53a0de5415174d58e775110d89e13dd76fc83/docutils/docutils/writers/_html_base.py#L686

@goroderickgo
Copy link

Hi, I saw the linked issue and was wondering if there was a roadmap to have this PR get merged into a release? Thanks!

@jhcole
Copy link
ContributorAuthor

Hi, I saw the linked issue and was wondering if there was a roadmap to have this PR get merged into a release? Thanks!

Sorry, I haven't had time to finish this. It will likely be a few months before I have time to focus on it again. You're welcome to take it over.

@berlin2123
Copy link

It works In my sphinx, If one just only change the code in/usr/local/lib/python3.<version>/dist-packages/myst_parser/mdit_to_docutils/base.py as this PR.

i.e., delete or comment the line 1352:

        #table["classes"] += ["colwidths-auto"]

@dbitouze
Copy link

dbitouze commentedNov 14, 2024
edited
Loading

@chrisjsewell Too bad this issue isn't fixed :)

It may be useful to note that the:widths: option is ignored with the{table} directive, but not with the{list-table} directive, as can be verified with the following code, for example in theLive Preview:

#With`{list-table}`:::{list-table}:widths: 30 30 30:header-rows: 1*- Header 1- Header 2- Header 3*- Cell 1-1- Cell 1-2- Cell 1-3*- Cell 2-1- Cell 2-2- Cell 2-3 long long long long long long long:::#With`{table}`:::{table} :width: 100:widths: 30 30 30| Header 1| Header 2| Header 3||----------|----------|---------------------------------------------|| Cell 1-1| Cell 1-2| Cell 1-3|| Cell 2-1| Cell 2-2| Cell 2-3 long long long long long long long|:::

@jduf
Copy link

Any update on this issue?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Column widths set in a table directive are ignored.
6 participants
@jhcole@chrisjsewell@goroderickgo@berlin2123@dbitouze@jduf

[8]ページ先頭

©2009-2025 Movatter.jp