mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #2291: pdflatex "Counter too large" error from footnotes inside tables of contents
This commit is contained in:
parent
bdc230b1cc
commit
9b958b6dcc
1
CHANGES
1
CHANGES
@ -7,6 +7,7 @@ Bugs fixed
|
||||
* #2265: Fix babel is used in spite of disabling it on ``latex_elements``
|
||||
* #2295: Avoid mutating dictionary errors while enumerating members in autodoc
|
||||
with Python 3
|
||||
* #2291: Fix pdflatex "Counter too large" error from footnotes inside tables of contents
|
||||
|
||||
|
||||
Release 1.3.5 (released Jan 24, 2016)
|
||||
|
@ -141,9 +141,10 @@ def find_source_node(node):
|
||||
return pnode.source
|
||||
|
||||
|
||||
def traverse_parent(node):
|
||||
def traverse_parent(node, cls=None):
|
||||
while node:
|
||||
yield node
|
||||
if cls is None or isinstance(node, cls):
|
||||
yield node
|
||||
node = node.parent
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ from sphinx import highlighting
|
||||
from sphinx.errors import SphinxError
|
||||
from sphinx.locale import admonitionlabels, _
|
||||
from sphinx.util import split_into
|
||||
from sphinx.util.nodes import clean_astext
|
||||
from sphinx.util.nodes import clean_astext, traverse_parent
|
||||
from sphinx.util.osutil import ustrftime
|
||||
from sphinx.util.texescape import tex_escape_map, tex_replace_map
|
||||
from sphinx.util.smartypants import educate_quotes_latex
|
||||
@ -159,11 +159,15 @@ class ShowUrlsTransform(object):
|
||||
if node.astext() != uri:
|
||||
index = node.parent.index(node)
|
||||
if show_urls == 'footnote':
|
||||
footnote_nodes = self.create_footnote(uri)
|
||||
for i, fn in enumerate(footnote_nodes):
|
||||
node.parent.insert(index + i + 1, fn)
|
||||
if list(traverse_parent(node, nodes.topic)):
|
||||
# should not expand references in topics
|
||||
pass
|
||||
else:
|
||||
footnote_nodes = self.create_footnote(uri)
|
||||
for i, fn in enumerate(footnote_nodes):
|
||||
node.parent.insert(index + i + 1, fn)
|
||||
|
||||
self.expanded = True
|
||||
self.expanded = True
|
||||
else: # all other true values (b/w compat)
|
||||
textnode = nodes.Text(" (%s)" % uri)
|
||||
node.parent.insert(index + 1, textnode)
|
||||
|
@ -2,6 +2,9 @@
|
||||
test-footenotes
|
||||
===============
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
The section with a reference to [AuthorYear]_
|
||||
=============================================
|
||||
|
||||
|
@ -372,6 +372,13 @@ def test_latex_show_urls_is_inline(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
||||
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
||||
'{\\emph{The section with a reference to \\phantomsection\\label{index:id1}'
|
||||
'{\\hyperref[index:authoryear]{\\emph{{[}AuthorYear{]}}}}}}}' in result)
|
||||
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
|
||||
'\\string-with\\string-a\\string-reference\\string-to]{\\emph{The section '
|
||||
'with a reference to }}}' in result)
|
||||
assert 'First footnote: \\footnote[2]{\nFirst\n}' in result
|
||||
assert 'Second footnote: \\footnote[1]{\nSecond\n}' in result
|
||||
assert '\\href{http://sphinx-doc.org/}{Sphinx} (http://sphinx-doc.org/)' in result
|
||||
@ -398,6 +405,13 @@ def test_latex_show_urls_is_footnote(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
||||
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
||||
'{\\emph{The section with a reference to \\phantomsection\\label{index:id1}'
|
||||
'{\\hyperref[index:authoryear]{\\emph{{[}AuthorYear{]}}}}}}}' in result)
|
||||
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
|
||||
'\\string-with\\string-a\\string-reference\\string-to]{\\emph{The section '
|
||||
'with a reference to }}}' in result)
|
||||
assert 'First footnote: \\footnote[2]{\nFirst\n}' in result
|
||||
assert 'Second footnote: \\footnote[1]{\nSecond\n}' in result
|
||||
assert ('\\href{http://sphinx-doc.org/}{Sphinx}'
|
||||
@ -426,6 +440,13 @@ def test_latex_show_urls_is_no(app, status, warning):
|
||||
print(result)
|
||||
print(status.getvalue())
|
||||
print(warning.getvalue())
|
||||
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
||||
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
||||
'{\\emph{The section with a reference to \\phantomsection\\label{index:id1}'
|
||||
'{\\hyperref[index:authoryear]{\\emph{{[}AuthorYear{]}}}}}}}' in result)
|
||||
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
|
||||
'\\string-with\\string-a\\string-reference\\string-to]{\\emph{The section '
|
||||
'with a reference to }}}' in result)
|
||||
assert 'First footnote: \\footnote[2]{\nFirst\n}' in result
|
||||
assert 'Second footnote: \\footnote[1]{\nSecond\n}' in result
|
||||
assert '\\href{http://sphinx-doc.org/}{Sphinx}' in result
|
||||
|
Loading…
Reference in New Issue
Block a user