Debian Codegraph @

texmf-dist/tex/generic/tex4ht/xr-hooks.4ht

raw
1 % xr-hooks.4ht (2025-08-01-14:51), generated from tex4ht-4ht.tex
2 % Copyright 2020-2025 TeX Users Group
3 % Copyright 2009-2025 TeX Users Group
4 %
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either
7 % version 1.3c of this license or (at your option) any
8 % later version. The latest version of this license is in
9 % https://www.latex-project.org/lppl.txt
10 % and version 1.3c or later is part of all distributions
11 % of LaTeX version 2005/12/01 or later.
12 %
13 % This work has the LPPL maintenance status "maintained".
14 %
15 % The Current Maintainer of this work
16 % is the TeX4ht Project <https://tug.org/tex4ht>.
17 %
18 % If you modify this program, changing the
19 % version identification would be appreciated.
20 \immediate\write-1{version 2025-08-01-14:51}
21
22 \ExplSyntaxOn
23 % detect )F[number]F- using l3regex
24 \regex_new:N \l_xref_filename
25 \regex_set:Nn \l_xref_filename {F\d+F}
26 % save all filenames declared in the xref file
27 \def\:extract:filename:from:xref#1#2#3{%
28 \regex_if_match:NnTF \l_xref_filename {#1}{%
29 \filename@parse{#2}
30 \expandafter\xdef\csname xr:dir:\filename@base\endcsname{\:tempa}
31 }{}
32 }
33 \def\:declare:xref:files#1#2{
34 \begingroup
35 % we need to find filenames of cutfiles
36 % we will use \filename@parse again, so we need to save the directory name
37 \edef\:tempa{#2}%
38 \def\:CrossWord##1##2##3{\:extract:filename:from:xref{##1}{##2}{\:tempa}}%
39 \catcode`\:=11% : is not letter at this moment
40 \InputIfFileExists{#1.xref}{}{}% load saved cross-references
41 \endgroup
42 }
43
44 \ExplSyntaxOff
45
46 \:AtEndOfPackage{\let\XR:\XR@
47 \def\XR@[#1][#2]#3{%
48 % save directory for the linked file
49 \filename@parse{#3}%
50 % \filename@base is filename, \filename@area directory
51 \expandafter\xdef\csname xr:dir:\filename@base\endcsname{\filename@area}%
52 \:declare:xref:files{\filename@area\filename@base}{\filename@area}% declare directory for cut files
53 \Configure{AtBeginDocument}{\XR:[#1][#2]{#3}}{}%
54 }%
55 }
56
57