| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: tagpdf-user.dtx |
| 4 |
% |
| 5 |
% Copyright (C) 2019-2026 Ulrike Fischer |
| 6 |
% |
| 7 |
% It may be distributed and/or modified under the conditions of the |
| 8 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 9 |
% license or (at your option) any later version. The latest version |
| 10 |
% of this license is in the file |
| 11 |
% |
| 12 |
% https://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
% This file is part of the "tagpdf bundle" (The Work in LPPL) |
| 15 |
% and all files in that bundle must be distributed together. |
| 16 |
% |
| 17 |
% ----------------------------------------------------------------------- |
| 18 |
% |
| 19 |
% The development version of the bundle can be found at |
| 20 |
% |
| 21 |
% https://github.com/latex3/tagpdf |
| 22 |
% |
| 23 |
% for those people who are interested. |
| 24 |
%<*driver> |
| 25 |
\DocumentMetadata{tagging=on} |
| 26 |
\documentclass{l3in2edoc} |
| 27 |
\usepackage{array,booktabs,caption} |
| 28 |
\hypersetup{pdfauthor=Ulrike Fischer, |
| 29 |
pdftitle=tagpdf-user module (tagpdf)} |
| 30 |
\begin{document} |
| 31 |
\DocInput{\jobname.dtx} |
| 32 |
\end{document} |
| 33 |
%</driver> |
| 34 |
% \fi |
| 35 |
% \title{^^A |
| 36 |
% The \pkg{tagpdf-user} module\\ |
| 37 |
% Code related to \LaTeX2e user commands and document commands ^^A |
| 38 |
% } |
| 39 |
% |
| 40 |
% \author{^^A |
| 41 |
% Ulrike Fischer\thanks |
| 42 |
% {^^A |
| 43 |
% E-mail: |
| 44 |
% \href{mailto:[email protected]} |
| 45 |
% {[email protected]}^^A |
| 46 |
% }^^A |
| 47 |
% } |
| 48 |
% |
| 49 |
% \date{Version 1.0c, released 2026-05-17} |
| 50 |
% \maketitle |
| 51 |
% \begin{documentation} |
| 52 |
% \section{Setup commands} |
| 53 |
% \begin{function}{\tagpdfsetup} |
| 54 |
% \begin{syntax} |
| 55 |
% \cs{tagpdfsetup}\Arg{key val list} |
| 56 |
% \end{syntax} |
| 57 |
% This is the main setup command to adapt the behaviour of tagpdf. |
| 58 |
% It can be used in the preamble and in the document (but not all keys make sense there). |
| 59 |
% \end{function} |
| 60 |
% |
| 61 |
% \begin{function}{activate (setup-key)} |
| 62 |
% And additional setup key which combine the other activate keys |
| 63 |
% |activate/mc|, |activate/tree|, |activate/struct| and additionally |
| 64 |
% adds a document structure. |
| 65 |
% \end{function} |
| 66 |
% |
| 67 |
% |
| 68 |
% \section{Commands related to mc-chunks} |
| 69 |
% \begin{function}{\tagmcbegin, \tagmcend,\tagmcuse} |
| 70 |
% \begin{syntax} |
| 71 |
% \cs{tagmcbegin}\Arg{key-val}\\ |
| 72 |
% \cs{tagmcend}\\ |
| 73 |
% \cs{tagmcuse}\Arg{label} |
| 74 |
% \end{syntax} |
| 75 |
% These are wrappers around |\tag_mc_begin:n|, |\tag_mc_end:| and |\tag_mc_use:n|. |
| 76 |
% The commands and their argument are documentated in the \pkg{tagpdf-mc} module. |
| 77 |
% In difference to the expl3 commands, \cs{tagmcbegin} issues also an \cs{ignorespaces}, |
| 78 |
% and \cs{tagmcend} will issue in horizontal mode an \cs{unskip}. |
| 79 |
% \end{function} |
| 80 |
% |
| 81 |
% \begin{function}{\tagmcifinTF} |
| 82 |
% \begin{syntax} |
| 83 |
% \cs{tagmcifinTF}\Arg{true code}\Arg{false code} |
| 84 |
% \end{syntax} |
| 85 |
% This is a wrapper around |\tag_mc_if_in:TF|. |
| 86 |
% and tests if an mc is open or not. It is mostly of |
| 87 |
% importance for pdflatex as lualatex doesn't mind much if a mc tag is not |
| 88 |
% correctly closed. Unlike the expl3 command it is not expandable. |
| 89 |
% |
| 90 |
% The command is probably not of much use and will perhaps disappear in future |
| 91 |
% versions. It normally makes more sense to push/pop an mc-chunk. |
| 92 |
% \end{function} |
| 93 |
% |
| 94 |
% \section{Commands related to structures} |
| 95 |
% \begin{function}{\tagstructbegin, \tagstructend,\tagstructuse} |
| 96 |
% \begin{syntax} |
| 97 |
% \cs{tagstructbegin}\Arg{key-val}\\ |
| 98 |
% \cs{tagstructend}\\ |
| 99 |
% \cs{tagstructuse}\Arg{label} |
| 100 |
% \end{syntax} |
| 101 |
% These are direct wrappers around |\tag_struct_begin:n|, |
| 102 |
% |\tag_struct_end:| and |\tag_struct_use:n|. |
| 103 |
% The commands and their argument are documented in the \pkg{tagpdf-struct} module. |
| 104 |
% \end{function} |
| 105 |
% |
| 106 |
% \section{Debugging} |
| 107 |
% \begin{function}{\ShowTagging} |
| 108 |
% \begin{syntax} |
| 109 |
% \cs{ShowTagging}\Arg{key-val} |
| 110 |
% \end{syntax} |
| 111 |
% This is a generic function to output various debugging helps. It not |
| 112 |
% necessarily stops the compilation. The keys and their function are described below. |
| 113 |
% \end{function} |
| 114 |
% |
| 115 |
% \begin{function}{mc-data (show-key)} |
| 116 |
% \begin{syntax} |
| 117 |
% |mc-data| = \meta{number} |
| 118 |
% \end{syntax} |
| 119 |
% This key is (currently?) relevant for lua mode only. |
| 120 |
% It shows the data of all mc-chunks created so far. |
| 121 |
% It is accurate only after shipout (and perhaps a second compilation), |
| 122 |
% so typically should be issued after a |
| 123 |
% newpage. The value is a positive integer and sets the first mc-shown. If no value |
| 124 |
% is given, 1 is used and so all mc-chunks created so far are shown. |
| 125 |
% \end{function} |
| 126 |
% \begin{function}{mc-current (show-key)} |
| 127 |
% \begin{syntax} |
| 128 |
% |mc-current| |
| 129 |
% \end{syntax} |
| 130 |
% This key shows the number and the tag of the currently open mc-chunk. If no |
| 131 |
% chunk is open it shows only the state of the abs count. It works in all mode, |
| 132 |
% but the output in luamode looks different. |
| 133 |
% \end{function} |
| 134 |
% \begin{function}{mc-marks (show-key)} |
| 135 |
% \begin{syntax} |
| 136 |
% |mc-marks| = |show|\verb+|+|use| |
| 137 |
% \end{syntax} |
| 138 |
% This key helps to debug the page marks. It should only be used at shipout in |
| 139 |
% header or footer. |
| 140 |
% \end{function} |
| 141 |
% \begin{function}{struct-stack (show-key)} |
| 142 |
% \begin{syntax} |
| 143 |
% |struct-stack| = |log|\verb+|+|show| |
| 144 |
% \end{syntax} |
| 145 |
% This key shows the current structure stack. With |log| the info is only |
| 146 |
% written to the log-file, |show| stops the compilation and shows on the terminal. |
| 147 |
% If no value is used, then the default is |show|. |
| 148 |
% \end{function} |
| 149 |
% |
| 150 |
% \begin{function}{debug/structures (show-key)} |
| 151 |
% \begin{syntax} |
| 152 |
% |debug/structures| = \meta{structure number} |
| 153 |
% \end{syntax} |
| 154 |
% This key is available only if the tagpdf-debug package is loaded |
| 155 |
% and shows all structures starting with the one with the number |
| 156 |
% given by the key. |
| 157 |
% \end{function} |
| 158 |
|
| 159 |
% \section{Extension commands} |
| 160 |
% The following commands and code parts are not core commands of tagpdf. |
| 161 |
% They either provide work-arounds for missing functionality elsewhere, |
| 162 |
% or do a first step to apply tagpdf commands to document commands. |
| 163 |
% |
| 164 |
% The commands and keys should be viewed as experimental! |
| 165 |
% |
| 166 |
% This part will be regularly revisited to check if the code should go to a |
| 167 |
% better place or can be improved and so can change easily. |
| 168 |
% |
| 169 |
% \subsection{Fake space} |
| 170 |
% \begin{function}{\pdffakespace} |
| 171 |
% (lua-only) This provides a lua-version of the |\pdffakespace| primitive of |
| 172 |
% pdftex. |
| 173 |
% \end{function} |
| 174 |
% |
| 175 |
% \subsection{Tagging of paragraphs} |
| 176 |
% |
| 177 |
% This makes use of the paragraph hooks in LaTeX to |
| 178 |
% automate the tagging of paragraph. It requires sane paragraph nesting, |
| 179 |
% faulty code, e.g. a missing |\par| at the end of a low-level vbox can highly |
| 180 |
% confuse the tagging. The tags should be carefully checked if this is used. |
| 181 |
% |
| 182 |
% \begin{function}{para/tagging (setup-key),paratagging-show (deprecated),paratagging (deprecated)} |
| 183 |
% \begin{syntax} |
| 184 |
% |para/tagging| = |true|\verb+|+|false|\\ |
| 185 |
% |debug/show=para|\\ |
| 186 |
% |debug/show=paraOff| |
| 187 |
% \end{syntax} |
| 188 |
% The |para/tagging| key can be used in |\tagpdfsetup| and enable/disables tagging |
| 189 |
% of paragraphics. |
| 190 |
% |debug/show=para| puts small colored numbers at the begin and end of a paragraph. |
| 191 |
% This is meant as a debugging help. The number are boxes and have a (tiny) height, |
| 192 |
% so they can affect typesetting. |
| 193 |
% \end{function} |
| 194 |
% |
| 195 |
% \begin{function}{\tagpdfparaOn,\tagpdfparaOff} |
| 196 |
% These commands allow to enable/disable para tagging too and are a bit |
| 197 |
% faster then |\tagpdfsetup|. But I'm not sure if the names are good. |
| 198 |
% \end{function} |
| 199 |
% |
| 200 |
% \begin{function}{\tagpdfsuppressmarks} |
| 201 |
% This command allows to suppress the creation of the marks. It takes an argument |
| 202 |
% which should normally be one of the mc-commands, puts a group around it and |
| 203 |
% suppress the marks creation in this group. This command should be used if |
| 204 |
% the begin and end command are at different boxing levels. E.g. |
| 205 |
% \begin{verbatim} |
| 206 |
% \@hangfrom |
| 207 |
% { |
| 208 |
% \tagstructbegin{tag=H1}% |
| 209 |
% \tagmcbegin {tag=H1}% |
| 210 |
% #2 |
| 211 |
% } |
| 212 |
% {#3\tagpdfsuppressmarks{\tagmcend}\tagstructend}% |
| 213 |
% \end{verbatim} |
| 214 |
% \end{function} |
| 215 |
% |
| 216 |
% \subsection{Header and footer} |
| 217 |
% Header and footer are automatically tagged as artifact: |
| 218 |
% They are surrounded by an artifact-mc and inside tagging is stopped. |
| 219 |
% If some real content is in the header and |
| 220 |
% footer, tagging must be restarted there explicitly. |
| 221 |
% The behaviour can be changed with the following key. |
| 222 |
% The key accepts the values |true| (the default), |
| 223 |
% |false| which disables the header tagging code. This can be useful |
| 224 |
% if the page style is empty (it then avoids empty mc-chunks) or |
| 225 |
% if the head and foot should be tagged in some special way. |
| 226 |
% The last value, |pagination|, is like |true| but |
| 227 |
% additionally adds an artifact structure with an pagination attribute. |
| 228 |
% |
| 229 |
% \begin{function}{page/exclude-header-footer (setup-key)} |
| 230 |
% \begin{syntax} |
| 231 |
% |page/exclude-header-footer| = |true|\verb+|+|false|\verb+|+pagination |
| 232 |
% \end{syntax}% |
| 233 |
% \end{function} |
| 234 |
|
| 235 |
% \subsection{Link tagging} |
| 236 |
% Links need a special structure and cross reference system. |
| 237 |
% This is added through hooks of the l3pdfannot module and will work |
| 238 |
% automatically if tagging is activated. |
| 239 |
% |
| 240 |
% Links can have an alternative text in the Contents but this disturbs reading, |
| 241 |
% so it is not done by default. |
| 242 |
% Another text can be added by changing the dictionary value: |
| 243 |
% \begin{verbatim} |
| 244 |
% \pdfannot_dict_put:nnn |
| 245 |
% { link/GoTo } |
| 246 |
% { Contents } |
| 247 |
% { (ref) } |
| 248 |
% \end{verbatim} |
| 249 |
% |
| 250 |
% \section{Socket support} |
| 251 |
% |
| 252 |
% \begin{function}{\tag_socket_use:n,\tag_socket_use:nnn,\UseTaggingSocket} |
| 253 |
% \begin{syntax} |
| 254 |
% \cs{tag_socket_use:n} \Arg{socket name}\\ |
| 255 |
% \cs{tag_socket_use:nn} \Arg{socket name} \Arg{socket argument}\\ |
| 256 |
% \cs{tag_socket_use:nnn} \Arg{socket name} \Arg{socket argument} \Arg{socket argument}\\ |
| 257 |
% \cs{tag_socket_use_expandable:n} \Arg{socket name}\\ |
| 258 |
% \cs{UseTaggingSocket} \Arg{socket name} \\ |
| 259 |
% \cs{UseTaggingSocket} \Arg{socket name} \Arg{socket argument}\\ |
| 260 |
% \cs{UseTaggingSocket} \Arg{socket name} \Arg{socket argument} \Arg{socket argument}\\ |
| 261 |
% \end{syntax} |
| 262 |
% \end{function} |
| 263 |
% |
| 264 |
% Given that we sometimes have to suspend tagging, it would be fairly |
| 265 |
% inefficient to put different plugs into these sockets whenever that |
| 266 |
% happens. We therefore offer \cs{UseTaggingSocket} which is like |
| 267 |
% \cs{UseSocket} except that is expects a socket starting with |
| 268 |
% \texttt{tagsupport/} but the socket name is specified without |
| 269 |
% this prefix, i.e., |
| 270 |
% \begin{quote} |
| 271 |
% \verb=\UseTaggingSocket{foo}= $\to$ |
| 272 |
% \verb=\UseSocket{tagsupport/foo}= |
| 273 |
% \end{quote}. |
| 274 |
% |
| 275 |
% Beside being slightly shorter, the big advantage is that this way |
| 276 |
% we can change \cs{UseTaggingSocket} to do nothing by switching a boolean |
| 277 |
% instead of changing the plugs of the tagging support sockets back and forth. |
| 278 |
% |
| 279 |
% Usually, these sockets have (beside the default plug defined for every socket) |
| 280 |
% one additional plug defined and directly assigned. This plug is used when |
| 281 |
% tagging is active. |
| 282 |
% There may be more plugs, e.g., tagging with special debugging or special behaviour |
| 283 |
% depending on the class or PDF version etc., but right now it is usually just on or off. |
| 284 |
% |
| 285 |
% When tagging is suspended they all have the same predefined behaviour: |
| 286 |
% The sockets with zero arguments do nothing. The sockets with one argument |
| 287 |
% gobble their argument. The sockets with two arguments |
| 288 |
% will drop their first argument and pass the second unchanged. |
| 289 |
% |
| 290 |
% It is possible to use the tagging support sockets with |
| 291 |
% \cs{UseSocket} directly, but in this case the socket remains active |
| 292 |
% if e.g. \cs{SuspendTagging} is in force. There may be reasons for doing |
| 293 |
% that but in general we expect to always use \cs{UseTaggingSocket}. |
| 294 |
% |
| 295 |
% For special cases like in some \cs{halign} contexts we need a fully expandable |
| 296 |
% version of the commend. For these cases, \cs{UseExpandableTaggingSocket} can be |
| 297 |
% used. To allow being expandable, it does not output any debugging information |
| 298 |
% if \cs{DebugSocketsOn} is in effect and therefore should be avoided whenever possible. |
| 299 |
% |
| 300 |
% The L3 programming layer versions \cs{tag_socket_use_expandable:n}, \cs{tag_socket_use:n}, and |
| 301 |
% \cs{tag_socket_use:nn}, \cs{tag_socket_use:nnn} |
| 302 |
% are slightly more efficient than |
| 303 |
% \cs{UseTaggingSocket} because they do not have to determine how |
| 304 |
% many arguments the socket takes when disabling it. |
| 305 |
% \end{documentation} |
| 306 |
% |
| 307 |
% \begin{implementation} |
| 308 |
% \section{User commands and extensions of document commands} |
| 309 |
% \begin{macrocode} |
| 310 |
%<@@=tag> |
| 311 |
%<*header> |
| 312 |
\ProvidesExplPackage {tagpdf-user} {2026-05-17} {1.0c} |
| 313 |
{tagpdf - user commands} |
| 314 |
%</header> |
| 315 |
% \end{macrocode} |
| 316 |
% \section{Setup and preamble commands} |
| 317 |
% \begin{macro}{\tagpdfsetup} |
| 318 |
% \begin{macrocode} |
| 319 |
%<base>\NewDocumentCommand \tagpdfsetup { m }{} |
| 320 |
%<*package> |
| 321 |
\RenewDocumentCommand \tagpdfsetup { m } |
| 322 |
{ |
| 323 |
\keys_set:nn { @@ / setup } { #1 } |
| 324 |
} |
| 325 |
%</package> |
| 326 |
% \end{macrocode} |
| 327 |
% \end{macro} |
| 328 |
% |
| 329 |
% \begin{macro}{\tag_tool:n,\tagtool (deprecated)} |
| 330 |
% This command is deprecated and will be removed. |
| 331 |
% \begin{macrocode} |
| 332 |
%<base>\cs_new_protected:Npn\tag_tool:n #1 {} |
| 333 |
%<base>\cs_set_eq:NN\tagtool\tag_tool:n |
| 334 |
%<*package> |
| 335 |
\cs_set_protected:Npn\tag_tool:n #1 |
| 336 |
{ |
| 337 |
\tag_if_active:T { \keys_set:nn {tag / tool}{#1} } |
| 338 |
} |
| 339 |
\cs_set_eq:NN\tagtool\tag_tool:n |
| 340 |
%</package> |
| 341 |
% \end{macrocode} |
| 342 |
% \end{macro} |
| 343 |
|
| 344 |
% \section{Commands for the mc-chunks} |
| 345 |
% \begin{macro}{\tagmcbegin,\tagmcend,\tagmcuse } |
| 346 |
% \begin{macrocode} |
| 347 |
%<*base> |
| 348 |
\NewDocumentCommand \tagmcbegin { m } |
| 349 |
{ |
| 350 |
\tag_mc_begin:n {#1} |
| 351 |
} |
| 352 |
|
| 353 |
|
| 354 |
\NewDocumentCommand \tagmcend { } |
| 355 |
{ |
| 356 |
\tag_mc_end: |
| 357 |
} |
| 358 |
|
| 359 |
\NewDocumentCommand \tagmcuse { m } |
| 360 |
{ |
| 361 |
\tag_mc_use:n {#1} |
| 362 |
} |
| 363 |
%</base> |
| 364 |
% \end{macrocode} |
| 365 |
% \end{macro} |
| 366 |
|
| 367 |
% \begin{macro}{\tagmcifinTF} |
| 368 |
% This is a wrapper around |\tag_mc_if_in:| and tests if an mc is open or not. It is mostly of |
| 369 |
% importance for pdflatex as lualatex doesn't mind much if a mc tag is not |
| 370 |
% correctly closed. Unlike the expl3 command it is not expandable. |
| 371 |
% \begin{macrocode} |
| 372 |
%<*package> |
| 373 |
\NewDocumentCommand \tagmcifinTF { m m } |
| 374 |
{ |
| 375 |
\tag_mc_if_in:TF { #1 } { #2 } |
| 376 |
} |
| 377 |
%</package> |
| 378 |
% \end{macrocode} |
| 379 |
% \end{macro} |
| 380 |
% |
| 381 |
% \section{Commands for the structure} |
| 382 |
% \begin{macro}{\tagstructbegin,\tagstructend,\tagstructuse } |
| 383 |
% |
| 384 |
% These are structure related user commands. There are direct wrapper around the |
| 385 |
% expl3 variants. |
| 386 |
% \begin{macrocode} |
| 387 |
%<*base> |
| 388 |
\NewDocumentCommand \tagstructbegin { m } |
| 389 |
{ |
| 390 |
\tag_struct_begin:n {#1} |
| 391 |
} |
| 392 |
|
| 393 |
\NewDocumentCommand \tagstructend { } |
| 394 |
{ |
| 395 |
\tag_struct_end: |
| 396 |
} |
| 397 |
|
| 398 |
\NewDocumentCommand \tagstructuse { m } |
| 399 |
{ |
| 400 |
\tag_struct_use:n {#1} |
| 401 |
} |
| 402 |
%</base> |
| 403 |
% \end{macrocode} |
| 404 |
% \end{macro} |
| 405 |
% |
| 406 |
% \section{Tagging Socket support} |
| 407 |
% |
| 408 |
% \begin{macro}{\tag_socket_use:n,\tag_socket_use:nn,\tag_socket_use:nnn,\UseTaggingSocket, |
| 409 |
% \tag_socket_use_expandable:n,\UseExpandableTaggingSocket} |
| 410 |
% \begin{macrocode} |
| 411 |
%<*package> |
| 412 |
\cs_set_protected:Npn \tag_socket_use:n #1 |
| 413 |
{ |
| 414 |
\bool_if:NT \l_@@_active_socket_bool |
| 415 |
{ \socket_use:n {tagsupport/#1} } |
| 416 |
} |
| 417 |
% \end{macrocode} |
| 418 |
% |
| 419 |
% \begin{macrocode} |
| 420 |
\cs_set_protected:Npn \tag_socket_use:nn #1#2 |
| 421 |
{ |
| 422 |
\bool_if:NT \l_@@_active_socket_bool |
| 423 |
{ \socket_use:nn {tagsupport/#1} {#2} } |
| 424 |
} |
| 425 |
% \end{macrocode} |
| 426 |
% |
| 427 |
% \begin{macrocode} |
| 428 |
\cs_set_protected:Npn \tag_socket_use:nnn #1#2#3 |
| 429 |
{ |
| 430 |
\bool_if:NTF \l_@@_active_socket_bool |
| 431 |
{ \socket_use:nnn {tagsupport/#1} {#2} {#3} } |
| 432 |
{ #3 } |
| 433 |
} |
| 434 |
% \end{macrocode} |
| 435 |
% \begin{macrocode} |
| 436 |
\cs_set:Npn \tag_socket_use_expandable:n #1 |
| 437 |
{ |
| 438 |
\bool_if:NT \l_@@_active_socket_bool |
| 439 |
{ \socket_use_expandable:n {tagsupport/#1} } |
| 440 |
} |
| 441 |
% \end{macrocode} |
| 442 |
% \begin{macrocode} |
| 443 |
\cs_set_protected:Npn \UseTaggingSocket #1 |
| 444 |
{ |
| 445 |
\bool_if:NTF \l_@@_active_socket_bool |
| 446 |
{ \socket_use:nw {tagsupport/#1} } |
| 447 |
{ |
| 448 |
\int_case:nnF |
| 449 |
{ \int_use:c { c__socket_tagsupport/#1_args_int } } |
| 450 |
{ |
| 451 |
0 \prg_do_nothing: |
| 452 |
1 \use_none:n |
| 453 |
2 \use_ii:nn |
| 454 |
% \end{macrocode} |
| 455 |
% We do not expect tagging sockets with more than one or two |
| 456 |
% arguments, so for now we only provide those. |
| 457 |
% \begin{macrocode} |
| 458 |
} |
| 459 |
\ERRORusetaggingsocket |
| 460 |
} |
| 461 |
} |
| 462 |
% \end{macrocode} |
| 463 |
|
| 464 |
% \begin{macrocode} |
| 465 |
\cs_set:Npn \UseExpandableTaggingSocket #1 |
| 466 |
{ |
| 467 |
\bool_if:NTF \l_@@_active_socket_bool |
| 468 |
{ \socket_use_expandable:nw {tagsupport/#1} } |
| 469 |
{ |
| 470 |
\int_case:nnF |
| 471 |
{ \int_use:c { c__socket_tagsupport/#1_args_int } } |
| 472 |
{ |
| 473 |
0 \prg_do_nothing: |
| 474 |
1 \use_none:n |
| 475 |
2 \use_ii:nn |
| 476 |
% \end{macrocode} |
| 477 |
% We do not expect tagging sockets with more than one or two |
| 478 |
% arguments, so for now we only provide those. |
| 479 |
% \begin{macrocode} |
| 480 |
} |
| 481 |
\ERRORusetaggingsocket |
| 482 |
} |
| 483 |
} |
| 484 |
%</package> |
| 485 |
% \end{macrocode} |
| 486 |
% \end{macro} |
| 487 |
% |
| 488 |
% \section{Debugging} |
| 489 |
% \begin{macro}{\ShowTagging} |
| 490 |
% This is a generic command for various show commands. |
| 491 |
% It takes a keyval list, the various keys are implemented below. |
| 492 |
% \begin{macrocode} |
| 493 |
%<*package> |
| 494 |
\NewDocumentCommand\ShowTagging { m } |
| 495 |
{ |
| 496 |
\keys_set:nn { @@ / show }{ #1} |
| 497 |
|
| 498 |
} |
| 499 |
% \end{macrocode} |
| 500 |
% \end{macro} |
| 501 |
% |
| 502 |
% \begin{macro}{mc-data (show-key)} |
| 503 |
% This key is (currently?) relevant for lua mode only. |
| 504 |
% It shows the data of all mc-chunks created so far. |
| 505 |
% It is accurate only after shipout, so typically should be issued after a |
| 506 |
% newpage. With the optional argument the minimal number can be set. |
| 507 |
% \begin{macrocode} |
| 508 |
\keys_define:nn { @@ / show } |
| 509 |
{ |
| 510 |
mc-data .code:n = |
| 511 |
{ |
| 512 |
\bool_if:NT \g_@@_mode_lua_bool |
| 513 |
{ |
| 514 |
\lua_now:e{ltx.@@.trace.show_all_mc_data(#1,\@@_get_mc_abs_cnt:,0)} |
| 515 |
} |
| 516 |
} |
| 517 |
,mc-data .default:n = 1 |
| 518 |
} |
| 519 |
|
| 520 |
% \end{macrocode} |
| 521 |
% \end{macro} |
| 522 |
% \begin{macro}{mc-current (show-key)} |
| 523 |
% This shows some info about the current mc-chunk. It works in generic and lua-mode. |
| 524 |
% \begin{macrocode} |
| 525 |
\keys_define:nn { @@ / show } |
| 526 |
{ mc-current .code:n = |
| 527 |
{ |
| 528 |
\bool_if:NTF \g_@@_mode_lua_bool |
| 529 |
{ |
| 530 |
\int_compare:nNnTF |
| 531 |
{ -2147483647 } |
| 532 |
= |
| 533 |
{ |
| 534 |
\lua_now:e |
| 535 |
{ |
| 536 |
tex.print |
| 537 |
(\int_use:N\c_document_cctab, |
| 538 |
tex.getattribute |
| 539 |
(luatexbase.attributes.g_@@_mc_cnt_attr)) |
| 540 |
} |
| 541 |
} |
| 542 |
{ |
| 543 |
\lua_now:e |
| 544 |
{ |
| 545 |
ltx.@@.trace.log |
| 546 |
( |
| 547 |
"mc-current:~no~MC~open,~current~abscnt |
| 548 |
=\@@_get_mc_abs_cnt:" |
| 549 |
,0 |
| 550 |
) |
| 551 |
texio.write_nl("") |
| 552 |
} |
| 553 |
} |
| 554 |
{ |
| 555 |
\lua_now:e |
| 556 |
{ |
| 557 |
ltx.@@.trace.log |
| 558 |
( |
| 559 |
"mc-current:~abscnt=\@@_get_mc_abs_cnt:==" |
| 560 |
.. |
| 561 |
tex.getattribute(luatexbase.attributes.g_@@_mc_cnt_attr) |
| 562 |
.. |
| 563 |
"~=>tag=" |
| 564 |
.. |
| 565 |
tostring |
| 566 |
(ltx.@@.func.get_tag_from |
| 567 |
(tex.getattribute |
| 568 |
(luatexbase.attributes.g_@@_mc_type_attr))) |
| 569 |
.. |
| 570 |
"=" |
| 571 |
.. |
| 572 |
tex.getattribute |
| 573 |
(luatexbase.attributes.g_@@_mc_type_attr) |
| 574 |
,0 |
| 575 |
) |
| 576 |
texio.write_nl("") |
| 577 |
} |
| 578 |
} |
| 579 |
} |
| 580 |
{ |
| 581 |
\msg_note:nn{ tag }{ mc-current } |
| 582 |
} |
| 583 |
} |
| 584 |
} |
| 585 |
% \end{macrocode} |
| 586 |
% \end{macro} |
| 587 |
% \begin{macro}{mc-marks (show-key)} |
| 588 |
% It maps the mc-marks into the sequences and then shows them. |
| 589 |
% This allows to inspect the first and last mc-Mark on a page. |
| 590 |
% It should only be used in the shipout (header/footer). |
| 591 |
% \begin{macrocode} |
| 592 |
\keys_define:nn { @@ / show } |
| 593 |
{ |
| 594 |
mc-marks .choice: , |
| 595 |
mc-marks / show .code:n = |
| 596 |
{ |
| 597 |
\@@_mc_get_marks: |
| 598 |
\@@_check_if_mc_in_galley:TF |
| 599 |
{ |
| 600 |
\iow_term:n {Marks~from~this~page:~} |
| 601 |
} |
| 602 |
{ |
| 603 |
\iow_term:n {Marks~from~a~previous~page:~} |
| 604 |
} |
| 605 |
\seq_show:N \l_@@_mc_firstmarks_seq |
| 606 |
\seq_show:N \l_@@_mc_botmarks_seq |
| 607 |
\@@_check_if_mc_tmb_missing:T |
| 608 |
{ |
| 609 |
\iow_term:n {BDC~missing~on~this~page!} |
| 610 |
} |
| 611 |
\@@_check_if_mc_tme_missing:T |
| 612 |
{ |
| 613 |
\iow_term:n {EMC~missing~on~this~page!} |
| 614 |
} |
| 615 |
}, |
| 616 |
mc-marks / use .code:n = |
| 617 |
{ |
| 618 |
\@@_mc_get_marks: |
| 619 |
\@@_check_if_mc_in_galley:TF |
| 620 |
{ Marks~from~this~page:~} |
| 621 |
{ Marks~from~a~previous~page:~} |
| 622 |
\seq_use:Nn \l_@@_mc_firstmarks_seq {,~}\quad |
| 623 |
\seq_use:Nn \l_@@_mc_botmarks_seq {,~}\quad |
| 624 |
\@@_check_if_mc_tmb_missing:T |
| 625 |
{ |
| 626 |
BDC~missing~ |
| 627 |
} |
| 628 |
\@@_check_if_mc_tme_missing:T |
| 629 |
{ |
| 630 |
EMC~missing |
| 631 |
} |
| 632 |
}, |
| 633 |
mc-marks .default:n = show |
| 634 |
} |
| 635 |
% \end{macrocode} |
| 636 |
% \end{macro} |
| 637 |
% \begin{macro}{struct-stack (show-key)} |
| 638 |
% \begin{macrocode} |
| 639 |
\keys_define:nn { @@ / show } |
| 640 |
{ |
| 641 |
struct-stack .choice: |
| 642 |
,struct-stack / log .code:n = \seq_log:N \g_@@_struct_tag_stack_seq |
| 643 |
,struct-stack / show .code:n = \seq_show:N \g_@@_struct_tag_stack_seq |
| 644 |
,struct-stack .default:n = show |
| 645 |
} |
| 646 |
%</package> |
| 647 |
% \end{macrocode} |
| 648 |
% \end{macro} |
| 649 |
% \begin{macro}{debug/structures (show-key)} |
| 650 |
% The following key is available only if the tagpdf-debug package is loaded |
| 651 |
% and shows all structures starting with the one with the number |
| 652 |
% given by the key. |
| 653 |
% \begin{macrocode} |
| 654 |
%<*debug> |
| 655 |
\keys_define:nn { @@ / show } |
| 656 |
{ |
| 657 |
,debug/structures .code:n = |
| 658 |
{ |
| 659 |
\int_step_inline:nnn{#1}{\c@g_@@_struct_abs_int} |
| 660 |
{ |
| 661 |
\msg_term:nneeee |
| 662 |
{ tag/debug } { show-struct } |
| 663 |
{ ##1 } |
| 664 |
{ |
| 665 |
\prop_map_function:cN |
| 666 |
{g_@@_struct_debug_##1_prop} |
| 667 |
\msg_show_item_unbraced:nn |
| 668 |
} |
| 669 |
{ } { } |
| 670 |
\msg_term:nneeee |
| 671 |
{ tag/debug } { show-kids } |
| 672 |
{ ##1 } |
| 673 |
{ |
| 674 |
\seq_map_function:cN |
| 675 |
{g_@@_struct_debug_kids_##1_seq} |
| 676 |
\msg_show_item_unbraced:n |
| 677 |
} |
| 678 |
{ } { } |
| 679 |
} |
| 680 |
} |
| 681 |
,debug/structures .default:n = 1 |
| 682 |
} |
| 683 |
%</debug> |
| 684 |
% \end{macrocode} |
| 685 |
% \end{macro} |
| 686 |
% |
| 687 |
% \section{Commands to extend document commands} |
| 688 |
% The following commands and code parts are not core commands of tagpdf. |
| 689 |
% They either provide work-arounds for missing functionality elsewhere, |
| 690 |
% or do a first step to apply tagpdf commands to document commands. |
| 691 |
% This part should be regularly revisited to check if the code should go to a |
| 692 |
% better place or can be improved. |
| 693 |
% |
| 694 |
% \begin{macrocode} |
| 695 |
%<*package> |
| 696 |
% \end{macrocode} |
| 697 |
% \subsection{Document structure} |
| 698 |
% \begin{macro}{\g_@@_root_default_tl,activate (setup-key),activate/socket (setup-key)} |
| 699 |
% \begin{macrocode} |
| 700 |
\tl_new:N\g_@@_root_default_tl |
| 701 |
\tl_gset:Nn\g_@@_root_default_tl {Document} |
| 702 |
|
| 703 |
\hook_gput_code:nnn{begindocument}{tagpdf}{\tagstructbegin{tag=\g_@@_root_default_tl}} |
| 704 |
\hook_gput_code:nnn{tagpdf/finish/before}{tagpdf}{\tagstructend} |
| 705 |
|
| 706 |
\keys_define:nn { @@ / setup} |
| 707 |
{ |
| 708 |
activate/socket .bool_set:N = \l_@@_active_socket_bool, |
| 709 |
activate .code:n = |
| 710 |
{ |
| 711 |
\keys_set:nn { @@ / setup } |
| 712 |
{ activate/mc,activate/tree,activate/struct,activate/socket } |
| 713 |
\tl_gset:Nn\g_@@_root_default_tl {#1} |
| 714 |
}, |
| 715 |
activate .default:n = Document |
| 716 |
} |
| 717 |
|
| 718 |
% \end{macrocode} |
| 719 |
% \end{macro} |
| 720 |
% |
| 721 |
% \subsection{Structure destinations} |
| 722 |
% Since TeXlive 2022 pdftex and luatex offer support for structure destinations |
| 723 |
% and the pdfmanagement has backend support for. We activate them if |
| 724 |
% structures are actually created. |
| 725 |
% Structure destinations are actually PDF 2.0 only but they don't harm in |
| 726 |
% older PDF and can improve html export. |
| 727 |
% \begin{macrocode} |
| 728 |
\AddToHook{begindocument/before} |
| 729 |
{ |
| 730 |
\bool_lazy_and:nnT |
| 731 |
{ \g_@@_active_struct_dest_bool } |
| 732 |
{ \g_@@_active_struct_bool } |
| 733 |
{ |
| 734 |
\tl_set:Nn \l_pdf_current_structure_destination_tl |
| 735 |
{ {@@/struct}{\g_@@_struct_stack_current_tl }} |
| 736 |
\pdf_activate_indexed_structure_destination: |
| 737 |
} |
| 738 |
} |
| 739 |
% \end{macrocode} |
| 740 |
|
| 741 |
% \subsection{Fake space} |
| 742 |
% \begin{macro}{\pdffakespace} |
| 743 |
% We need a luatex variant for |\pdffakespace|. This should probably go into |
| 744 |
% the kernel at some time. We also provide a no-op version for dvi mode |
| 745 |
% \begin{macrocode} |
| 746 |
\bool_if:NT \g_@@_mode_lua_bool |
| 747 |
{ |
| 748 |
\NewDocumentCommand\pdffakespace { } |
| 749 |
{ |
| 750 |
\@@_fakespace: |
| 751 |
} |
| 752 |
} |
| 753 |
\providecommand\pdffakespace{} |
| 754 |
% \end{macrocode} |
| 755 |
% \end{macro} |
| 756 |
% |
| 757 |
% \subsection{Paratagging} |
| 758 |
% The following are some simple commands to enable/disable paratagging. |
| 759 |
% Probably one should add some checks if we are already in a paragraph. |
| 760 |
% |
| 761 |
% |
| 762 |
% \begin{macro}{ |
| 763 |
% \l_@@_para_bool, |
| 764 |
% \l_@@_para_flattened_bool, |
| 765 |
% \l_@@_para_show_bool, |
| 766 |
% \g_@@_para_begin_int, |
| 767 |
% \g_@@_para_end_int, |
| 768 |
% \g_@@_para_main_begin_int, |
| 769 |
% \g_@@_para_main_end_int, |
| 770 |
% \g_@@_para_main_struct_tl, |
| 771 |
% \l_@@_para_tag_default_tl, |
| 772 |
% \l_@@_para_tag_tl, |
| 773 |
% \l_@@_para_main_tag_tl, |
| 774 |
% \l_@@_para_attr_class_tl, |
| 775 |
% \l_@@_para_main_attr_class_tl, |
| 776 |
% } |
| 777 |
% At first some variables. |
| 778 |
% \begin{macrocode} |
| 779 |
%</package> |
| 780 |
%<base>\bool_new:N \l_@@_para_flattened_bool |
| 781 |
%<base>\bool_new:N \l_@@_para_bool |
| 782 |
%<*package> |
| 783 |
\int_new:N \g_@@_para_begin_int |
| 784 |
\int_new:N \g_@@_para_end_int |
| 785 |
\int_new:N \g_@@_para_main_begin_int |
| 786 |
\int_new:N \g_@@_para_main_end_int |
| 787 |
% \end{macrocode} |
| 788 |
% this will hold the structure number of the current text-unit. |
| 789 |
% \begin{macrocode} |
| 790 |
\tl_new:N \g_@@_para_main_struct_tl |
| 791 |
\tl_gset:Nn \g_@@_para_main_struct_tl {1} |
| 792 |
\tl_new:N \l_@@_para_tag_default_tl |
| 793 |
\tl_new:N \l_@@_para_tag_tl |
| 794 |
\tl_set:Nn \l_@@_para_tag_tl { \l_@@_para_tag_default_tl } |
| 795 |
\tl_new:N \l_@@_para_main_tag_tl |
| 796 |
\tl_set:Nn \l_@@_para_tag_default_tl { \UseStructureName {para/textblock} } |
| 797 |
\tl_set:Nn \l_@@_para_main_tag_tl { \UseStructureName {para/semantic} } |
| 798 |
%\tl_new:N \l_@@_para_attr_class_tl % defined in lttagging |
| 799 |
\tl_new:N \l_@@_para_main_attr_class_tl |
| 800 |
% \end{macrocode} |
| 801 |
% \end{macro} |
| 802 |
|
| 803 |
% \begin{macro} |
| 804 |
% { |
| 805 |
% \@@_gincr_para_main_begin_int:, |
| 806 |
% \@@_gincr_para_main_end_int:, |
| 807 |
% \@@_gincr_para_begin_int:, |
| 808 |
% \@@_gincr_para_end_int: |
| 809 |
% } |
| 810 |
% The global para counter should be set through commands so |
| 811 |
% that \cs{tag_stop:} can stop them. |
| 812 |
% \begin{macrocode} |
| 813 |
\cs_new_protected:Npn \@@_gincr_para_main_begin_int: |
| 814 |
{ |
| 815 |
\int_gincr:N \g_@@_para_main_begin_int |
| 816 |
} |
| 817 |
\cs_new_protected:Npn \@@_gincr_para_begin_int: |
| 818 |
{ |
| 819 |
\int_gincr:N \g_@@_para_begin_int |
| 820 |
} |
| 821 |
\cs_new_protected:Npn \@@_gincr_para_main_end_int: |
| 822 |
{ |
| 823 |
\int_gincr:N \g_@@_para_main_end_int |
| 824 |
} |
| 825 |
\cs_new_protected:Npn \@@_gincr_para_end_int: |
| 826 |
{ |
| 827 |
\int_gincr:N \g_@@_para_end_int |
| 828 |
} |
| 829 |
% \end{macrocode} |
| 830 |
% \end{macro} |
| 831 |
% \begin{macro}{\@@_start_para_ints:,\@@_stop_para_ints:} |
| 832 |
% \begin{macrocode} |
| 833 |
\cs_new_protected:Npn \@@_start_para_ints: |
| 834 |
{ |
| 835 |
\cs_set_protected:Npn \@@_gincr_para_main_begin_int: |
| 836 |
{ |
| 837 |
\int_gincr:N \g_@@_para_main_begin_int |
| 838 |
} |
| 839 |
\cs_set_protected:Npn \@@_gincr_para_begin_int: |
| 840 |
{ |
| 841 |
\int_gincr:N \g_@@_para_begin_int |
| 842 |
} |
| 843 |
\cs_set_protected:Npn \@@_gincr_para_main_end_int: |
| 844 |
{ |
| 845 |
\int_gincr:N \g_@@_para_main_end_int |
| 846 |
} |
| 847 |
\cs_set_protected:Npn \@@_gincr_para_end_int: |
| 848 |
{ |
| 849 |
\int_gincr:N \g_@@_para_end_int |
| 850 |
} |
| 851 |
} |
| 852 |
\cs_new_protected:Npn \@@_stop_para_ints: |
| 853 |
{ |
| 854 |
\cs_set_eq:NN \@@_gincr_para_main_begin_int:\prg_do_nothing: |
| 855 |
\cs_set_eq:NN \@@_gincr_para_begin_int: \prg_do_nothing: |
| 856 |
\cs_set_eq:NN \@@_gincr_para_main_end_int: \prg_do_nothing: |
| 857 |
\cs_set_eq:NN \@@_gincr_para_end_int: \prg_do_nothing: |
| 858 |
} |
| 859 |
% \end{macrocode} |
| 860 |
% \end{macro} |
| 861 |
% |
| 862 |
% We want to be able to inspect the current para main structure, so |
| 863 |
% we need a command to store its structure number |
| 864 |
% \begin{macro}{\@@_para_main_store_struct:} |
| 865 |
% \begin{macrocode} |
| 866 |
\cs_new:Npn \@@_para_main_store_struct: |
| 867 |
{ |
| 868 |
\tl_gset:Ne \g_@@_para_main_struct_tl {\int_use:N \c@g_@@_struct_abs_int } |
| 869 |
} |
| 870 |
% \end{macrocode} |
| 871 |
% \end{macro} |
| 872 |
% |
| 873 |
%\begin{macro} |
| 874 |
% { |
| 875 |
% para/tagging (setup-key), |
| 876 |
% para/tag (setup-key), |
| 877 |
% para/maintag (setup-key), |
| 878 |
% para/tagging (tool-key), |
| 879 |
% para/tag (tool-key), |
| 880 |
% para/maintag (tool-key), |
| 881 |
% para/flattened (tool-key), |
| 882 |
% unittag (deprecated), |
| 883 |
% para-flattened (deprecated), |
| 884 |
% paratagging (deprecated), |
| 885 |
% paratagging-show (deprecated), |
| 886 |
% paratag (deprecated), |
| 887 |
% } |
| 888 |
% These keys enable/disable locally paratagging. |
| 889 |
% Paragraphs are typically tagged with two structure: A main structure |
| 890 |
% around the whole paragraph, and inner structures around the various chunks. |
| 891 |
% Debugging can be |
| 892 |
% activated locally with |debug/show=para|, this can affect the typesetting |
| 893 |
% as the small numbers |
| 894 |
% are boxes and they have a (small) height. Debugging can be deactivated |
| 895 |
% with |debug/show=paraOff| |
| 896 |
% The |para/tag| key sets the tag used by |
| 897 |
% the inner structure, |para/maintag| the tag of the outer structure, |
| 898 |
% both can also be changed with |\tag_tool:n| |
| 899 |
% \begin{macrocode} |
| 900 |
\keys_define:nn { @@ / setup } |
| 901 |
{ |
| 902 |
para/tagging .bool_set:N = \l_@@_para_bool, |
| 903 |
debug/show/para .code:n = {\bool_set_true:N \l_@@_para_show_bool}, |
| 904 |
debug/show/paraOff .code:n = {\bool_set_false:N \l_@@_para_show_bool}, |
| 905 |
para/tag .tl_set:N = \l_@@_para_tag_tl, |
| 906 |
para/maintag .tl_set:N = \l_@@_para_main_tag_tl, |
| 907 |
para/flattened .bool_set:N = \l_@@_para_flattened_bool |
| 908 |
} |
| 909 |
% \end{macrocode} |
| 910 |
% deprecated key definitions: |
| 911 |
% \begin{macrocode} |
| 912 |
\keys_define:nn { tag / tool} |
| 913 |
{ |
| 914 |
para/tagging .bool_set:N = \l_@@_para_bool, |
| 915 |
para/tag .tl_set:N = \l_@@_para_tag_tl, |
| 916 |
para/maintag .tl_set:N = \l_@@_para_main_tag_tl, |
| 917 |
para/flattened .bool_set:N = \l_@@_para_flattened_bool |
| 918 |
} |
| 919 |
% \end{macrocode} |
| 920 |
% the deprecated names |
| 921 |
% \begin{macrocode} |
| 922 |
\keys_define:nn { @@ / setup } |
| 923 |
{ |
| 924 |
paratagging .bool_set:N = \l_@@_para_bool, |
| 925 |
paratagging-show .bool_set:N = \l_@@_para_show_bool, |
| 926 |
paratag .tl_set:N = \l_@@_para_tag_tl |
| 927 |
} |
| 928 |
% \end{macrocode} |
| 929 |
% still needed as used in block code ... |
| 930 |
% \begin{macrocode} |
| 931 |
\keys_define:nn { tag / tool} |
| 932 |
{ |
| 933 |
para .bool_set:N = \l_@@_para_bool, |
| 934 |
paratag .tl_set:N = \l_@@_para_tag_tl, |
| 935 |
unittag .tl_set:N = \l_@@_para_main_tag_tl, |
| 936 |
para-flattened .bool_set:N = \l_@@_para_flattened_bool |
| 937 |
} |
| 938 |
% \end{macrocode} |
| 939 |
% \end{macro} |
| 940 |
% Helper command for debugging: |
| 941 |
% \begin{macrocode} |
| 942 |
\cs_new_protected:Npn \@@_check_para_begin_show:nn #1 #2 |
| 943 |
%#1 color, #2 prefix |
| 944 |
{ |
| 945 |
\bool_if:NT \l_@@_para_show_bool |
| 946 |
{ |
| 947 |
\tag_mc_begin:n{artifact} |
| 948 |
\llap{\color_select:n{#1}\tiny#2\int_use:N\g_@@_para_begin_int\ } |
| 949 |
\tag_mc_end: |
| 950 |
} |
| 951 |
} |
| 952 |
|
| 953 |
\cs_new_protected:Npn \@@_check_para_end_show:nn #1 #2 |
| 954 |
%#1 color, #2 prefix |
| 955 |
{ |
| 956 |
\bool_if:NT \l_@@_para_show_bool |
| 957 |
{ |
| 958 |
\tag_mc_begin:n{artifact} |
| 959 |
\rlap{\color_select:n{#1}\tiny\ #2\int_use:N\g_@@_para_end_int} |
| 960 |
\tag_mc_end: |
| 961 |
} |
| 962 |
} |
| 963 |
% \end{macrocode} |
| 964 |
% |
| 965 |
% \begin{macrocode} |
| 966 |
\AddToHook{begindocument/before}[tagpdf/para] |
| 967 |
{ |
| 968 |
\AddToHook{para/begin}[tagpdf]{ \tag_socket_use:n { para/begin } } |
| 969 |
\AddToHook{para/end} [tagpdf] { \tag_socket_use:n { para/end } } |
| 970 |
} |
| 971 |
% \end{macrocode} |
| 972 |
% |
| 973 |
% We check the para count at the end. If tagging is not active it is not a error, |
| 974 |
% but we issue a warning as it perhaps indicates that the code didn't guard |
| 975 |
% everything correctly with tagging sockets. |
| 976 |
% \begin{macrocode} |
| 977 |
\AddToHook{enddocument/info} |
| 978 |
{ |
| 979 |
\tag_if_active:F |
| 980 |
{ |
| 981 |
\msg_redirect_name:nnn { tag } { para-hook-count-wrong } { warning } |
| 982 |
} |
| 983 |
\int_compare:nNnF {\g_@@_para_main_begin_int}={\g_@@_para_main_end_int} |
| 984 |
{ |
| 985 |
\msg_error:nneee |
| 986 |
{tag} |
| 987 |
{para-hook-count-wrong} |
| 988 |
{\int_use:N\g_@@_para_main_begin_int} |
| 989 |
{\int_use:N\g_@@_para_main_end_int} |
| 990 |
{text-unit} |
| 991 |
} |
| 992 |
\int_compare:nNnF {\g_@@_para_begin_int}={\g_@@_para_end_int} |
| 993 |
{ |
| 994 |
\msg_error:nneee |
| 995 |
{tag} |
| 996 |
{para-hook-count-wrong} |
| 997 |
{\int_use:N\g_@@_para_begin_int} |
| 998 |
{\int_use:N\g_@@_para_end_int} |
| 999 |
{text} |
| 1000 |
} |
| 1001 |
} |
| 1002 |
% \end{macrocode} |
| 1003 |
%</package> |
| 1004 |
% |
| 1005 |
% \begin{macro} |
| 1006 |
% { |
| 1007 |
% \tagpdfparaOn, |
| 1008 |
% \tagpdfparaOff |
| 1009 |
% } |
| 1010 |
% This two command switch para mode on and off. |\tagpdfsetup| could be used |
| 1011 |
% too but is longer. An alternative is |\tag_tool:n{para/tagging=false}| |
| 1012 |
% \begin{macrocode} |
| 1013 |
%<base>\newcommand\tagpdfparaOn {} |
| 1014 |
%<base>\newcommand\tagpdfparaOff{} |
| 1015 |
%<*package> |
| 1016 |
\renewcommand\tagpdfparaOn {\bool_set_true:N \l_@@_para_bool} |
| 1017 |
\renewcommand\tagpdfparaOff{\bool_set_false:N \l_@@_para_bool} |
| 1018 |
% \end{macrocode} |
| 1019 |
% \end{macro} |
| 1020 |
% |
| 1021 |
% \begin{macro} |
| 1022 |
% { |
| 1023 |
% \tagpdfsuppressmarks |
| 1024 |
% } |
| 1025 |
% This command allows to suppress the creation of the marks. It takes an argument |
| 1026 |
% which should normally be one of the mc-commands, puts a group around it and |
| 1027 |
% suppress the marks creation in this group. This command should be used if |
| 1028 |
% the begin and end command are at different boxing levels. E.g. |
| 1029 |
% \begin{verbatim} |
| 1030 |
% \@hangfrom |
| 1031 |
% { |
| 1032 |
% \tagstructbegin{tag=H1}% |
| 1033 |
% \tagmcbegin {tag=H1}% |
| 1034 |
% #2 |
| 1035 |
% } |
| 1036 |
% {#3\tagpdfsuppressmarks{\tagmcend}\tagstructend}% |
| 1037 |
% \end{verbatim} |
| 1038 |
% \begin{macrocode} |
| 1039 |
\NewDocumentCommand\tagpdfsuppressmarks{m} |
| 1040 |
{{\use:c{@@_mc_disable_marks:} #1}} |
| 1041 |
% \end{macrocode} |
| 1042 |
% \end{macro} |
| 1043 |
% \subsection{Language support} |
| 1044 |
% |
| 1045 |
% With the following key the lang variable is set. All structures in the current group will |
| 1046 |
% then set this lang variable. |
| 1047 |
% \begin{macro}{test/lang (setup-key)} |
| 1048 |
% \begin{macrocode} |
| 1049 |
\keys_define:nn { @@ / setup } |
| 1050 |
{ |
| 1051 |
text / lang .tl_set:N = \l_@@_struct_lang_tl |
| 1052 |
} |
| 1053 |
% \end{macrocode} |
| 1054 |
% \end{macro} |
| 1055 |
% \subsection{Header and footer} |
| 1056 |
% Header and footer should normally be tagged as artifacts. The following code |
| 1057 |
% requires the output tagging sockets. |
| 1058 |
% For now we allow to disable this function, but probably the code should always there at |
| 1059 |
% the end. |
| 1060 |
% TODO check if Pagination should be changeable. |
| 1061 |
% \begin{macrocode} |
| 1062 |
\cs_new_protected:Npn\@@_hook_kernel_before_head:{} |
| 1063 |
\cs_new_protected:Npn\@@_hook_kernel_after_head:{} |
| 1064 |
\cs_new_protected:Npn\@@_hook_kernel_before_foot:{} |
| 1065 |
\cs_new_protected:Npn\@@_hook_kernel_after_foot:{} |
| 1066 |
% \end{macrocode} |
| 1067 |
% We use the page sockets. |
| 1068 |
% \begin{macrocode} |
| 1069 |
\NewTaggingSocketPlug{build/page/header}{tagpdf} |
| 1070 |
{ |
| 1071 |
\@@_hook_kernel_before_head: |
| 1072 |
#2 |
| 1073 |
\@@_hook_kernel_after_head: |
| 1074 |
} |
| 1075 |
|
| 1076 |
\AssignTaggingSocketPlug{build/page/header}{tagpdf} |
| 1077 |
\NewTaggingSocketPlug{build/page/footer}{tagpdf} |
| 1078 |
{ |
| 1079 |
\@@_hook_kernel_before_foot: |
| 1080 |
#2 |
| 1081 |
\@@_hook_kernel_after_foot: |
| 1082 |
} |
| 1083 |
\AssignTaggingSocketPlug{build/page/footer}{tagpdf} |
| 1084 |
% \end{macrocode} |
| 1085 |
% |
| 1086 |
% \begin{macrocode} |
| 1087 |
\bool_new:N \g_@@_saved_in_mc_bool |
| 1088 |
\cs_new_protected:Npn \@@_exclude_headfoot_begin: |
| 1089 |
{ |
| 1090 |
\bool_set_false:N \l_@@_para_bool |
| 1091 |
\bool_if:NTF \g_@@_mode_lua_bool |
| 1092 |
{ |
| 1093 |
\tag_mc_end_push: |
| 1094 |
} |
| 1095 |
{ |
| 1096 |
\bool_gset_eq:NN \g_@@_saved_in_mc_bool \g_@@_in_mc_bool |
| 1097 |
\bool_gset_false:N \g_@@_in_mc_bool |
| 1098 |
} |
| 1099 |
\tag_mc_begin:n {artifact} |
| 1100 |
\tag_suspend:n{headfoot} |
| 1101 |
} |
| 1102 |
\cs_new_protected:Npn \@@_exclude_headfoot_end: |
| 1103 |
{ |
| 1104 |
\tag_resume:n{headfoot} |
| 1105 |
\tag_mc_end: |
| 1106 |
\bool_if:NTF \g_@@_mode_lua_bool |
| 1107 |
{ |
| 1108 |
\tag_mc_begin_pop:n{} |
| 1109 |
} |
| 1110 |
{ |
| 1111 |
\bool_gset_eq:NN \g_@@_in_mc_bool\g_@@_saved_in_mc_bool |
| 1112 |
} |
| 1113 |
} |
| 1114 |
% \end{macrocode} |
| 1115 |
% This version allows to use an Artifact structure |
| 1116 |
% \begin{macrocode} |
| 1117 |
\@@_attr_new_entry:nn {@@/attr/pagination}{/O/Artifact/Type/Pagination} |
| 1118 |
\cs_new_protected:Npn \@@_exclude_struct_headfoot_begin:n #1 |
| 1119 |
{ |
| 1120 |
\bool_set_false:N \l_@@_para_bool |
| 1121 |
\bool_if:NTF \g_@@_mode_lua_bool |
| 1122 |
{ |
| 1123 |
\tag_mc_end_push: |
| 1124 |
} |
| 1125 |
{ |
| 1126 |
\bool_gset_eq:NN \g_@@_saved_in_mc_bool \g_@@_in_mc_bool |
| 1127 |
\bool_gset_false:N \g_@@_in_mc_bool |
| 1128 |
} |
| 1129 |
\tag_struct_begin:n{tag=Artifact,attribute-class=@@/attr/#1} |
| 1130 |
\tag_mc_begin:n {artifact=#1} |
| 1131 |
\tag_suspend:n{headfoot} |
| 1132 |
} |
| 1133 |
|
| 1134 |
\cs_new_protected:Npn \@@_exclude_struct_headfoot_end: |
| 1135 |
{ |
| 1136 |
\tag_resume:n{headfoot} |
| 1137 |
\tag_mc_end: |
| 1138 |
\tag_struct_end: |
| 1139 |
\bool_if:NTF \g_@@_mode_lua_bool |
| 1140 |
{ |
| 1141 |
\tag_mc_begin_pop:n{} |
| 1142 |
} |
| 1143 |
{ |
| 1144 |
\bool_gset_eq:NN \g_@@_in_mc_bool\g_@@_saved_in_mc_bool |
| 1145 |
} |
| 1146 |
} |
| 1147 |
% \end{macrocode} |
| 1148 |
% And now the keys |
| 1149 |
% \begin{macro}{page/exclude-header-footer (setup-key),exclude-header-footer (deprecated)} |
| 1150 |
% \begin{macrocode} |
| 1151 |
\keys_define:nn { @@ / setup } |
| 1152 |
{ |
| 1153 |
page/exclude-header-footer .choice:, |
| 1154 |
page/exclude-header-footer / true .code:n = |
| 1155 |
{ |
| 1156 |
\cs_set_eq:NN \@@_hook_kernel_before_head: \@@_exclude_headfoot_begin: |
| 1157 |
\cs_set_eq:NN \@@_hook_kernel_before_foot: \@@_exclude_headfoot_begin: |
| 1158 |
\cs_set_eq:NN \@@_hook_kernel_after_head: \@@_exclude_headfoot_end: |
| 1159 |
\cs_set_eq:NN \@@_hook_kernel_after_foot: \@@_exclude_headfoot_end: |
| 1160 |
}, |
| 1161 |
page/exclude-header-footer / pagination .code:n = |
| 1162 |
{ |
| 1163 |
\cs_set:Nn \@@_hook_kernel_before_head: { \@@_exclude_struct_headfoot_begin:n {pagination} } |
| 1164 |
\cs_set:Nn \@@_hook_kernel_before_foot: { \@@_exclude_struct_headfoot_begin:n {pagination} } |
| 1165 |
\cs_set_eq:NN \@@_hook_kernel_after_head: \@@_exclude_struct_headfoot_end: |
| 1166 |
\cs_set_eq:NN \@@_hook_kernel_after_foot: \@@_exclude_struct_headfoot_end: |
| 1167 |
}, |
| 1168 |
page/exclude-header-footer / false .code:n = |
| 1169 |
{ |
| 1170 |
\cs_set_eq:NN \@@_hook_kernel_before_head: \prg_do_nothing: |
| 1171 |
\cs_set_eq:NN \@@_hook_kernel_before_foot: \prg_do_nothing: |
| 1172 |
\cs_set_eq:NN \@@_hook_kernel_after_head: \prg_do_nothing: |
| 1173 |
\cs_set_eq:NN \@@_hook_kernel_after_foot: \prg_do_nothing: |
| 1174 |
}, |
| 1175 |
page/exclude-header-footer .default:n = true, |
| 1176 |
page/exclude-header-footer .initial:n = true, |
| 1177 |
% \end{macrocode} |
| 1178 |
% deprecated name |
| 1179 |
% \begin{macrocode} |
| 1180 |
exclude-header-footer .meta:n = { page/exclude-header-footer = {#1} } |
| 1181 |
} |
| 1182 |
% \end{macrocode} |
| 1183 |
% \end{macro} |
| 1184 |
% |
| 1185 |
% A special, experimental tagged version, which only works with fancyhdr or similar that uses |
| 1186 |
% parbox. The sockets aren't in lttagging yet, so until 2026-06-01 we have to declare |
| 1187 |
% the plugs at begin document: |
| 1188 |
% \begin{macrocode} |
| 1189 |
\AtBeginDocument |
| 1190 |
{ |
| 1191 |
\NewTaggingSocketPlug{parbox/before}{tag/footer} |
| 1192 |
{ |
| 1193 |
\tag_struct_begin:n{tag=Span} |
| 1194 |
\tag_mc_begin:n{} |
| 1195 |
} |
| 1196 |
|
| 1197 |
\NewTaggingSocketPlug{parbox/after}{tag/footer} |
| 1198 |
{ |
| 1199 |
\tag_mc_end: |
| 1200 |
\tag_struct_end: |
| 1201 |
} |
| 1202 |
} |
| 1203 |
\cs_new_protected:Npn \@@_headfoot_tagged_begin:n #1 |
| 1204 |
{ |
| 1205 |
\AssignTaggingSocketPlug{parbox/before}{tag/footer} |
| 1206 |
\AssignTaggingSocketPlug{parbox/after}{tag/footer} |
| 1207 |
\bool_set_false:N \l_@@_para_bool |
| 1208 |
\bool_if:NTF \g_@@_mode_lua_bool |
| 1209 |
{ |
| 1210 |
\tag_mc_end_push: |
| 1211 |
} |
| 1212 |
{ |
| 1213 |
\bool_gset_eq:NN \g_@@_saved_in_mc_bool \g_@@_in_mc_bool |
| 1214 |
\bool_gset_false:N \g_@@_in_mc_bool |
| 1215 |
} |
| 1216 |
\tag_struct_begin:n{tag=Artifact,attribute-class=_@@/attr/#1,parent=\tag_get:n{current_Sect}} |
| 1217 |
} |
| 1218 |
|
| 1219 |
\cs_new_protected:Npn \@@_headfoot_tagged_end: |
| 1220 |
{ |
| 1221 |
\tag_struct_end: |
| 1222 |
\bool_if:NTF \g_@@_mode_lua_bool |
| 1223 |
{ |
| 1224 |
\tag_mc_begin_pop:n{} |
| 1225 |
} |
| 1226 |
{ |
| 1227 |
\bool_gset_eq:NN \g_@@_in_mc_bool\g_@@_saved_in_mc_bool |
| 1228 |
} |
| 1229 |
} |
| 1230 |
\keys_define:nn { @@ / setup } |
| 1231 |
{ |
| 1232 |
page/tag-header-footer .choice:, |
| 1233 |
page/tag-header-footer/artifact .code:n = |
| 1234 |
{ |
| 1235 |
\cs_set:Nn \__tag_hook_kernel_before_head: { \__tag_headfoot_tagged_begin:n {pagination}} |
| 1236 |
\cs_set:Nn \__tag_hook_kernel_before_foot: { \__tag_headfoot_tagged_begin:n {pagination}} |
| 1237 |
\cs_set_eq:NN \__tag_hook_kernel_after_head: \__tag_headfoot_tagged_end: |
| 1238 |
\cs_set_eq:NN \__tag_hook_kernel_after_foot: \__tag_headfoot_tagged_end: |
| 1239 |
}, |
| 1240 |
page/tag-header-footer .default:n = artifact, |
| 1241 |
} |
| 1242 |
% \end{macrocode} |
| 1243 |
% \subsection{Links} |
| 1244 |
% We need to close and reopen mc-chunks around links. |
| 1245 |
% We handle URI, GoTo (internal) links, GoToR, Launch and Named links. |
| 1246 |
% Links should have an alternative text in the Contents |
| 1247 |
% key; this is added for normal links by the generic hyperref driver. |
| 1248 |
% With luatex we make use of the lualinksplit package to get |
| 1249 |
% OBJR of all annotations into the Link structure, so the hook code |
| 1250 |
% should not contain the command to insert the OBJR into the structure. |
| 1251 |
% |
| 1252 |
% At first we provide the link name that will be in the next LaTeX release (06/2026) |
| 1253 |
% \begin{macrocode} |
| 1254 |
\AddToHookNext{class/before} |
| 1255 |
{ |
| 1256 |
\cs_if_exist:NF \l_@@_name_link_tl |
| 1257 |
{ |
| 1258 |
\tl_new:N \l_@@_name_link_tl |
| 1259 |
\tl_set:Nn \l_@@_name_link_tl{Link} |
| 1260 |
} |
| 1261 |
} |
| 1262 |
% \end{macrocode} |
| 1263 |
% Tagging sockets for links |
| 1264 |
% \begin{macrocode} |
| 1265 |
\socket_if_exist:nF {tagsupport/link/before} |
| 1266 |
{ |
| 1267 |
\NewTaggingSocket{link/before}{1} |
| 1268 |
\NewTaggingSocket{link/after}{1} |
| 1269 |
} |
| 1270 |
\NewTaggingSocketPlug{link/before}{kernel} |
| 1271 |
{ |
| 1272 |
\mode_leave_vertical: |
| 1273 |
\tag_mc_end_push: |
| 1274 |
\tag_struct_begin:n { tag=\UseStructureName{link} } |
| 1275 |
\tag_mc_begin:n {} |
| 1276 |
#1 |
| 1277 |
} |
| 1278 |
\AssignTaggingSocketPlug{link/before}{kernel} |
| 1279 |
|
| 1280 |
\NewTaggingSocketPlug{link/after}{kernel} |
| 1281 |
{ |
| 1282 |
#1 |
| 1283 |
\tag_mc_end: |
| 1284 |
\tag_struct_end: |
| 1285 |
\tag_mc_begin_pop:n{} |
| 1286 |
} |
| 1287 |
\AssignTaggingSocketPlug{link/after}{kernel} |
| 1288 |
|
| 1289 |
|
| 1290 |
\bool_lazy_and:nnTF |
| 1291 |
{ \sys_if_engine_luatex_p: } |
| 1292 |
{ |
| 1293 |
\tl_if_empty_p:e |
| 1294 |
{ |
| 1295 |
\lua_now:e |
| 1296 |
{ if~ luatexbase.in_callback('pre_shipout_filter','linksplit')~ |
| 1297 |
then~else~tex.print('1')~end |
| 1298 |
} |
| 1299 |
} |
| 1300 |
} |
| 1301 |
{ |
| 1302 |
\hook_gput_code:nnn |
| 1303 |
{pdfannot/link/URI/before} |
| 1304 |
{tagpdf} |
| 1305 |
{ |
| 1306 |
\UseTaggingSocket{link/before}{} |
| 1307 |
} |
| 1308 |
|
| 1309 |
\hook_gput_code:nnn |
| 1310 |
{pdfannot/link/URI/after} |
| 1311 |
{tagpdf} |
| 1312 |
{ |
| 1313 |
\UseTaggingSocket{link/after}{} |
| 1314 |
} |
| 1315 |
|
| 1316 |
\hook_gput_code:nnn |
| 1317 |
{pdfannot/link/GoTo/before} |
| 1318 |
{tagpdf} |
| 1319 |
{ |
| 1320 |
\UseTaggingSocket{link/before}{} |
| 1321 |
} |
| 1322 |
|
| 1323 |
\hook_gput_code:nnn |
| 1324 |
{pdfannot/link/GoTo/after} |
| 1325 |
{tagpdf} |
| 1326 |
{ |
| 1327 |
\UseTaggingSocket{link/after}{} |
| 1328 |
} |
| 1329 |
|
| 1330 |
\hook_gput_code:nnn |
| 1331 |
{pdfannot/link/GoToR/before} |
| 1332 |
{tagpdf} |
| 1333 |
{ |
| 1334 |
\UseTaggingSocket{link/before} |
| 1335 |
} |
| 1336 |
|
| 1337 |
\hook_gput_code:nnn |
| 1338 |
{pdfannot/link/GoToR/after} |
| 1339 |
{tagpdf} |
| 1340 |
{ |
| 1341 |
\UseTaggingSocket{link/after}{} |
| 1342 |
} |
| 1343 |
\hook_gput_code:nnn |
| 1344 |
{pdfannot/link/Launch/before} |
| 1345 |
{tagpdf} |
| 1346 |
{ |
| 1347 |
\UseTaggingSocket{link/before}{} |
| 1348 |
} |
| 1349 |
|
| 1350 |
\hook_gput_code:nnn |
| 1351 |
{pdfannot/link/Launch/after} |
| 1352 |
{tagpdf} |
| 1353 |
{ |
| 1354 |
\UseTaggingSocket{link/after}{} |
| 1355 |
} |
| 1356 |
\hook_gput_code:nnn |
| 1357 |
{pdfannot/link/Named/before} |
| 1358 |
{tagpdf} |
| 1359 |
{ |
| 1360 |
\UseTaggingSocket{link/before}{} |
| 1361 |
} |
| 1362 |
|
| 1363 |
\hook_gput_code:nnn |
| 1364 |
{pdfannot/link/Named/after} |
| 1365 |
{tagpdf} |
| 1366 |
{ |
| 1367 |
\UseTaggingSocket{link/after}{} |
| 1368 |
} |
| 1369 |
} |
| 1370 |
{ |
| 1371 |
\hook_gput_code:nnn |
| 1372 |
{pdfannot/link/URI/before} |
| 1373 |
{tagpdf} |
| 1374 |
{ |
| 1375 |
\UseTaggingSocket{link/before} |
| 1376 |
{ |
| 1377 |
\pdfannot_dict_put:nne |
| 1378 |
{ link/URI } |
| 1379 |
{ StructParent } |
| 1380 |
{ \tag_struct_parent_int: } |
| 1381 |
} |
| 1382 |
} |
| 1383 |
|
| 1384 |
\hook_gput_code:nnn |
| 1385 |
{pdfannot/link/URI/after} |
| 1386 |
{tagpdf} |
| 1387 |
{ |
| 1388 |
\UseTaggingSocket{link/after} |
| 1389 |
{ |
| 1390 |
\tag_struct_insert_annot:ee |
| 1391 |
{\pdfannot_link_ref_last:}{\tag_struct_parent_int:} |
| 1392 |
} |
| 1393 |
} |
| 1394 |
|
| 1395 |
\hook_gput_code:nnn |
| 1396 |
{pdfannot/link/GoTo/before} |
| 1397 |
{tagpdf} |
| 1398 |
{ |
| 1399 |
\UseTaggingSocket{link/before} |
| 1400 |
{ |
| 1401 |
\pdfannot_dict_put:nne |
| 1402 |
{ link/GoTo } |
| 1403 |
{ StructParent } |
| 1404 |
{ \tag_struct_parent_int: } |
| 1405 |
} |
| 1406 |
} |
| 1407 |
|
| 1408 |
\hook_gput_code:nnn |
| 1409 |
{pdfannot/link/GoTo/after} |
| 1410 |
{tagpdf} |
| 1411 |
{ |
| 1412 |
\UseTaggingSocket{link/after} |
| 1413 |
{ |
| 1414 |
\tag_struct_insert_annot:ee |
| 1415 |
{\pdfannot_link_ref_last:}{\tag_struct_parent_int:} |
| 1416 |
} |
| 1417 |
} |
| 1418 |
|
| 1419 |
\hook_gput_code:nnn |
| 1420 |
{pdfannot/link/GoToR/before} |
| 1421 |
{tagpdf} |
| 1422 |
{ |
| 1423 |
\UseTaggingSocket{link/before} |
| 1424 |
{ |
| 1425 |
\pdfannot_dict_put:nne |
| 1426 |
{ link/GoToR } |
| 1427 |
{ StructParent } |
| 1428 |
{ \tag_struct_parent_int: } |
| 1429 |
} |
| 1430 |
} |
| 1431 |
|
| 1432 |
\hook_gput_code:nnn |
| 1433 |
{pdfannot/link/GoToR/after} |
| 1434 |
{tagpdf} |
| 1435 |
{ |
| 1436 |
\UseTaggingSocket{link/after} |
| 1437 |
{ |
| 1438 |
\tag_struct_insert_annot:ee |
| 1439 |
{\pdfannot_link_ref_last:}{\tag_struct_parent_int:} |
| 1440 |
} |
| 1441 |
} |
| 1442 |
|
| 1443 |
\hook_gput_code:nnn |
| 1444 |
{pdfannot/link/Named/before} |
| 1445 |
{tagpdf} |
| 1446 |
{ |
| 1447 |
\UseTaggingSocket{link/before} |
| 1448 |
{ |
| 1449 |
\pdfannot_dict_put:nne |
| 1450 |
{ link/Named } |
| 1451 |
{ StructParent } |
| 1452 |
{ \tag_struct_parent_int: } |
| 1453 |
} |
| 1454 |
} |
| 1455 |
|
| 1456 |
\hook_gput_code:nnn |
| 1457 |
{pdfannot/link/Named/after} |
| 1458 |
{tagpdf} |
| 1459 |
{ |
| 1460 |
\UseTaggingSocket{link/after} |
| 1461 |
{ |
| 1462 |
\tag_struct_insert_annot:ee |
| 1463 |
{\pdfannot_link_ref_last:}{\tag_struct_parent_int:} |
| 1464 |
} |
| 1465 |
} |
| 1466 |
\hook_gput_code:nnn |
| 1467 |
{pdfannot/link/Launch/before} |
| 1468 |
{tagpdf} |
| 1469 |
{ |
| 1470 |
\UseTaggingSocket{link/before} |
| 1471 |
{ |
| 1472 |
\pdfannot_dict_put:nne |
| 1473 |
{ link/Launch } |
| 1474 |
{ StructParent } |
| 1475 |
{ \tag_struct_parent_int: } |
| 1476 |
} |
| 1477 |
} |
| 1478 |
|
| 1479 |
\hook_gput_code:nnn |
| 1480 |
{pdfannot/link/Launch/after} |
| 1481 |
{tagpdf} |
| 1482 |
{ |
| 1483 |
\UseTaggingSocket{link/after} |
| 1484 |
{ |
| 1485 |
\tag_struct_insert_annot:ee |
| 1486 |
{\pdfannot_link_ref_last:}{\tag_struct_parent_int:} |
| 1487 |
} |
| 1488 |
} |
| 1489 |
} |
| 1490 |
% \end{macrocode} |
| 1491 |
% |
| 1492 |
% \subsection{Attaching css-files for derivation} |
| 1493 |
% |
| 1494 |
% Derivation to html (https://pdfa.org/wp-content/uploads/2019/06/Deriving_HTML_from_PDF.pdf, |
| 1495 |
% implemented by, e.g., ngpdf) can be improved by attaching CSS style definitions |
| 1496 |
% in associated files with relationship supplement to the Catalog\footnote{Previously they |
| 1497 |
% suggested the StructTreeRoot, but this is not compatible with pdf/A-3}. |
| 1498 |
% |
| 1499 |
% Such CSS style definitions can be given in two ways: |
| 1500 |
% \begin{itemize} |
| 1501 |
% \item In files with the extension \texttt{.css}. Such files should contain only |
| 1502 |
% CSS style definitions. ngpdf will store these files and include them with an |
| 1503 |
% \verb+<link rel=stylesheet href=...>+ in the head of the html. |
| 1504 |
% \item In files with the extension \texttt{.html}. Such files should contain CSS style |
| 1505 |
% definitions inside one (or more) \verb+<style>...</style>+ html tags. The content of these |
| 1506 |
% files are copied by ngpdf directly into the head of the derived html. |
| 1507 |
% \end{itemize} |
| 1508 |
% |
| 1509 |
% By default (if tagging is active) tagpdf embeds now such CSS style definitions. |
| 1510 |
% Currently the list of files is rather short and consists of two files (with extension |
| 1511 |
% .html and \verb+<style>...</style>+ html tags) which are provided by the tagpdf package: |
| 1512 |
% \begin{itemize} |
| 1513 |
% \item latex-align-css.html which improves the styling of amsmath alignments tagged with MathML. |
| 1514 |
% \item latex-list-css.html which improves the style of list environments. |
| 1515 |
% \end{itemize} |
| 1516 |
% |
| 1517 |
% It is possible to suppress the embedding of these files by setting the \cs{tagpdfsetup} key |
| 1518 |
% \texttt{attach-css} to \texttt{false}, \texttt{attach-css=true} or \texttt{attach-css} reverts this again. |
| 1519 |
% |
| 1520 |
% For developers, \cs{tagpdfsetup} some keys to manipulate the list exist: |
| 1521 |
% With \verb+css-list={file1,file2}+ the list can be overwritten. \verb+css-list=+ clears |
| 1522 |
% the list (and so suppresses the embedding too). |
| 1523 |
% To remove a file from the list, use \verb+css-list-remove=file+, e.g. |
| 1524 |
% \verb+css-list-remove=latex-list-css.html+. To add your |
| 1525 |
% own file use \verb+css-list-add=my-fancy-align-css.html+. |
| 1526 |
% It is also possible to attach a .css-file in this way. |
| 1527 |
% |
| 1528 |
% These keys do not affect files added directly with root-supplemental-file or catalog-supplemental-file. |
| 1529 |
% |
| 1530 |
% The files in this list are attached at the end of the compilation |
| 1531 |
% but you shouldn't rely on a specific order of the embedding in the html. |
| 1532 |
% |
| 1533 |
% We want to avoid to embed files twice, so we use a prop. |
| 1534 |
% \begin{macrocode} |
| 1535 |
\prop_new:N \g_@@_css_prop |
| 1536 |
\prop_gset_from_keyval:Nn \g_@@_css_prop |
| 1537 |
{ |
| 1538 |
latex-list-css.html=true, |
| 1539 |
latex-align-css.html=true |
| 1540 |
} |
| 1541 |
|
| 1542 |
|
| 1543 |
\bool_new:N \g_@@_css_bool |
| 1544 |
\bool_gset_true:N \g_@@_css_bool |
| 1545 |
% \end{macrocode} |
| 1546 |
% The files for the catalog must be added before the catalog is pushed. |
| 1547 |
% \begin{macrocode} |
| 1548 |
\tl_gput_left:Nn \g__kernel_pdfmanagement_end_run_code_tl |
| 1549 |
{ |
| 1550 |
\bool_lazy_and:nnT { \g_@@_css_bool }{ \tag_if_active_p: } |
| 1551 |
{ |
| 1552 |
\prop_map_inline:Nn \g_@@_css_prop |
| 1553 |
{ |
| 1554 |
\keys_set:nn { @@ / setup }{ catalog-supplemental-file= {#1} } |
| 1555 |
} |
| 1556 |
} |
| 1557 |
} |
| 1558 |
|
| 1559 |
\keys_define:nn { @@ / setup } |
| 1560 |
{ |
| 1561 |
attach-css .bool_gset:N = \g_@@_css_bool, |
| 1562 |
css-list .code:n = |
| 1563 |
{ |
| 1564 |
\tl_if_empty:nTF{#1} |
| 1565 |
{\prop_gclear:N \g_@@_css_prop } |
| 1566 |
{\prop_gput:Nnn \g_@@_css_prop { #1 }{true}} |
| 1567 |
}, |
| 1568 |
css-list-add .code:n = { \prop_gput:Nnn \g_@@_css_prop { #1 }{true} }, |
| 1569 |
css-list-remove .code:n = { \prop_gremove:Nn \g_@@_css_prop { #1 } }, |
| 1570 |
} |
| 1571 |
% \end{macrocode} |
| 1572 |
%</package> |
| 1573 |
% \end{implementation} |
| 1574 |
% \PrintIndex |