summaryrefslogtreecommitdiff
path: root/macros/latex-dev/required/latex-lab/latex-lab-firstaid.dtx
blob: a50b36783797338e2e08ff9287f715b79c845fd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
% \iffalse meta-comment
%
%% File: latex-lab-firstaid.dtx (C) Copyright 2023 LaTeX Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version.  The latest version
% of this license is in the file
%
%    https://www.latex-project.org/lppl.txt
%
%
% The development version of the bundle can be found below
%
%    https://github.com/latex3/latex2e/required/latex-lab
%
% for those people who are interested or want to report an issue.
%
\def\ltlabfirstaiddate{2024-01-21}
\def\ltlabfirstaidversion{0.85b}
%<*driver>
\documentclass{l3doc}
\EnableCrossrefs
\CodelineIndex
\begin{document}
  \DocInput{latex-lab-firstaid.dtx}
\end{document}
%</driver>
%
% \fi
%
% \title{The \textsf{latex-lab-firstaid} package\\
% Temporary patches to external packages needed for the tagging project}
% \author{\LaTeX{} Project\thanks{Initial implementation done by Ulrike Fischer}}
% \date{v\ltlabfirstaidversion\ \ltlabfirstaiddate}
%
% \maketitle
%
% \newcommand{\xt}[1]{\textsl{\textsf{#1}}}
% \newcommand{\TODO}[1]{\textbf{[TODO:} #1\textbf{]}}
% \newcommand{\docclass}{document class \marginpar{\raggedright document class
% customizations}}
%
% \providecommand\hook[1]{\texttt{#1}}
%
% \begin{abstract}
% \end{abstract}
%
% \section{Introduction}
%
% The followings contains small temporary changes to external packages to avoid
% errors with the new tagging code. 
% 
% Similar to the main firstaid package the goal is to remove the 
% patches once the packages have been updated.

% \section{Implementation}
%    \begin{macrocode}
%<*package>
%<@@=tag>
%    \end{macrocode}
%    \begin{macrocode}
\ProvidesPackage {latex-lab-testphase-firstaid} [%
   \ltlabfirstaiddate\space v\ltlabfirstaiddate\space
   Temporary patches to external packages needed for the tagging project]
%    \end{macrocode}
% \subsection{ams classes}
% The amsart and amsbook classes do not use \cs{@author} to store the author list
% but a command \cs{authors}. To be able to nevertheless use the authors in the
% xmp-metadata we map \cs{@author} to this new command. 
% 
%    \begin{macrocode}
\AddToHook{class/amsart/after}
 {\def\@author{\authors}}
\AddToHook{class/amsbook/after}
 {\def\@author{\authors}}
%    \end{macrocode}
% \subsection{blindtext}
% The blindtext package generates lists with nested \cs{loop} command.
% The inner loop introduces a group around the list which error when lists are tagged
% as \cs{@doendpe} is lost.
%    \begin{macrocode}
\AddToHook{file/blindtext.sty/after}[latex-lab-firstaid]{%
  \FirstAidNeededT{blindtext}{sty}{\blindfiledate\space\blindfileversion\space%
                 blindtext-Package}%
   {%
    \renewcommand{\blind@items}{%
       \setcounter{blind@listcount}{1}%
      \loop
      \ifblind@optional
        \ifblind@long
          \item[\blindtext@countitem] \blindtext@text
        \else
          \item[\blindtext@count] \blindtext@item
        \fi
        \else % \blind@optionalfalse
          \ifblind@long
            \item \blindtext@text
          \else
            \item \blindtext@countitem
          \fi
        \fi % \ifblind@optional
        {%
          \loop
          \ifnum\value{blindlistlevel}>\value{blindlist@level}%
            \stepcounter{blind@levelcount}%
            \blind@list[\value{blindlist}]\relax
            \addtocounter{blind@levelcount}{-1}%
            \setcounter{blind@listcount}{1}%
          \repeat
        \expandafter}\if@endpe\@doendpe\fi % <----------changed
      \ifnum\value{blind@listcount}<\value{blindlist}%
        \stepcounter{blind@listcount}%
      \repeat
    }
   }%
 }
%    \end{macrocode}
% \subsection{cleveref}
% The cleveref package redefines \cs{@makefntext} and this means that the patches in
% the new footnote code fails. We use a hook instead
%    \begin{macrocode}
\AddToHook{package/cleveref/after} 
 {
   \let\@makefntext\cref@old@makefntext
   \AddToHook{cmd/@makefntext/before}{%
    \cref@constructprefix{footnote}{\cref@result}%
    \protected@edef\cref@currentlabel{%
     [footnote][\arabic{footnote}][\cref@result]%
    \p@footnote\@thefnmark}}
%    \end{macrocode}
% The second problem is that it redefines \cs{refstepcounter} to use an argument.
% In itself this isn't a problem but as the new definition doesn't grab the arguments
% directly it fails over the generic hook inserted at the end of the definition
%    \begin{macrocode}
   \RenewDocumentCommand\refstepcounter{om}{%
     \IfNoValueTF{#1}%
      {\refstepcounter@noarg{#2}}%
      {\refstepcounter@optarg[#1]{#2}}%
    }%
 }   
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%    \begin{macrocode}
%<*latex-lab>
\ProvidesFile{firstaid-latex-lab-testphase.ltx}
        [\ltlabfirstaiddate\space v\ltlabfirstaidversion\space
         latex-lab wrapper firstaid]

\RequirePackage{latex-lab-testphase-firstaid}

%</latex-lab>
%    \end{macrocode}