Merge pull request #7397 from tk0miya/6564_table_width

Fix html: a width of table was ignored on HTML builder (ref: #6564)
This commit is contained in:
Takeshi KOMIYA 2020-03-30 23:53:24 +09:00 committed by GitHub
commit ac2987a7d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -30,6 +30,7 @@ Bugs fixed
different with one from ``index`` directive with "builtin" type different with one from ``index`` directive with "builtin" type
* #7301: capital characters are not allowed for node_id * #7301: capital characters are not allowed for node_id
* #7301: epub: duplicated node_ids are generated * #7301: epub: duplicated node_ids are generated
* #6564: html: a width of table was ignored on HTML builder
Testing Testing
-------- --------

View File

@ -734,11 +734,14 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
self._table_row_index = 0 self._table_row_index = 0
atts = {}
classes = [cls.strip(' \t\n') for cls in self.settings.table_style.split(',')] classes = [cls.strip(' \t\n') for cls in self.settings.table_style.split(',')]
classes.insert(0, "docutils") # compat classes.insert(0, "docutils") # compat
if 'align' in node: if 'align' in node:
classes.append('align-%s' % node['align']) 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) self.body.append(tag)
def visit_row(self, node: Element) -> None: def visit_row(self, node: Element) -> None: