mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Use \thesphinxscope mark-up (shorter, and may help trick for page scope)
This commit is contained in:
parent
c55216858e
commit
6275a7756f
@ -176,7 +176,7 @@
|
|||||||
\@footnotemark
|
\@footnotemark
|
||||||
% Sphinx addition: store internal hyperref anchor reference to allow
|
% Sphinx addition: store internal hyperref anchor reference to allow
|
||||||
% multiple clickable reference to same numbered footnote
|
% multiple clickable reference to same numbered footnote
|
||||||
\expandafter\xdef\csname FNH!\number\value{sphinxscope}!#1\endcsname{\Hy@footnote@currentHref}%
|
\expandafter\xdef\csname FNH!\thesphinxscope!#1\endcsname{\Hy@footnote@currentHref}%
|
||||||
\def\FNH@endfntext@fntext{\@footnotetext}%
|
\def\FNH@endfntext@fntext{\@footnotetext}%
|
||||||
\FNH@startfntext
|
\FNH@startfntext
|
||||||
}%
|
}%
|
||||||
@ -345,18 +345,18 @@
|
|||||||
% this <number> as argument and taking into account current <scope>.
|
% this <number> as argument and taking into account current <scope>.
|
||||||
\protected\def\sphinxfootref#1{% #1 always explicit number in Sphinx usage
|
\protected\def\sphinxfootref#1{% #1 always explicit number in Sphinx usage
|
||||||
\spx@opt@BeforeFootnote
|
\spx@opt@BeforeFootnote
|
||||||
\ifcsname FNH!\number\value{sphinxscope}!#1\endcsname
|
\ifcsname FNH!\thesphinxscope!#1\endcsname
|
||||||
\gdef\@thefnmark{#1}% \@thefnmark always redefined globally by latex
|
\gdef\@thefnmark{#1}% \@thefnmark always redefined globally by latex
|
||||||
\let\spx@saved@makefnmark\@makefnmark
|
\let\spx@saved@makefnmark\@makefnmark
|
||||||
\edef\@makefnmark{% we pre-expand the sphinxscope value, to be safe
|
\edef\@makefnmark{% we pre-expand the sphinxscope value, to be safe
|
||||||
\noexpand\hyper@linkstart{link}{\@nameuse{FNH!\number\value{sphinxscope}!#1}}%
|
\noexpand\hyper@linkstart{link}{\@nameuse{FNH!\thesphinxscope!#1}}%
|
||||||
\noexpand\spx@saved@makefnmark
|
\noexpand\spx@saved@makefnmark
|
||||||
\noexpand\hyper@linkend
|
\noexpand\hyper@linkend
|
||||||
}%
|
}%
|
||||||
\H@@footnotemark
|
\H@@footnotemark
|
||||||
\let\@makefnmark\spx@saved@makefnmark
|
\let\@makefnmark\spx@saved@makefnmark
|
||||||
\else
|
\else
|
||||||
\xdef\@thefnmark{\noexpand\ref{\number\value{sphinxscope}.#1}}% #1 = number
|
\xdef\@thefnmark{\noexpand\ref{\thesphinxscope.#1}}% #1 = number
|
||||||
\H@@footnotemark
|
\H@@footnotemark
|
||||||
\fi
|
\fi
|
||||||
}%
|
}%
|
||||||
|
@ -1738,7 +1738,7 @@ class LaTeXTranslator(SphinxTranslator):
|
|||||||
def visit_footnotetext(self, node: Element) -> None:
|
def visit_footnotetext(self, node: Element) -> None:
|
||||||
label = cast(nodes.label, node[0])
|
label = cast(nodes.label, node[0])
|
||||||
self.body.append('%%\n\\begin{footnotetext}[%s]'
|
self.body.append('%%\n\\begin{footnotetext}[%s]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.%s}%%\n'
|
'\\phantomsection\\label{\\thesphinxscope.%s}%%\n'
|
||||||
'\\sphinxAtStartFootnote\n' % (label.astext(), label.astext()))
|
'\\sphinxAtStartFootnote\n' % (label.astext(), label.astext()))
|
||||||
|
|
||||||
def depart_footnotetext(self, node: Element) -> None:
|
def depart_footnotetext(self, node: Element) -> None:
|
||||||
|
@ -733,11 +733,11 @@ def test_footnote(app, status, warning):
|
|||||||
assert ('\\bibitem[bar]{footnote:bar}\n\\sphinxAtStartPar\ncite\n') in result
|
assert ('\\bibitem[bar]{footnote:bar}\n\\sphinxAtStartPar\ncite\n') in result
|
||||||
assert '\\sphinxcaption{Table caption \\sphinxfootnotemark[4]' in result
|
assert '\\sphinxcaption{Table caption \\sphinxfootnotemark[4]' in result
|
||||||
assert ('\\hline%\n\\begin{footnotetext}[4]'
|
assert ('\\hline%\n\\begin{footnotetext}[4]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.4}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.4}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'footnote in table caption\n%\n\\end{footnotetext}\\ignorespaces %\n'
|
'footnote in table caption\n%\n\\end{footnotetext}\\ignorespaces %\n'
|
||||||
'\\begin{footnotetext}[5]'
|
'\\begin{footnotetext}[5]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.5}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.5}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'footnote in table header\n%\n\\end{footnotetext}\\ignorespaces '
|
'footnote in table header\n%\n\\end{footnotetext}\\ignorespaces '
|
||||||
'\n\\sphinxAtStartPar\n'
|
'\n\\sphinxAtStartPar\n'
|
||||||
@ -765,13 +765,13 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
|
|||||||
assert ('\\chapter{The section with a reference to \\sphinxfootnotemark[5]}\n'
|
assert ('\\chapter{The section with a reference to \\sphinxfootnotemark[5]}\n'
|
||||||
'\\label{\\detokenize{index:the-section-with-a-reference-to}}'
|
'\\label{\\detokenize{index:the-section-with-a-reference-to}}'
|
||||||
'%\n\\begin{footnotetext}[5]'
|
'%\n\\begin{footnotetext}[5]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.5}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.5}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'Footnote in section\n%\n\\end{footnotetext}') in result
|
'Footnote in section\n%\n\\end{footnotetext}') in result
|
||||||
assert ('\\caption{This is the figure caption with a footnote to '
|
assert ('\\caption{This is the figure caption with a footnote to '
|
||||||
'\\sphinxfootnotemark[7].}\\label{\\detokenize{index:id29}}\\end{figure}\n'
|
'\\sphinxfootnotemark[7].}\\label{\\detokenize{index:id29}}\\end{figure}\n'
|
||||||
'%\n\\begin{footnotetext}[7]'
|
'%\n\\begin{footnotetext}[7]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.7}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.7}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'Footnote in caption\n%\n\\end{footnotetext}') in result
|
'Footnote in caption\n%\n\\end{footnotetext}') in result
|
||||||
assert ('\\sphinxcaption{footnote \\sphinxfootnotemark[8] in '
|
assert ('\\sphinxcaption{footnote \\sphinxfootnotemark[8] in '
|
||||||
@ -779,11 +779,11 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
|
|||||||
assert ('\\caption{footnote \\sphinxfootnotemark[9] '
|
assert ('\\caption{footnote \\sphinxfootnotemark[9] '
|
||||||
'in caption \\sphinxfootnotemark[10] of longtable\\strut}') in result
|
'in caption \\sphinxfootnotemark[10] of longtable\\strut}') in result
|
||||||
assert ('\\endlastfoot\n%\n\\begin{footnotetext}[9]'
|
assert ('\\endlastfoot\n%\n\\begin{footnotetext}[9]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.9}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.9}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'Foot note in longtable\n%\n\\end{footnotetext}\\ignorespaces %\n'
|
'Foot note in longtable\n%\n\\end{footnotetext}\\ignorespaces %\n'
|
||||||
'\\begin{footnotetext}[10]'
|
'\\begin{footnotetext}[10]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.10}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.10}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'Second footnote in caption of longtable\n') in result
|
'Second footnote in caption of longtable\n') in result
|
||||||
assert ('This is a reference to the code\\sphinxhyphen{}block in the footnote:\n'
|
assert ('This is a reference to the code\\sphinxhyphen{}block in the footnote:\n'
|
||||||
@ -825,7 +825,7 @@ def test_latex_show_urls_is_inline(app, status, warning):
|
|||||||
assert ('Third footnote: %\n\\begin{footnote}[3]\\sphinxAtStartFootnote\n'
|
assert ('Third footnote: %\n\\begin{footnote}[3]\\sphinxAtStartFootnote\n'
|
||||||
'Third \\sphinxfootnotemark[4]\n%\n\\end{footnote}%\n'
|
'Third \\sphinxfootnotemark[4]\n%\n\\end{footnote}%\n'
|
||||||
'\\begin{footnotetext}[4]'
|
'\\begin{footnotetext}[4]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.4}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.4}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'Footnote inside footnote\n%\n\\end{footnotetext}\\ignorespaces') in result
|
'Footnote inside footnote\n%\n\\end{footnotetext}\\ignorespaces') in result
|
||||||
assert ('\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde} '
|
assert ('\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde} '
|
||||||
@ -835,7 +835,7 @@ def test_latex_show_urls_is_inline(app, status, warning):
|
|||||||
'\\leavevmode\n\\sphinxAtStartPar\nDescription' in result)
|
'\\leavevmode\n\\sphinxAtStartPar\nDescription' in result)
|
||||||
assert ('\\item[{Footnote in term \\sphinxfootnotemark[6]}] '
|
assert ('\\item[{Footnote in term \\sphinxfootnotemark[6]}] '
|
||||||
'\\leavevmode%\n\\begin{footnotetext}[6]'
|
'\\leavevmode%\n\\begin{footnotetext}[6]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.6}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.6}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces '
|
'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces '
|
||||||
'\n\\sphinxAtStartPar\nDescription') in result
|
'\n\\sphinxAtStartPar\nDescription') in result
|
||||||
@ -878,7 +878,7 @@ def test_latex_show_urls_is_footnote(app, status, warning):
|
|||||||
assert ('Third footnote: %\n\\begin{footnote}[6]\\sphinxAtStartFootnote\n'
|
assert ('Third footnote: %\n\\begin{footnote}[6]\\sphinxAtStartFootnote\n'
|
||||||
'Third \\sphinxfootnotemark[7]\n%\n\\end{footnote}%\n'
|
'Third \\sphinxfootnotemark[7]\n%\n\\end{footnote}%\n'
|
||||||
'\\begin{footnotetext}[7]'
|
'\\begin{footnotetext}[7]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.7}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.7}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'Footnote inside footnote\n%\n'
|
'Footnote inside footnote\n%\n'
|
||||||
'\\end{footnotetext}\\ignorespaces') in result
|
'\\end{footnotetext}\\ignorespaces') in result
|
||||||
@ -888,20 +888,20 @@ def test_latex_show_urls_is_footnote(app, status, warning):
|
|||||||
assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}'
|
assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}'
|
||||||
'{URL in term}\\sphinxfootnotemark[9]}] '
|
'{URL in term}\\sphinxfootnotemark[9]}] '
|
||||||
'\\leavevmode%\n\\begin{footnotetext}[9]'
|
'\\leavevmode%\n\\begin{footnotetext}[9]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.9}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.9}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n'
|
'\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n'
|
||||||
'\\end{footnotetext}\\ignorespaces \n\\sphinxAtStartPar\nDescription') in result
|
'\\end{footnotetext}\\ignorespaces \n\\sphinxAtStartPar\nDescription') in result
|
||||||
assert ('\\item[{Footnote in term \\sphinxfootnotemark[11]}] '
|
assert ('\\item[{Footnote in term \\sphinxfootnotemark[11]}] '
|
||||||
'\\leavevmode%\n\\begin{footnotetext}[11]'
|
'\\leavevmode%\n\\begin{footnotetext}[11]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.11}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.11}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces '
|
'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces '
|
||||||
'\n\\sphinxAtStartPar\nDescription') in result
|
'\n\\sphinxAtStartPar\nDescription') in result
|
||||||
assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist}'
|
assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist}'
|
||||||
'\\sphinxfootnotemark[10]}] '
|
'\\sphinxfootnotemark[10]}] '
|
||||||
'\\leavevmode%\n\\begin{footnotetext}[10]'
|
'\\leavevmode%\n\\begin{footnotetext}[10]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.10}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.10}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n'
|
'\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n'
|
||||||
'\\end{footnotetext}\\ignorespaces \n\\sphinxAtStartPar\nDescription') in result
|
'\\end{footnotetext}\\ignorespaces \n\\sphinxAtStartPar\nDescription') in result
|
||||||
@ -939,7 +939,7 @@ def test_latex_show_urls_is_no(app, status, warning):
|
|||||||
assert ('Third footnote: %\n\\begin{footnote}[3]\\sphinxAtStartFootnote\n'
|
assert ('Third footnote: %\n\\begin{footnote}[3]\\sphinxAtStartFootnote\n'
|
||||||
'Third \\sphinxfootnotemark[4]\n%\n\\end{footnote}%\n'
|
'Third \\sphinxfootnotemark[4]\n%\n\\end{footnote}%\n'
|
||||||
'\\begin{footnotetext}[4]'
|
'\\begin{footnotetext}[4]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.4}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.4}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'Footnote inside footnote\n%\n\\end{footnotetext}\\ignorespaces') in result
|
'Footnote inside footnote\n%\n\\end{footnotetext}\\ignorespaces') in result
|
||||||
assert '\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde}' in result
|
assert '\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde}' in result
|
||||||
@ -947,7 +947,7 @@ def test_latex_show_urls_is_no(app, status, warning):
|
|||||||
'\\leavevmode\n\\sphinxAtStartPar\nDescription') in result
|
'\\leavevmode\n\\sphinxAtStartPar\nDescription') in result
|
||||||
assert ('\\item[{Footnote in term \\sphinxfootnotemark[6]}] '
|
assert ('\\item[{Footnote in term \\sphinxfootnotemark[6]}] '
|
||||||
'\\leavevmode%\n\\begin{footnotetext}[6]'
|
'\\leavevmode%\n\\begin{footnotetext}[6]'
|
||||||
'\\phantomsection\\label{\\number\\value{sphinxscope}.6}%\n'
|
'\\phantomsection\\label{\\thesphinxscope.6}%\n'
|
||||||
'\\sphinxAtStartFootnote\n'
|
'\\sphinxAtStartFootnote\n'
|
||||||
'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces '
|
'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces '
|
||||||
'\n\\sphinxAtStartPar\nDescription') in result
|
'\n\\sphinxAtStartPar\nDescription') in result
|
||||||
|
Loading…
Reference in New Issue
Block a user