Skip to content

Commit

Permalink
Merge pull request sphinx-doc#7397 from tk0miya/6564_table_width
Browse files Browse the repository at this point in the history
Fix html: a width of table was ignored on HTML builder (ref: sphinx-doc#6564)
  • Loading branch information
tk0miya committed Mar 30, 2020
2 parents 80e06fc + 015def3 commit ac2987a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -30,6 +30,7 @@ Bugs fixed
different with one from ``index`` directive with "builtin" type
* #7301: capital characters are not allowed for node_id
* #7301: epub: duplicated node_ids are generated
* #6564: html: a width of table was ignored on HTML builder

Testing
--------
Expand Down
5 changes: 4 additions & 1 deletion sphinx/writers/html5.py
Expand Up @@ -734,11 +734,14 @@ def visit_table(self, node: Element) -> None:

self._table_row_index = 0

atts = {}
classes = [cls.strip(' \t\n') for cls in self.settings.table_style.split(',')]
classes.insert(0, "docutils") # compat
if 'align' in node:
classes.append('align-%s' % node['align'])
tag = self.starttag(node, 'table', CLASS=' '.join(classes))
if 'width' in node:
atts['style'] = 'width: %s' % node['width']
tag = self.starttag(node, 'table', CLASS=' '.join(classes), **atts)
self.body.append(tag)

def visit_row(self, node: Element) -> None:
Expand Down

0 comments on commit ac2987a

Please sign in to comment.