Merge pull request #4974 from tk0miya/latex_deeply_nested_enumlist

Fix latex: deeply nested enumerated list which is beginning with non-1 causes LaTeX engine crashed
This commit is contained in:
Takeshi KOMIYA 2018-05-19 14:03:33 +09:00 committed by GitHub
commit 6df16e9daf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 2 deletions

View File

@ -28,6 +28,8 @@ Bugs fixed
* C++, properly use ``desc_addname`` nodes for prefixes of names. * C++, properly use ``desc_addname`` nodes for prefixes of names.
* #4915, #4916: links on search page are broken when using dirhtml builder * #4915, #4916: links on search page are broken when using dirhtml builder
* #4969: autodoc: constructor method should not have return annotation * #4969: autodoc: constructor method should not have return annotation
* latex: deeply nested enumerated list which is beginning with non-1 causes
LaTeX engine crashed
Testing Testing
-------- --------

View File

@ -18,6 +18,7 @@ from collections import defaultdict
from os import path from os import path
from docutils import nodes, writers from docutils import nodes, writers
from docutils.utils.roman import toRoman
from docutils.writers.latex2e import Babel from docutils.writers.latex2e import Babel
from six import itervalues, text_type from six import itervalues, text_type
@ -1514,8 +1515,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append('\\begin{enumerate}\n') self.body.append('\\begin{enumerate}\n')
if 'start' in node: if 'start' in node:
nested = get_nested_level(node) enum_depth = "enum%s" % toRoman(get_nested_level(node)).lower()
self.body.append('\\setcounter{enum%s}{%d}\n' % ('i' * nested, node['start'] - 1)) self.body.append('\\setcounter{%s}{%d}\n' % (enum_depth, node['start'] - 1))
if self.table: if self.table:
self.table.has_problematic = True self.table.has_problematic = True

View File

@ -9,6 +9,12 @@ nested-enumerated-list
10) Pyramid 10) Pyramid
11) Nile River 11) Nile River
(x) Atbara
(y) Blue Nile
(#) Sobat
(#) Semliki
(#) Kagera
6. Markup 6. Markup
iii. reStructuredText iii. reStructuredText

View File

@ -1239,4 +1239,5 @@ def test_latex_nested_enumerated_list(app, status, warning):
assert r'\setcounter{enumi}{4}' in result assert r'\setcounter{enumi}{4}' in result
assert r'\setcounter{enumii}{3}' in result assert r'\setcounter{enumii}{3}' in result
assert r'\setcounter{enumiii}{9}' in result assert r'\setcounter{enumiii}{9}' in result
assert r'\setcounter{enumiv}{23}' in result
assert r'\setcounter{enumii}{2}' in result assert r'\setcounter{enumii}{2}' in result