|
1 | 1 | \NeedsTeXFormat{LaTeX2e} |
2 | 2 | \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)] |
4 | 4 | %% |
5 | 5 | %% 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 |
7 | 7 | %% as available at https://www.ctan.org/pkg/footnotehyper |
8 | 8 | %% License: the one applying to Sphinx |
9 | 9 | %% |
|
17 | 17 | %% 4. macro definition \sphinxfootnotemark, |
18 | 18 | %% 5. macro definition \sphinxlongtablepatch |
19 | 19 | %% 6. replaced some \undefined by \@undefined |
| 20 | +\newif\iffootnotehyperparse\footnotehyperparsetrue |
20 | 21 | \DeclareOption*{\PackageWarning{footnotehyper-sphinx}{Option `\CurrentOption' is unknown}}% |
21 | 22 | \ProcessOptions\relax |
22 | 23 | \newbox\FNH@notes |
|
218 | 219 | \FNH@endfntext@fntext {\unvbox\z@}% |
219 | 220 | \endgroup |
220 | 221 | }% |
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 |
229 | 266 | }% |
230 | 267 | \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@ |
232 | 269 | \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}% |
243 | 271 | \expandafter\FNH@check@b |
244 | 272 | \fi |
245 | 273 | }% |
| 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 | +}% |
246 | 285 | \def\FNH@check@b #1\relax{% |
247 | 286 | \expandafter\expandafter\expandafter\FNH@check@c |
248 | 287 | \expandafter\meaning\expandafter\FNH@prefntext |
249 | 288 | \meaning\FNH@postfntext1.2!3?4,\FNH@check@c\relax |
250 | 289 | }% |
251 | 290 | \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 |
253 | 292 | }% |
254 | 293 | % slight reformulation for Sphinx |
255 | 294 | \def\FNH@bad@makefntext@alert{% |
|
283 | 322 | \noexpand\if@endpe\noexpand\@endpetrue\noexpand\fi |
284 | 323 | }% |
285 | 324 | }% |
286 | | -% end of footnotehyper 2017/02/16 v0.99 |
287 | 325 | % some extras for Sphinx : |
288 | 326 | % \sphinxfootnotemark: usable in section titles and silently removed from TOCs. |
289 | 327 | \def\sphinxfootnotemark [#1]% |
|
0 commit comments