Fix: `make text will crush if a definition list item has more than 1 classifiers as: term : classifier1 : classifier2`.

This commit is contained in:
shimizukawa
2015-07-25 17:30:13 +02:00
parent 18bb742745
commit 3cd7e14e75
2 changed files with 8 additions and 4 deletions

View File

@@ -37,6 +37,9 @@ Bugs fixed
* #1923: Use babel features only if the babel latex element is nonempty.
* #1942: Fix a KeyError in websupport.
* #1903: Fix strange id generation for glossary terms.
* #1796, On py3, automated .mo building cause UnicodeDecodeError
* Fix: ``make text`` will crush if a definition list item has more than 1 classifiers as:
``term : classifier1 : classifier2``.
Release 1.3.1 (released Mar 17, 2015)

View File

@@ -628,8 +628,7 @@ class TextTranslator(nodes.NodeVisitor):
self.end_state(first='%s. ' % self.list_counter[-1])
def visit_definition_list_item(self, node):
self._li_has_classifier = len(node) >= 2 and \
isinstance(node[1], nodes.classifier)
self._classifier_count_in_li = len(node.traverse(nodes.classifier))
def depart_definition_list_item(self, node):
pass
@@ -638,7 +637,7 @@ class TextTranslator(nodes.NodeVisitor):
self.new_state(0)
def depart_term(self, node):
if not self._li_has_classifier:
if not self._classifier_count_in_li:
self.end_state(end=None)
def visit_termsep(self, node):
@@ -649,7 +648,9 @@ class TextTranslator(nodes.NodeVisitor):
self.add_text(' : ')
def depart_classifier(self, node):
self.end_state(end=None)
self._classifier_count_in_li -= 1
if not self._classifier_count_in_li:
self.end_state(end=None)
def visit_definition(self, node):
self.new_state()