fix #3450: &nbsp is appeared in EPUB docs

This commit is contained in:
Yoshiki Shibukawa 2017-02-24 20:04:00 +09:00
parent b352927b37
commit 99b27c0c00
2 changed files with 17 additions and 2 deletions

View File

@ -31,7 +31,7 @@ Bugs fixed
* #3427: autodoc: memory addresses are not stripped on Windows * #3427: autodoc: memory addresses are not stripped on Windows
* #3428: xetex build tests fail due to fontspec v2.6 defining ``\strong`` * #3428: xetex build tests fail due to fontspec v2.6 defining ``\strong``
* #3349: Result of ``IndexBuilder.load()`` is broken * #3349: Result of ``IndexBuilder.load()`` is broken
* #3450: &nbsp is appeared in EPUB docs
Testing Testing
-------- --------

View File

@ -131,7 +131,7 @@ class HTMLTranslator(BaseTranslator):
pass pass
def visit_desc_returns(self, node): def visit_desc_returns(self, node):
self.body.append(' → ') self.body.append(' → ')
def depart_desc_returns(self, node): def depart_desc_returns(self, node):
pass pass
@ -727,6 +727,11 @@ class HTMLTranslator(BaseTranslator):
self.body.append(self.starttag(node, 'tr', '')) self.body.append(self.starttag(node, 'tr', ''))
node.column = 0 node.column = 0
def visit_entry(self, node):
BaseTranslator.visit_entry(self, node)
if self.body[-1] == ' ':
self.body[-1] = ' '
def visit_field_list(self, node): def visit_field_list(self, node):
self._fieldlist_row_index = 0 self._fieldlist_row_index = 0
return BaseTranslator.visit_field_list(self, node) return BaseTranslator.visit_field_list(self, node)
@ -739,6 +744,12 @@ class HTMLTranslator(BaseTranslator):
node['classes'].append('field-odd') node['classes'].append('field-odd')
self.body.append(self.starttag(node, 'tr', '', CLASS='field')) self.body.append(self.starttag(node, 'tr', '', CLASS='field'))
def visit_field_name(self, node):
context_count = len(self.context)
BaseTranslator.visit_field_name(self, node)
if context_count != len(self.context):
self.context[-1] = self.context[-1].replace(' ', ' ')
def visit_math(self, node, math_env=''): def visit_math(self, node, math_env=''):
self.builder.warn('using "math" markup without a Sphinx math extension ' self.builder.warn('using "math" markup without a Sphinx math extension '
'active, please use one of the math extensions ' 'active, please use one of the math extensions '
@ -821,6 +832,10 @@ class SmartyPantsHTMLTranslator(HTMLTranslator):
self.no_smarty -= 1 self.no_smarty -= 1
HTMLTranslator.depart_option(self, node) HTMLTranslator.depart_option(self, node)
def visit_option_group(self, node):
HTMLTranslator.visit_option_group(self, node)
self.context[-2] = self.context[-2].replace(' ', ' ')
def bulk_text_processor(self, text): def bulk_text_processor(self, text):
if self.no_smarty <= 0: if self.no_smarty <= 0:
return sphinx_smarty_pants(text) return sphinx_smarty_pants(text)