Skip to content

Commit 39e4ea2

Browse files
committed
Sync with footnotehyper 1.1d
This fixes a problem introduced at 1.1b which could case latex build crash in case of extra user packages. It also improves compatibility with babel + french.
1 parent 1cf915f commit 39e4ea2

File tree

1 file changed

+61
-23
lines changed

1 file changed

+61
-23
lines changed

sphinx/texinputs/footnotehyper-sphinx.sty

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
\NeedsTeXFormat{LaTeX2e}
22
\ProvidesPackage{footnotehyper-sphinx}%
3-
[2021/01/29 v1.1c hyperref aware footnote.sty for sphinx (JFB)]
3+
[2021/02/04 v1.1d hyperref aware footnote.sty for sphinx (JFB)]
44
%%
55
%% Package: footnotehyper-sphinx
6-
%% Version: based on footnotehyper.sty 2021/01/29 v1.1c
6+
%% Version: based on footnotehyper.sty 2021/02/04 v1.1d
77
%% as available at https://www.ctan.org/pkg/footnotehyper
88
%% License: the one applying to Sphinx
99
%%
@@ -17,6 +17,7 @@
1717
%% 4. macro definition \sphinxfootnotemark,
1818
%% 5. macro definition \sphinxlongtablepatch
1919
%% 6. replaced some \undefined by \@undefined
20+
\newif\iffootnotehyperparse\footnotehyperparsetrue
2021
\DeclareOption*{\PackageWarning{footnotehyper-sphinx}{Option `\CurrentOption' is unknown}}%
2122
\ProcessOptions\relax
2223
\newbox\FNH@notes
@@ -218,38 +219,76 @@
218219
\FNH@endfntext@fntext {\unvbox\z@}%
219220
\endgroup
220221
}%
221-
\AtBeginDocument{%
222-
\let\FNH@@makefntext\@makefntext
223-
\ifx\@makefntextFB\@undefined
224-
\expandafter\@gobble\else\expandafter\@firstofone\fi
225-
{\ifFBFrenchFootnotes \let\FNH@@makefntext\@makefntextFB \else
226-
\let\FNH@@makefntext\@makefntextORI\fi}%
227-
\expandafter\FNH@check@a\FNH@@makefntext{1.2!3?4,}%
228-
\FNH@@@1.2!3?4,\FNH@@@\relax
222+
\let\FNH@prefntext\@empty
223+
\let\FNH@postfntext\@empty
224+
\AtBeginDocument{\iffootnotehyperparse\expandafter\FNH@check\fi}%
225+
\def\FNH@safeif#1{%
226+
\iftrue\csname if#1\endcsname\csname fi\endcsname\expandafter\@firstoftwo
227+
\else\csname fi\endcsname\expandafter\@secondoftwo
228+
\fi
229+
}%
230+
\def\FNH@check{%
231+
\ifx\@makefntextFB\@undefined\expandafter\FNH@check@
232+
\else\expandafter\FNH@frenchb@
233+
\fi
234+
}%
235+
\def\FNH@frenchb@{%
236+
\def\FNH@prefntext{%
237+
\localleftbox{}%
238+
\let\FBeverypar@save\FBeverypar@quote
239+
\let\FBeverypar@quote\relax
240+
\FNH@safeif{FB@koma}%
241+
{\FNH@safeif{FBFrenchFootnotes}%
242+
{\ifx\footnote\thanks
243+
\let\@@makefnmark\@@makefnmarkTH
244+
\@makefntextTH{} % space as in french.ldf
245+
\else
246+
\let\@@makefnmark\@@makefnmarkFB
247+
\@makefntextFB{} % space as in french.ldf
248+
\fi
249+
}{\let\@@makefnmark\@@makefnmarkORI
250+
\@makefntextORI{}% no space as in french.ldf
251+
}%
252+
}%
253+
{\FNH@safeif{FBFrenchFootnotes}%
254+
{\@makefntextFB{}}%
255+
{\@makefntextORI{}}%
256+
}%
257+
}%
258+
\def\FNH@postfntext{%
259+
\let\FBeverypar@quote\FBeverypar@save
260+
\localleftbox{\FBeveryline@quote}%
261+
}%
262+
}%
263+
\def\FNH@check@{%
264+
\expandafter\FNH@check@a\@makefntext{1.2!3?4,}%
265+
\FNH@@@1.2!3?4,\FNH@@@\relax
229266
}%
230267
\long\def\FNH@check@a #11.2!3?4,#2\FNH@@@#3{%
231-
\ifx\relax#3\FNH@bad@makefntext@alert
268+
\ifx\relax#3\expandafter\FNH@checkagain@
232269
\else
233-
\edef\FNH@restore@{\catcode`\noexpand\@\the\catcode`\@\relax}%
234-
\makeatletter
235-
\ifx\@makefntextFB\@undefined
236-
\expandafter\@gobble\else\expandafter\@firstofone\fi
237-
{\@ifclassloaded{memoir}%
238-
{\ifFBFrenchFootnotes\expandafter\@gobble\fi}%
239-
{}}%
240-
\@secondoftwo
241-
\scantokens{\def\FNH@prefntext{#1}\def\FNH@postfntext{#2}}%
242-
\FNH@restore@
270+
\def\FNH@prefntext{#1}\def\FNH@postfntext{#2}%
243271
\expandafter\FNH@check@b
244272
\fi
245273
}%
274+
\def\FNH@checkagain@{%
275+
\expandafter\FNH@checkagain@a
276+
\detokenize\expandafter{\@makefntext{1.2!3?4,}}\relax\FNH@@@
277+
}%
278+
\edef\FNH@temp{\noexpand\FNH@checkagain@a ##1\string{1.2!3?4,\string}}%
279+
\expandafter\def\FNH@temp#2#3\FNH@@@{%
280+
\ifx\relax#2%
281+
\def\FNH@prefntext{\@makefntext{}}%
282+
\else\FNH@bad@makefntext@alert
283+
\fi
284+
}%
246285
\def\FNH@check@b #1\relax{%
247286
\expandafter\expandafter\expandafter\FNH@check@c
248287
\expandafter\meaning\expandafter\FNH@prefntext
249288
\meaning\FNH@postfntext1.2!3?4,\FNH@check@c\relax
250289
}%
251290
\def\FNH@check@c #11.2!3?4,#2#3\relax{%
252-
\ifx\FNH@check@c#2\expandafter\@gobble\fi\FNH@bad@makefntext@alert
291+
\ifx\FNH@check@c#2\else\FNH@bad@makefntext@alert\fi
253292
}%
254293
% slight reformulation for Sphinx
255294
\def\FNH@bad@makefntext@alert{%
@@ -283,7 +322,6 @@
283322
\noexpand\if@endpe\noexpand\@endpetrue\noexpand\fi
284323
}%
285324
}%
286-
% end of footnotehyper 2017/02/16 v0.99
287325
% some extras for Sphinx :
288326
% \sphinxfootnotemark: usable in section titles and silently removed from TOCs.
289327
\def\sphinxfootnotemark [#1]%

0 commit comments

Comments
 (0)