Fix html: a width of table was ignored on HTML builder (ref: #6564)

This commit is contained in:
Takeshi KOMIYA 2020-03-29 17:56:19 +09:00
parent 3b6b3e5801
commit 49063aa4eb
2 changed files with 5 additions and 1 deletions

View File

@ -23,6 +23,7 @@ Bugs fixed
* #7368: C++, comma operator in expressions, pack expansion in template
argument lists, and more comprehensive error messages in some cases.
* C, C++, fix crash and wrong duplicate warnings related to anon symbols.
* #6564: html: a width of table was ignored on HTML builder
Testing
--------

View File

@ -734,11 +734,14 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
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: