mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #2292: Some footnotes disappear from LaTeX output
This commit is contained in:
parent
9b958b6dcc
commit
9ba7cc815c
1
CHANGES
1
CHANGES
@ -8,6 +8,7 @@ Bugs fixed
|
|||||||
* #2295: Avoid mutating dictionary errors while enumerating members in autodoc
|
* #2295: Avoid mutating dictionary errors while enumerating members in autodoc
|
||||||
with Python 3
|
with Python 3
|
||||||
* #2291: Fix pdflatex "Counter too large" error from footnotes inside tables of contents
|
* #2291: Fix pdflatex "Counter too large" error from footnotes inside tables of contents
|
||||||
|
* #2292: Fix some footnotes disappear from LaTeX output
|
||||||
|
|
||||||
|
|
||||||
Release 1.3.5 (released Jan 24, 2016)
|
Release 1.3.5 (released Jan 24, 2016)
|
||||||
|
@ -199,9 +199,14 @@ class ShowUrlsTransform(object):
|
|||||||
def is_auto_footnote(node):
|
def is_auto_footnote(node):
|
||||||
return isinstance(node, nodes.footnote) and node.get('auto')
|
return isinstance(node, nodes.footnote) and node.get('auto')
|
||||||
|
|
||||||
def footnote_ref_by(ids):
|
def footnote_ref_by(node):
|
||||||
|
ids = node['ids']
|
||||||
|
parent = list(traverse_parent(node, (nodes.document, addnodes.start_of_file)))[0]
|
||||||
|
|
||||||
def is_footnote_ref(node):
|
def is_footnote_ref(node):
|
||||||
return isinstance(node, nodes.footnote_reference) and ids[0] == node['refid']
|
return (isinstance(node, nodes.footnote_reference) and
|
||||||
|
ids[0] == node['refid'] and
|
||||||
|
parent in list(traverse_parent(node)))
|
||||||
|
|
||||||
return is_footnote_ref
|
return is_footnote_ref
|
||||||
|
|
||||||
@ -220,7 +225,7 @@ class ShowUrlsTransform(object):
|
|||||||
footnote['names'].remove(old_label)
|
footnote['names'].remove(old_label)
|
||||||
footnote['names'].append(label)
|
footnote['names'].append(label)
|
||||||
|
|
||||||
for footnote_ref in self.document.traverse(footnote_ref_by(footnote['ids'])):
|
for footnote_ref in self.document.traverse(footnote_ref_by(footnote)):
|
||||||
footnote_ref.remove(footnote_ref[0])
|
footnote_ref.remove(footnote_ref[0])
|
||||||
footnote_ref += nodes.Text(label)
|
footnote_ref += nodes.Text(label)
|
||||||
|
|
||||||
|
6
tests/roots/test-footnotes/bar.rst
Normal file
6
tests/roots/test-footnotes/bar.rst
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
bar
|
||||||
|
===
|
||||||
|
|
||||||
|
Same footnote number [1]_ in bar.rst
|
||||||
|
|
||||||
|
.. [1] footnote in bar
|
6
tests/roots/test-footnotes/baz.rst
Normal file
6
tests/roots/test-footnotes/baz.rst
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
baz
|
||||||
|
===
|
||||||
|
|
||||||
|
Auto footnote number [#]_ in baz.rst
|
||||||
|
|
||||||
|
.. [#] footnote in baz
|
@ -2,6 +2,11 @@
|
|||||||
test-footenotes
|
test-footenotes
|
||||||
===============
|
===============
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
|
||||||
|
bar
|
||||||
|
baz
|
||||||
|
|
||||||
.. contents::
|
.. contents::
|
||||||
:local:
|
:local:
|
||||||
|
|
||||||
|
@ -372,6 +372,8 @@ def test_latex_show_urls_is_inline(app, status, warning):
|
|||||||
print(result)
|
print(result)
|
||||||
print(status.getvalue())
|
print(status.getvalue())
|
||||||
print(warning.getvalue())
|
print(warning.getvalue())
|
||||||
|
assert 'Same footnote number \\footnote[1]{\nfootnote in bar\n} in bar.rst' in result
|
||||||
|
assert 'Auto footnote number \\footnote[1]{\nfootnote in baz\n} in baz.rst' in result
|
||||||
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
||||||
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
||||||
'{\\emph{The section with a reference to \\phantomsection\\label{index:id1}'
|
'{\\emph{The section with a reference to \\phantomsection\\label{index:id1}'
|
||||||
@ -405,6 +407,8 @@ def test_latex_show_urls_is_footnote(app, status, warning):
|
|||||||
print(result)
|
print(result)
|
||||||
print(status.getvalue())
|
print(status.getvalue())
|
||||||
print(warning.getvalue())
|
print(warning.getvalue())
|
||||||
|
assert 'Same footnote number \\footnote[1]{\nfootnote in bar\n} in bar.rst' in result
|
||||||
|
assert 'Auto footnote number \\footnote[2]{\nfootnote in baz\n} in baz.rst' in result
|
||||||
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
||||||
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
||||||
'{\\emph{The section with a reference to \\phantomsection\\label{index:id1}'
|
'{\\emph{The section with a reference to \\phantomsection\\label{index:id1}'
|
||||||
@ -412,20 +416,20 @@ def test_latex_show_urls_is_footnote(app, status, warning):
|
|||||||
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
|
assert ('\\phantomsection\\label{index:id27}{\\hyperref[index:the\\string-section'
|
||||||
'\\string-with\\string-a\\string-reference\\string-to]{\\emph{The section '
|
'\\string-with\\string-a\\string-reference\\string-to]{\\emph{The section '
|
||||||
'with a reference to }}}' in result)
|
'with a reference to }}}' in result)
|
||||||
assert 'First footnote: \\footnote[2]{\nFirst\n}' in result
|
assert 'First footnote: \\footnote[3]{\nFirst\n}' in result
|
||||||
assert 'Second footnote: \\footnote[1]{\nSecond\n}' in result
|
assert 'Second footnote: \\footnote[1]{\nSecond\n}' in result
|
||||||
assert ('\\href{http://sphinx-doc.org/}{Sphinx}'
|
assert ('\\href{http://sphinx-doc.org/}{Sphinx}'
|
||||||
'\\footnote[3]{\nhttp://sphinx-doc.org/\n}' in result)
|
'\\footnote[4]{\nhttp://sphinx-doc.org/\n}' in result)
|
||||||
assert 'Third footnote: \\footnote[5]{\nThird\n}' in result
|
assert 'Third footnote: \\footnote[6]{\nThird\n}' in result
|
||||||
assert ('\\href{http://sphinx-doc.org/~test/}{URL including tilde}'
|
assert ('\\href{http://sphinx-doc.org/~test/}{URL including tilde}'
|
||||||
'\\footnote[4]{\nhttp://sphinx-doc.org/\\textasciitilde{}test/\n}' in result)
|
'\\footnote[5]{\nhttp://sphinx-doc.org/\\textasciitilde{}test/\n}' in result)
|
||||||
assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term}\\protect\\footnotemark[7]}] '
|
assert ('\\item[{\\href{http://sphinx-doc.org/}{URL in term}\\protect\\footnotemark[8]}] '
|
||||||
'\\leavevmode\\footnotetext[7]{\nhttp://sphinx-doc.org/\n}\nDescription' in result)
|
|
||||||
assert ('\\item[{Footnote in term \\protect\\footnotemark[9]}] '
|
|
||||||
'\\leavevmode\\footnotetext[9]{\nFootnote in term\n}\nDescription' in result)
|
|
||||||
assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist}\\protect'
|
|
||||||
'\\footnotemark[8]}] '
|
|
||||||
'\\leavevmode\\footnotetext[8]{\nhttp://sphinx-doc.org/\n}\nDescription' in result)
|
'\\leavevmode\\footnotetext[8]{\nhttp://sphinx-doc.org/\n}\nDescription' in result)
|
||||||
|
assert ('\\item[{Footnote in term \\protect\\footnotemark[10]}] '
|
||||||
|
'\\leavevmode\\footnotetext[10]{\nFootnote in term\n}\nDescription' in result)
|
||||||
|
assert ('\\item[{\\href{http://sphinx-doc.org/}{Term in deflist}\\protect'
|
||||||
|
'\\footnotemark[9]}] '
|
||||||
|
'\\leavevmode\\footnotetext[9]{\nhttp://sphinx-doc.org/\n}\nDescription' in result)
|
||||||
assert ('\\href{https://github.com/sphinx-doc/sphinx}'
|
assert ('\\href{https://github.com/sphinx-doc/sphinx}'
|
||||||
'{https://github.com/sphinx-doc/sphinx}\n' in result)
|
'{https://github.com/sphinx-doc/sphinx}\n' in result)
|
||||||
assert ('\\href{mailto:sphinx-dev@googlegroups.com}'
|
assert ('\\href{mailto:sphinx-dev@googlegroups.com}'
|
||||||
@ -440,6 +444,8 @@ def test_latex_show_urls_is_no(app, status, warning):
|
|||||||
print(result)
|
print(result)
|
||||||
print(status.getvalue())
|
print(status.getvalue())
|
||||||
print(warning.getvalue())
|
print(warning.getvalue())
|
||||||
|
assert 'Same footnote number \\footnote[1]{\nfootnote in bar\n} in bar.rst' in result
|
||||||
|
assert 'Auto footnote number \\footnote[1]{\nfootnote in baz\n} in baz.rst' in result
|
||||||
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
assert ('\\phantomsection\\label{index:id26}{\\hyperref[index:the\\string-section'
|
||||||
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
'\\string-with\\string-a\\string-reference\\string-to\\string-authoryear]'
|
||||||
'{\\emph{The section with a reference to \\phantomsection\\label{index:id1}'
|
'{\\emph{The section with a reference to \\phantomsection\\label{index:id1}'
|
||||||
|
Loading…
Reference in New Issue
Block a user