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-15 01:46:40 +09:00
parent 981e044bd5
commit c6050a3d1e
4 changed files with 12 additions and 2 deletions

View File

@ -23,6 +23,8 @@ Bugs fixed
topic, admonition, table and section.
* #4913: i18n: literal blocks in bullet list are not translated
* #4962: cpp domain: raises TypeError on duplicate declaration
* latex: deeply nested enumerated list which is beginning with non-1 causes
LaTeX engine crashed
Testing
--------

View File

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

View File

@ -9,6 +9,12 @@ nested-enumerated-list
10) Pyramid
11) Nile River
(x) Atbara
(y) Blue Nile
(#) Sobat
(#) Semliki
(#) Kagera
6. Markup
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{enumii}{3}' in result
assert r'\setcounter{enumiii}{9}' in result
assert r'\setcounter{enumiv}{23}' in result
assert r'\setcounter{enumii}{2}' in result