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

🐛 FIX: floor table column widths to integers #568

Merged
merged 2 commits into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion myst_parser/mdit_to_docutils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ def render_table(self, token: SyntaxTreeNode) -> None:

# column settings element
maxcols = len(header_row.children)
colwidths = [round(100 / maxcols, 2)] * maxcols
colwidths = [100 // maxcols] * maxcols
tgroup = nodes.tgroup(cols=len(colwidths))
table += tgroup
for colwidth in colwidths:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_renderers/fixtures/sphinx_directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ table (`sphinx.directives.patches.RSTTable`):
<emphasis>
title
<tgroup cols="2">
<colspec colwidth="50.0">
<colspec colwidth="50.0">
<colspec colwidth="50">
<colspec colwidth="50">
<thead>
<row>
<entry>
Expand Down
22 changes: 11 additions & 11 deletions tests/test_renderers/fixtures/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ a|b
<document source="<src>/index.md">
<table classes="colwidths-auto">
<tgroup cols="2">
<colspec colwidth="50.0">
<colspec colwidth="50.0">
<colspec colwidth="50">
<colspec colwidth="50">
<thead>
<row>
<entry>
Expand All @@ -35,8 +35,8 @@ Header only:
<document source="<src>/index.md">
<table classes="colwidths-auto">
<tgroup cols="2">
<colspec colwidth="50.0">
<colspec colwidth="50.0">
<colspec colwidth="50">
<colspec colwidth="50">
<thead>
<row>
<entry>
Expand All @@ -56,9 +56,9 @@ a | b | c
<document source="<src>/index.md">
<table classes="colwidths-auto">
<tgroup cols="3">
<colspec colwidth="33.33">
<colspec colwidth="33.33">
<colspec colwidth="33.33">
<colspec colwidth="33">
<colspec colwidth="33">
<colspec colwidth="33">
<thead>
<row>
<entry classes="text-left">
Expand Down Expand Up @@ -92,8 +92,8 @@ Nested syntax:
<document source="<src>/index.md">
<table classes="colwidths-auto">
<tgroup cols="2">
<colspec colwidth="50.0">
<colspec colwidth="50.0">
<colspec colwidth="50">
<colspec colwidth="50">
<thead>
<row>
<entry>
Expand Down Expand Up @@ -125,8 +125,8 @@ a|b
<document source="<src>/index.md">
<table classes="colwidths-auto">
<tgroup cols="2">
<colspec colwidth="50.0">
<colspec colwidth="50.0">
<colspec colwidth="50">
<colspec colwidth="50">
<thead>
<row>
<entry>
Expand Down
2 changes: 2 additions & 0 deletions tests/test_sphinx/sourcedirs/texi_table/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extensions = ["myst_parser"]
exclude_patterns = ["_build"]
3 changes: 3 additions & 0 deletions tests/test_sphinx/sourcedirs/texi_table/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
| foo | bar |
| --- | --- |
| baz | bim |
17 changes: 17 additions & 0 deletions tests/test_sphinx/test_sphinx_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,3 +547,20 @@ def test_fieldlist_extension(
regress_html=True,
regress_ext=f".sphinx{sphinx.version_info[0]}.html",
)


@pytest.mark.sphinx(
buildername="texinfo",
srcdir=os.path.join(SOURCE_DIR, "texi_table"),
freshenv=True,
)
def test_texinfo_table(
app,
status,
warning,
):
"""Test that tables can be built with the Texinfo builder."""
app.build()
assert "build succeeded" in status.getvalue() # Build succeeded
warnings = warning.getvalue().strip()
assert warnings == ""
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
a=1{`}
<table classes="colwidths-auto">
<tgroup cols="2">
<colspec colwidth="50.0">
<colspec colwidth="50.0">
<colspec colwidth="50">
<colspec colwidth="50">
<thead>
<row>
<entry>
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sphinx/test_sphinx_builds/test_basic.sphinx4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
a=1{`}
<table classes="colwidths-auto">
<tgroup cols="2">
<colspec colwidth="50.0">
<colspec colwidth="50.0">
<colspec colwidth="50">
<colspec colwidth="50">
<thead>
<row>
<entry>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
gras
<table classes="colwidths-auto">
<tgroup cols="1">
<colspec colwidth="100.0">
<colspec colwidth="100">
<thead>
<row>
<entry>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
gras
<table classes="colwidths-auto">
<tgroup cols="1">
<colspec colwidth="100.0">
<colspec colwidth="100">
<thead>
<row>
<entry>
Expand Down