| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: tagpdf-checks.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 |
% |
| 25 |
% |
| 26 |
%<*driver> |
| 27 |
\DocumentMetadata{tagging=on} |
| 28 |
\documentclass{l3in2edoc} |
| 29 |
\usepackage{array,booktabs,caption,longtable} |
| 30 |
\hypersetup{pdfauthor=Ulrike Fischer, |
| 31 |
pdftitle=tagpdf-checks module (tagpdf)} |
| 32 |
\begin{document} |
| 33 |
\DocInput{\jobname.dtx} |
| 34 |
\end{document} |
| 35 |
%</driver> |
| 36 |
% \fi |
| 37 |
% \title{^^A |
| 38 |
% The \pkg{tagpdf-checks} module\\ Messages and check code ^^A |
| 39 |
% } |
| 40 |
% |
| 41 |
% \author{^^A |
| 42 |
% Ulrike Fischer\thanks |
| 43 |
% {^^A |
| 44 |
% E-mail: |
| 45 |
% \href{mailto:[email protected]} |
| 46 |
% {[email protected]}^^A |
| 47 |
% }^^A |
| 48 |
% } |
| 49 |
% |
| 50 |
% \date{Version 1.0c, released 2026-05-17} |
| 51 |
% \maketitle |
| 52 |
% \begin{documentation} |
| 53 |
% \section{Commands} |
| 54 |
% \begin{function}[pTF,EXP]{\tag_if_active:} |
| 55 |
% This command tests if tagging is active. It only gives true if all tagging has |
| 56 |
% been activated, \emph{and} if tagging hasn't been stopped locally. |
| 57 |
% \end{function} |
| 58 |
% \begin{function}[EXP]{\tag_get:n} |
| 59 |
% \begin{syntax} |
| 60 |
% \cs{tag_get:n} \Arg{keyword} |
| 61 |
% \end{syntax} |
| 62 |
% This is a generic command to retrieve data for the current structure or |
| 63 |
% mc-chunk. Currently |
| 64 |
% the only sensible values for the argument \meta{keyword} |
| 65 |
% are |mc_tag|, |struct_tag|, |struct_id| and |struct_num|. |
| 66 |
% \end{function} |
| 67 |
% |
| 68 |
% \begin{function}[pTF,EXP]{\tag_if_box_tagged:N} |
| 69 |
% \begin{syntax} |
| 70 |
% \cs{tag_if_box_tagged:NTF} \meta{box} \Arg{true code} \Arg{false code} |
| 71 |
% \end{syntax} |
| 72 |
% This tests if a box contains tagging commands. |
| 73 |
% It relies currently on that the code, that saved the box, correctly sets |
| 74 |
% the command \verb+\l_tag_box_\int_use:N #1_tl+ to a positive value. |
| 75 |
% The LaTeX commands will do that automatically |
| 76 |
% at some time but it is in the responsibility of the user to |
| 77 |
% ensure that when using low-level code. |
| 78 |
% If the internal command doesn't exist the box is assumed to be untagged. |
| 79 |
% \end{function} |
| 80 |
% \section{Description of log messages} |
| 81 |
% \subsection{\cs{ShowTagging} command} |
| 82 |
% \begin{tabular}{lll} |
| 83 |
% Argument & type & note\\ |
| 84 |
% \cs{ShowTagging}{mc-data = num} & log+term & lua-only\\ |
| 85 |
% \cs{ShowTagging}{mc-current} & log+term & \\ |
| 86 |
% \cs{ShowTagging}{struck-stack= [log\verb+|+show]} & log or term+stop \\ |
| 87 |
% \cs{ShowTagging}{debug/structures = num} & log+termn & debug mode only |
| 88 |
% \end{tabular} |
| 89 |
% |
| 90 |
% \begin{function}[pTF]{\tag_if_in:n} |
| 91 |
% \begin{syntax} |
| 92 |
% \cs{tag_if_in:n} \Arg{standard structure type} |
| 93 |
% \end{syntax} |
| 94 |
% This command tests if we are currently \enquote{in} a specific structure by checking |
| 95 |
% if the argument is on the stack. The argument must be a standard structure type as no role mapping is applied. |
| 96 |
% |
| 97 |
% The main use case is to check if there is an open P structure that should be closed. |
| 98 |
% \end{function} |
| 99 |
|
| 100 |
% \subsection{Messages in checks and commands} |
| 101 |
% \scriptsize |
| 102 |
% \begin{tabular}{llll} |
| 103 |
% command & message & action & remark\\ |
| 104 |
% |\@@_check_structure_has_tag:n| |
| 105 |
% & |struct-missing-tag| |
| 106 |
% & error |
| 107 |
% \\ |
| 108 |
% |\@@_check_structure_tag:N| |
| 109 |
% & |role-unknown-tag| |
| 110 |
% & warning |
| 111 |
% \\ |
| 112 |
% |\@@_check_info_closing_struct:n| |
| 113 |
% & |struct-show-closing| |
| 114 |
% & info |
| 115 |
% & log-level>0 |
| 116 |
% \\ |
| 117 |
% |\@@_check_no_open_struct:| |
| 118 |
% & struct-faulty-nesting |
| 119 |
% & error |
| 120 |
% & TODO: error only with 1? |
| 121 |
% \\ |
| 122 |
% |\@@_check_struct_used:n| |
| 123 |
% & |struct-used-twice| |
| 124 |
% & warning |
| 125 |
% \\ |
| 126 |
% |\@@_check_add_tag_role:nn| |
| 127 |
% & |role-missing|, |role-tag|, |role-unknown| |
| 128 |
% & warning, info (>0), warning |
| 129 |
% \\ |
| 130 |
% |\@@_check_mc_if_nested:|, |
| 131 |
% & |mc-nested| |
| 132 |
% & warning |
| 133 |
% \\ |
| 134 |
% |\@@_check_mc_if_open:| |
| 135 |
% & |mc-not-open| |
| 136 |
% & warning |
| 137 |
% & only generic (?) |
| 138 |
% \\ |
| 139 |
% |\@@_check_mc_pushed_popped:nn| |
| 140 |
% & |mc-pushed|, |mc-popped| |
| 141 |
% & info (2), info+|seq_log| (>2) |
| 142 |
% \\ |
| 143 |
% |\@@_check_mc_tag:N| |
| 144 |
% & |mc-tag-missing|, |role-unknown-tag| |
| 145 |
% & error (missing), warning (unknown). |
| 146 |
% \\ |
| 147 |
% |\@@_check_mc_used:n| |
| 148 |
% & |mc-used-twice| |
| 149 |
% & warning |
| 150 |
% & TODO: review the sense of this test! |
| 151 |
% \\ |
| 152 |
% |\@@_check_show_MCID_by_page:| |
| 153 |
% & |
| 154 |
% & |
| 155 |
% & currently unused |
| 156 |
% \\ |
| 157 |
% |\tag_mc_use:n| |
| 158 |
% & |mc-label-unknown|, |mc-used-twice| |
| 159 |
% & warning |
| 160 |
% & in mc-shared |
| 161 |
% \\ |
| 162 |
% |\role_add_tag:nn| |
| 163 |
% & |new-tag| |
| 164 |
% & info (>0) |
| 165 |
% & in roles |
| 166 |
% \\ |
| 167 |
% & |sys-no-interwordspace| |
| 168 |
% & warning |
| 169 |
% & space module, only xetex/dvi |
| 170 |
% \\ |
| 171 |
% |\@@_struct_write_obj:n| |
| 172 |
% & |struct-no-objnum| |
| 173 |
% & error |
| 174 |
% & in struct module |
| 175 |
% \\ |
| 176 |
% |\@@_struct_write_obj:n| |
| 177 |
% & |struct-orphan| |
| 178 |
% & warning |
| 179 |
% & in struct module |
| 180 |
% \\ |
| 181 |
% |\tag_struct_begin:n| |
| 182 |
% & |struct-faulty-nesting| |
| 183 |
% & error |
| 184 |
% \\ |
| 185 |
% |\@@_struct_insert_annot:nn| |
| 186 |
% & |struct-faulty-nesting| |
| 187 |
% & error |
| 188 |
% \\ |
| 189 |
% |tag_struct_use:n| |
| 190 |
% & |struct-label-unknown| |
| 191 |
% & warning |
| 192 |
% \\ |
| 193 |
% |attribute-class|, |attribute| |
| 194 |
% & |attr-unknown| |
| 195 |
% & error |
| 196 |
% \\ |
| 197 |
% |\@@_tree_fill_parenttree:| |
| 198 |
% & |tree-mcid-index-wrong| |
| 199 |
% & warning |
| 200 |
% TODO: should trigger a standard rerun message. |
| 201 |
% \\ |
| 202 |
% in |enddocument/info|-hook |
| 203 |
% & |para-hook-count-wrong| |
| 204 |
% & error (warning?) |
| 205 |
% \end{tabular} |
| 206 |
% |
| 207 |
% \normalsize |
| 208 |
% \subsection{Messages from the ptagging code} |
| 209 |
% A few messages are issued in generic |
| 210 |
% mode from the code which reinserts missing TMB/TME. |
| 211 |
% This is currently done if log-level is larger than zero. |
| 212 |
% TODO: reconsider log-level and messages when this code |
| 213 |
% settles down. |
| 214 |
% |
| 215 |
% |
| 216 |
% \subsection{Warning messages from the lua-code} |
| 217 |
% The messages are triggered if the log-level is at least equal to the number. |
| 218 |
% |
| 219 |
% \begin{tabular}[t]{>{\ttfamily}lll} |
| 220 |
% message & log-level & remark \\\hline |
| 221 |
% WARN TAG-NOT-TAGGED: &1 \\ |
| 222 |
% WARN TAG-OPEN-MC: &1 \\ |
| 223 |
% WARN SHIPOUT-MC-OPEN: &1 \\ |
| 224 |
% WARN SHIPOUT-UPS: &0 & shouldn't happen \\ |
| 225 |
% WARN TEX-MC-INSERT-MISSING:&0 & shouldn't happen \\ |
| 226 |
% WARN TEX-MC-INSERT-NO-KIDS:&2 & e.g. from empty hbox |
| 227 |
% \end{tabular} |
| 228 |
% |
| 229 |
% \subsection{Info messages from the lua-code} |
| 230 |
% The messages are triggered if the log-level is at least equal to the number. |
| 231 |
% |TAG| messages are from the traversing function, |TEX| from code used in the tagpdf-mc module. |
| 232 |
% |PARENTREE| is the code building the parenttree. |
| 233 |
% |
| 234 |
% \begin{longtable}{>{\ttfamily}lll} |
| 235 |
% message & log-level & remark \\\hline\endhead |
| 236 |
% INFO SHIPOUT-INSERT-LAST-EMC & 3 & finish of shipout code \\ |
| 237 |
% INFO SPACE-FUNCTION-FONT & 3 & interwordspace code \\ |
| 238 |
% INFO TAG-ABSPAGE & 3 \\ |
| 239 |
% INFO TAG-ARGS & 4 \\ |
| 240 |
% INFO TAG-ENDHEAD & 4 \\ |
| 241 |
% INFO TAG-ENDHEAD & 4 \\ |
| 242 |
% INFO TAG-HEAD & 3 \\ |
| 243 |
% INFO TAG-INSERT-ARTIFACT & 3 \\ |
| 244 |
% INFO TAG-INSERT-BDC & 3 \\ |
| 245 |
% INFO TAG-INSERT-EMC & 3 \\ |
| 246 |
% INFO TAG-INSERT-TAG & 3 \\ |
| 247 |
% INFO TAG-KERN-SUBTYPE & 4\\ |
| 248 |
% INFO TAG-MATH-SUBTYPE & 4 \\ |
| 249 |
% INFO TAG-MC-COMPARE & 4 \\ |
| 250 |
% INFO TAG-MC-INTO-PAGE & 3 \\ |
| 251 |
% INFO TAG-NEW-MC-NODE & 4 \\ |
| 252 |
% INFO TAG-NODE & 3 \\ |
| 253 |
% INFO TAG-NO-HEAD & 3 \\ |
| 254 |
% INFO TAG-NOT-TAGGED & 2 & replaced by artifact\\ |
| 255 |
% INFO TAG-QUITTING-BOX & 4 \\ |
| 256 |
% INFO TAG-STORE-MC-KID & 4 \\ |
| 257 |
% INFO TAG-TRAVERSING-BOX 3 \\ |
| 258 |
% INFO TAG-USE-ACTUALTEXT & 3 \\ |
| 259 |
% INFO TAG-USE-ALT & 3 \\ |
| 260 |
% INFO TAG-USE-RAW & 3 \\ |
| 261 |
% INFO TEX-MC-INSERT-KID & 3 \\ |
| 262 |
% INFO TEX-MC-INSERT-KID-TEST & 4 \\ |
| 263 |
% INFO TEX-MC-INTO-STRUCT & 3 \\ |
| 264 |
% INFO TEX-STORE-MC-DATA & 3 \\ |
| 265 |
% INFO TEX-STORE-MC-KID & 3 \\ |
| 266 |
% INFO PARENTTREE-CHUNKS & 3 \\ |
| 267 |
% INFO PARENTTREE-NO-DATA & 3\\ |
| 268 |
% INFO PARENTTREE-NUM & 3 \\ |
| 269 |
% INFO PARENTTREE-NUMENTRY & 3 \\ |
| 270 |
% INFO PARENTTREE-STRUCT-OBJREF & 4 |
| 271 |
% \end{longtable} |
| 272 |
% |
| 273 |
% \subsection{Debug mode messages and code} |
| 274 |
% If the package tagpdf-debug is loaded a number of commands are redefined and |
| 275 |
% enhanced with additional commands which can be used to output debug messages or |
| 276 |
% collect statistics. The commands are present but do nothing if the log-level is zero. |
| 277 |
% \begin{tabular}{llll} |
| 278 |
% command & name & action & remark\\\hline |
| 279 |
% |\tag_mc_begin:n| & mc-begin-insert & msg \\ |
| 280 |
% & mc-begin-ignore & msg & if inactive \\ |
| 281 |
% \end{tabular} |
| 282 |
% |
| 283 |
% \subsection{Messages} |
| 284 |
% \begin{function}{ |
| 285 |
% mc-nested, |
| 286 |
% mc-tag-missing, |
| 287 |
% mc-label-unknown, |
| 288 |
% mc-used-twice, |
| 289 |
% mc-used-twice, |
| 290 |
% mc-not-open, |
| 291 |
% mc-pushed, |
| 292 |
% mc-popped, |
| 293 |
% mc-current} |
| 294 |
% Various messages related to mc-chunks. TODO document their meaning. |
| 295 |
% \end{function} |
| 296 |
% \begin{function}{struct-unknown,struct-no-objnum,struct-orphan,struct-faulty-nesting, |
| 297 |
% struct-missing-tag,struct-used-twice,struct-label-unknown,struct-show-closing} |
| 298 |
% Various messages related to structure. Check the definition in the code for their |
| 299 |
% meaning and the arguments they take. |
| 300 |
% \end{function} |
| 301 |
% |
| 302 |
% \begin{function}{tree-struct-still-open} |
| 303 |
% Message issued at the end of the compilation |
| 304 |
% if there are (beside Root) other open structures on the stack. |
| 305 |
% \end{function} |
| 306 |
% |
| 307 |
% \begin{function}{tree-statistic} |
| 308 |
% Message issued at the end of the compilation |
| 309 |
% showing the number of objects to write |
| 310 |
% \end{function} |
| 311 |
% |
| 312 |
% \begin{function}{show-struct,show-kids} |
| 313 |
% These two messages are used in debug mode |
| 314 |
% to show the current structures in the log and terminal. |
| 315 |
% \end{function} |
| 316 |
% |
| 317 |
|
| 318 |
% \begin{function}{attr-unknown} |
| 319 |
% Message if an attribute i sunknown. |
| 320 |
% \end{function} |
| 321 |
% |
| 322 |
% \begin{function}{role-missing,role-unknown,role-unknown-tag,role-unknown-NS,role-tag,new-tag, |
| 323 |
% role-parent-child-result,role-remapping} |
| 324 |
% Messages related to role mapping. |
| 325 |
% \end{function} |
| 326 |
% |
| 327 |
% \begin{function}{tree-mcid-index-wrong} |
| 328 |
% Used in the tree code, typically indicates the document must be rerun. |
| 329 |
% \end{function} |
| 330 |
% |
| 331 |
% \begin{function}{sys-no-interwordspace} |
| 332 |
% Message if an engine doesn't support inter word spaces |
| 333 |
% \end{function} |
| 334 |
% |
| 335 |
% \begin{function}{para-hook-count-wrong} |
| 336 |
% Message if the number of begin paragraph and end paragraph differ. This normally means faulty structure. |
| 337 |
% \end{function} |
| 338 |
% \end{documentation} |
| 339 |
% \begin{implementation} |
| 340 |
% \begin{macrocode} |
| 341 |
%<@@=tag> |
| 342 |
%<*header> |
| 343 |
\ProvidesExplPackage {tagpdf-checks-code} {2026-05-17} {1.0c} |
| 344 |
{part of tagpdf - code related to checks, conditionals, debugging and messages} |
| 345 |
%</header> |
| 346 |
% \end{macrocode} |
| 347 |
% \section{Messages} |
| 348 |
% |
| 349 |
% \subsection{Messages related to mc-chunks} |
| 350 |
% \begin{macro}{mc-nested} |
| 351 |
% This message is issue is a mc is opened before the previous has been closed. |
| 352 |
% This is not relevant for luamode, as the attributes don't care about this. |
| 353 |
% It is used in the |\@@_check_mc_if_nested:| test. |
| 354 |
% \begin{macrocode} |
| 355 |
%<*package> |
| 356 |
\msg_new:nnn { tag } {mc-nested} { nested~marked~content~found~-~mcid~#1 } |
| 357 |
% \end{macrocode} |
| 358 |
% \end{macro} |
| 359 |
% \begin{macro}{mc-tag-missing} |
| 360 |
% If the tag is missing |
| 361 |
% \begin{macrocode} |
| 362 |
\msg_new:nnn { tag } {mc-tag-missing} { MC-tag~missing;~#1~used~instead~-~mcid~#2 } |
| 363 |
% \end{macrocode} |
| 364 |
% \end{macro} |
| 365 |
% \begin{macro}{mc-label-unknown} |
| 366 |
% If the label of a mc that is used in another place is not known (yet) |
| 367 |
% or has been undefined as the mc was already used. |
| 368 |
% \begin{macrocode} |
| 369 |
\msg_new:nnn { tag } {mc-label-unknown} |
| 370 |
{ label~#1~unknown~or~has~been~already~used.\\ |
| 371 |
Either~rerun~or~remove~one~of~the~uses. } |
| 372 |
% \end{macrocode} |
| 373 |
% \end{macro} |
| 374 |
% \begin{macro}{mc-used-twice} |
| 375 |
% An mc-chunk can be inserted only in one structure. This indicates wrong coding |
| 376 |
% and so should at least give a warning. |
| 377 |
% \begin{macrocode} |
| 378 |
\msg_new:nnn { tag } {mc-used-twice} { mc~#1~has~been~already~used } |
| 379 |
% \end{macrocode} |
| 380 |
% \end{macro} |
| 381 |
% \begin{macro}{mc-not-open} |
| 382 |
% This is issued if a |\tag_mc_end:| is issued wrongly, wrong coding. |
| 383 |
% \begin{macrocode} |
| 384 |
\msg_new:nnn { tag } {mc-not-open} { there~is~no~mc~to~end~at~#1 } |
| 385 |
% \end{macrocode} |
| 386 |
% \end{macro} |
| 387 |
% \begin{macro}{mc-pushed,mc-popped} |
| 388 |
% Informational messages about mc-pushing. |
| 389 |
% \begin{macrocode} |
| 390 |
\msg_new:nnn { tag } {mc-pushed} { #1~has~been~pushed~to~the~mc~stack} |
| 391 |
\msg_new:nnn { tag } {mc-popped} { #1~has~been~removed~from~the~mc~stack } |
| 392 |
% \end{macrocode} |
| 393 |
% \end{macro} |
| 394 |
% \begin{macro}{mc-current} |
| 395 |
% Informational messages about current mc state. |
| 396 |
% \begin{macrocode} |
| 397 |
\msg_new:nnn { tag } {mc-current} |
| 398 |
{ current~MC:~ |
| 399 |
\bool_if:NTF\g_@@_in_mc_bool |
| 400 |
{abscnt=\@@_get_mc_abs_cnt:,~tag=\g_@@_mc_key_tag_tl} |
| 401 |
{no~MC~open,~current~abscnt=\@@_get_mc_abs_cnt:"} |
| 402 |
} |
| 403 |
% \end{macrocode} |
| 404 |
% \end{macro} |
| 405 |
% \subsection{Messages related to structures} |
| 406 |
% \begin{macro}{struct-unknown} |
| 407 |
% if for example a parent key value points to structure that doesn't exist (yet) |
| 408 |
% \begin{macrocode} |
| 409 |
\msg_new:nnn { tag } {struct-unknown} |
| 410 |
{ structure~with~number~#1~doesn't~exist\\ #2 } |
| 411 |
% \end{macrocode} |
| 412 |
% \end{macro} |
| 413 |
% \begin{macro}{struct-no-objnum} |
| 414 |
% Should not happen \ldots |
| 415 |
% \begin{macrocode} |
| 416 |
\msg_new:nnn { tag } {struct-no-objnum} { objnum~missing~for~structure~#1 } |
| 417 |
% \end{macrocode} |
| 418 |
% \end{macro} |
| 419 |
% \begin{macro}{struct-orphan} |
| 420 |
% This indicates that there is a structure which has kids but no parent. |
| 421 |
% This can happen if a structure is stashed but then not used. |
| 422 |
% \begin{macrocode} |
| 423 |
\msg_new:nnn { tag } {struct-orphan} |
| 424 |
{ |
| 425 |
Structure~#1~has~#2~kids~but~no~parent.\\ |
| 426 |
It~is~turned~into~an~artifact.\\ |
| 427 |
Did~you~stashed~a~structure~and~then~didn't~use~it? |
| 428 |
} |
| 429 |
|
| 430 |
% \end{macrocode} |
| 431 |
% \end{macro} |
| 432 |
% \begin{macro}{struct-faulty-nesting} |
| 433 |
% This indicates that there is somewhere one |\tag_struct_end:| too much. |
| 434 |
% This should be normally an error. |
| 435 |
% \begin{macrocode} |
| 436 |
\msg_new:nnn { tag } |
| 437 |
{struct-faulty-nesting} |
| 438 |
{ there~is~no~open~structure~on~the~stack } |
| 439 |
% \end{macrocode} |
| 440 |
% \end{macro} |
| 441 |
% \begin{macro}{struct-missing-tag} |
| 442 |
% A structure must have a tag. |
| 443 |
% \begin{macrocode} |
| 444 |
\msg_new:nnn { tag } {struct-missing-tag} { a~structure~must~have~a~tag! } |
| 445 |
% \end{macrocode} |
| 446 |
% \end{macro} |
| 447 |
% \begin{macro}{struct-used-twice} |
| 448 |
% \begin{macrocode} |
| 449 |
\msg_new:nnn { tag } {struct-used-twice} |
| 450 |
{ structure~with~label~#1~has~already~been~used} |
| 451 |
% \end{macrocode} |
| 452 |
% \end{macro} |
| 453 |
% \begin{macro}{struct-label-unknown} |
| 454 |
% label is unknown, typically needs a rerun. |
| 455 |
% \begin{macrocode} |
| 456 |
\msg_new:nnn { tag } {struct-label-unknown} |
| 457 |
{ structure~with~label~#1~is~unknown~rerun} |
| 458 |
% \end{macrocode} |
| 459 |
% \end{macro} |
| 460 |
% \begin{macro}{struct-show-closing} |
| 461 |
% Informational message shown if log-mode is high enough |
| 462 |
% \begin{macrocode} |
| 463 |
\msg_new:nnn { tag } {struct-show-closing} |
| 464 |
{ closing~structure~#1~tagged~\use:e{\prop_item:cn{g_@@_struct_#1_prop}{S}} } |
| 465 |
% \end{macrocode} |
| 466 |
% \end{macro} |
| 467 |
% |
| 468 |
% \begin{macro}{struct-Ref-unknown} |
| 469 |
% This message is issued at the end, when the Ref keys are updated. |
| 470 |
% TODO: in debug mode it should report more info about the structure. |
| 471 |
% \begin{macrocode} |
| 472 |
\msg_new:nnn { tag } {struct-Ref-unknown} |
| 473 |
{ |
| 474 |
#1~has~no~related~structure.\\ |
| 475 |
/Ref~not~updated. |
| 476 |
} |
| 477 |
% \end{macrocode} |
| 478 |
% \end{macro} |
| 479 |
% \begin{macro}{tree-struct-still-open} |
| 480 |
% Message issued at the end if there are beside Root other |
| 481 |
% open structures on the stack. |
| 482 |
% \begin{macrocode} |
| 483 |
\msg_new:nnn { tag } {tree-struct-still-open} |
| 484 |
{ |
| 485 |
There~are~still~open~structures~on~the~stack!\\ |
| 486 |
The~stack~contains~\seq_use:Nn\g_@@_struct_tag_stack_seq{,}.\\ |
| 487 |
The~structures~are~automatically~closed,\\ |
| 488 |
but~their~nesting~can~be~wrong. |
| 489 |
} |
| 490 |
% \end{macrocode} |
| 491 |
% \end{macro} |
| 492 |
% |
| 493 |
% \begin{macro}{tree-statistic} |
| 494 |
% Message issued at the end showing the estimated number of |
| 495 |
% structures and MC-childs |
| 496 |
% \begin{macrocode} |
| 497 |
\msg_new:nnn { tag } {tree-statistic} |
| 498 |
{ |
| 499 |
Finalizing~the~tagging~structure:\\ |
| 500 |
Writing~out~\c_tilde_str |
| 501 |
\int_use:N\c@g_@@_struct_abs_int\c_space_tl~structure~objects\\ |
| 502 |
with~\c_tilde_str |
| 503 |
\int_use:N\c@g_@@_MCID_abs_int\c_space_tl'MC'~leaf~nodes.\\ |
| 504 |
Be~patient~if~there~are~lots~of~objects! |
| 505 |
} |
| 506 |
%</package> |
| 507 |
% \end{macrocode} |
| 508 |
% \end{macro} |
| 509 |
% The following messages are only needed in debug mode. |
| 510 |
% \begin{macro}{show-struct,show-kids} |
| 511 |
% This two messages are used to show the current structures in the log and terminal. |
| 512 |
% \begin{macrocode} |
| 513 |
%<*debug> |
| 514 |
\msg_new:nnn { tag/debug } { show-struct } |
| 515 |
{ |
| 516 |
=========================\\ |
| 517 |
The~structure~#1~ |
| 518 |
\tl_if_empty:nTF {#2} |
| 519 |
{ is~empty \\>~ . } |
| 520 |
{ contains: #2 } |
| 521 |
\\ |
| 522 |
} |
| 523 |
\msg_new:nnn { tag/debug } { show-kids } |
| 524 |
{ |
| 525 |
The~structure~has~the~following~kids: |
| 526 |
\tl_if_empty:nTF {#2} |
| 527 |
{ \\>~ NONE } |
| 528 |
{ #2 } |
| 529 |
\\ |
| 530 |
========================= |
| 531 |
} |
| 532 |
%</debug> |
| 533 |
% \end{macrocode} |
| 534 |
% \end{macro} |
| 535 |
% \subsection{Attributes} |
| 536 |
% Not much yet, as attributes aren't used so much. |
| 537 |
% \begin{macro}{attr-unknown} |
| 538 |
% \begin{macrocode} |
| 539 |
%<*package> |
| 540 |
\msg_new:nnn { tag } {attr-unknown} { attribute~#1~is~unknown} |
| 541 |
% \end{macrocode} |
| 542 |
% \end{macro} |
| 543 |
% |
| 544 |
% \subsection{Roles} |
| 545 |
% \begin{macro}{role-missing,role-unknown,role-unknown-tag,role-unknown-NS} |
| 546 |
% Warning message if either the tag or the role is missing |
| 547 |
% \begin{macrocode} |
| 548 |
\msg_new:nnn { tag } {role-missing} { tag~#1~has~no~role~assigned } |
| 549 |
\msg_new:nnn { tag } {role-unknown} { role~#1~is~not~known } |
| 550 |
\msg_new:nnn { tag } {role-unknown-tag} { tag~#1~is~not~known } |
| 551 |
\msg_new:nnn { tag } {role-unknown-NS} { \tl_if_empty:nTF{#1}{Empty~NS}{NS~#1~is~not~known} } |
| 552 |
% \end{macrocode} |
| 553 |
% \end{macro} |
| 554 |
% \begin{macro}{role-parent-child-check} |
| 555 |
% This is an info message that inform which elements are checked, typically |
| 556 |
% used to show the original tags, not the rolemapped one. |
| 557 |
% \begin{macrocode} |
| 558 |
\msg_new:nnn { tag } {role-parent-child-check} |
| 559 |
{ Checking~Parent-Child~'#1'~-->~'#2' } |
| 560 |
% \end{macrocode} |
| 561 |
% \end{macro} |
| 562 |
% \begin{macro}{role-parent-child-result} |
| 563 |
% This is info and warning message about the containment rules between child and |
| 564 |
% parent tags. |
| 565 |
% \begin{macrocode} |
| 566 |
\msg_new:nnn { tag } {role-parent-child-result} |
| 567 |
{ Parent-Child~'#1'~-->~'#2'.\\Relation~is~#3~\msg_line_context:} |
| 568 |
% \end{macrocode} |
| 569 |
% \end{macro} |
| 570 |
% \begin{macro}{role-struct-parent-child-forbidden} |
| 571 |
% The most important message is that the relation |
| 572 |
% is not allowed between two structures. |
| 573 |
% Argument \#1 is the parent structure number, \#2 is the child structure number, |
| 574 |
% \#3 NS:tag info of the parent (TODO perhaps rolemapped), |
| 575 |
% \#4 NS:tag of the child. (TODO ) |
| 576 |
% \begin{macrocode} |
| 577 |
\msg_new:nnn { tag } {role-struct-parent-child-forbidden} |
| 578 |
{ |
| 579 |
Parent-Child~'#3'~-->~'#4'.\\ |
| 580 |
Relation~is~not~allowed! ~\msg_line_context:\\ |
| 581 |
struct~#1,~ |
| 582 |
\exp_last_unbraced:Ne\use_i:nn { \prop_item:cn{ g_@@_struct_#1_prop}{tag} } |
| 583 |
\c_space_tl-->\c_space_tl |
| 584 |
struct~#2,~ |
| 585 |
\exp_last_unbraced:Ne\use_i:nn { \prop_item:cn{ g_@@_struct_#2_prop}{tag} } |
| 586 |
} |
| 587 |
% \end{macrocode} |
| 588 |
% \end{macro} |
| 589 |
% \begin{macro}{role-MC-child-forbidden} |
| 590 |
% In case that MC is forbidden we use |
| 591 |
% a special message. |
| 592 |
% Argument \#1 is the parent structure number. \#2 NS:tag of the parent, |
| 593 |
% \begin{macrocode} |
| 594 |
\msg_new:nnn { tag } {role-MC-child-forbidden} |
| 595 |
{ |
| 596 |
Parent-Child~'#2'~-->~'MC~(real~content)'.\\ |
| 597 |
Relation~is~not~allowed! ~\msg_line_context:\\ |
| 598 |
struct~#1,~ |
| 599 |
\exp_last_unbraced:Ne\use_i:nn { \prop_item:cn{ g_@@_struct_#1_prop}{tag} } |
| 600 |
} |
| 601 |
% \end{macrocode} |
| 602 |
% \end{macro} |
| 603 |
% \begin{macro}{role-parent-child-forbidden} |
| 604 |
% The most important message is that the relation is not allowed. |
| 605 |
% Argument \#1 is the parent structure number. \#2 NS:tag of the parent, |
| 606 |
% \#3 NS:tag of the child. |
| 607 |
% \begin{macrocode} |
| 608 |
\msg_new:nnn { tag } {role-parent-child-forbidden} |
| 609 |
{ |
| 610 |
Parent-Child~'#2'~-->~'#3'.\\ |
| 611 |
Relation~is~not~allowed! ~\msg_line_context:\\ |
| 612 |
struct~#1,~\prop_item:cn{ g_@@_struct_#1_prop}{S} |
| 613 |
\c_space_tl |
| 614 |
\str_if_eq:nnF{#3}{MC~(realcontent)} |
| 615 |
{-->~struct~\int_eval:n {\c@g_@@_struct_abs_int}} |
| 616 |
} |
| 617 |
% \end{macrocode} |
| 618 |
% \end{macro} |
| 619 |
|
| 620 |
% \begin{macro}{\@@_check_forbidden_parent_child:nnnn} |
| 621 |
% \begin{macrocode} |
| 622 |
\cs_new_protected:Npn \@@_check_forbidden_parent_child:nnnn #1#2#3#4 |
| 623 |
% #1 check number, #2 number of parent struct |
| 624 |
% #3 parent info, #4 child info |
| 625 |
{ |
| 626 |
\int_compare:nNnT {#1 } <0 |
| 627 |
{ |
| 628 |
\msg_warning:nneee |
| 629 |
{ tag } |
| 630 |
{role-parent-child-forbidden} |
| 631 |
{ #2} |
| 632 |
{ #3 } |
| 633 |
{ #4 } |
| 634 |
} |
| 635 |
} |
| 636 |
\cs_generate_variant:Nn \@@_check_forbidden_parent_child:nnnn {nnee} |
| 637 |
|
| 638 |
% new with structure numbers: |
| 639 |
\cs_new_protected:Npn \@@_check_struct_forbidden_parent_child:nnn #1#2#3 |
| 640 |
% #1 check number, |
| 641 |
% #2 number of parent struct |
| 642 |
% #3 number of child struct |
| 643 |
{ |
| 644 |
\int_compare:nNnT {#1 } <0 |
| 645 |
{ |
| 646 |
\prop_get:cnN {g_@@_struct_#2_prop}{parentrole}\l_@@_get_parent_tmpc_tl |
| 647 |
\prop_get:cnN {g_@@_struct_#3_prop}{rolemap}\l_@@_get_child_tmpc_tl |
| 648 |
\msg_warning:nneeee |
| 649 |
{ tag } |
| 650 |
{role-struct-parent-child-forbidden} |
| 651 |
{ #2 } |
| 652 |
{ #3 } |
| 653 |
{ |
| 654 |
\exp_last_unbraced:No \use_ii:nn { \l_@@_get_parent_tmpc_tl } |
| 655 |
: |
| 656 |
\exp_last_unbraced:No \use_i:nn {\l_@@_get_parent_tmpc_tl } |
| 657 |
} |
| 658 |
{ |
| 659 |
\exp_last_unbraced:No \use_ii:nn { \l_@@_get_child_tmpc_tl } |
| 660 |
: |
| 661 |
\exp_last_unbraced:No \use_i:nn { \l_@@_get_child_tmpc_tl } |
| 662 |
} |
| 663 |
} |
| 664 |
} |
| 665 |
\cs_generate_variant:Nn\@@_check_struct_forbidden_parent_child:nnn{onn} |
| 666 |
% \end{macrocode} |
| 667 |
% \end{macro} |
| 668 |
% |
| 669 |
% \begin{macro}{role-parent-child-unresolved} |
| 670 |
% If a structure is stashed and then used later and its root is one |
| 671 |
% of Part, Div or NonStruct, then we can not check the parent-child |
| 672 |
% rules. This would require to know all children. In this case we only |
| 673 |
% warn. |
| 674 |
% resolved a |
| 675 |
% Argument \#1 is the parent structure number. \#2 NS:tag of the parent, |
| 676 |
% \#3 NS:tag of the child. |
| 677 |
% \begin{macrocode} |
| 678 |
\msg_new:nnn { tag } {role-parent-child-unresolved} |
| 679 |
{ |
| 680 |
Structure~\int_eval:n {\c@g_@@_struct_abs_int}~was~moved~into~structure~#1.\\ |
| 681 |
Parent-Child~'#2'~-->~'#3'~can~not~checked. |
| 682 |
} |
| 683 |
% \end{macrocode} |
| 684 |
% \end{macro} |
| 685 |
% |
| 686 |
% \begin{macro}{\@@_check_unresolved_parent_child:nnnn} |
| 687 |
% \begin{macrocode} |
| 688 |
\cs_new_protected:Npn \@@_check_unresolved_parent_child:nnnn #1#2#3#4 |
| 689 |
% #1 check number, #2 number of parent struct |
| 690 |
% #3 parent info, #4 child info |
| 691 |
{ |
| 692 |
\int_compare:nNnT { #1 } = {\c_@@_role_rule_checkparent_tl} |
| 693 |
{ |
| 694 |
\msg_warning:nneee |
| 695 |
{ tag } |
| 696 |
{role-parent-child-unresolved} |
| 697 |
{ #2 } |
| 698 |
{ #3 } |
| 699 |
{ #4 } |
| 700 |
} |
| 701 |
} |
| 702 |
% \end{macrocode} |
| 703 |
% \end{macro} |
| 704 |
% |
| 705 |
% \begin{macro}{tag/check/parent-child,tag/check/parent-child-end,} |
| 706 |
% Sockets used around the parent-child checks so that we can disable them. |
| 707 |
% \begin{macrocode} |
| 708 |
\socket_new:nn{tag/check/parent-child}{1} |
| 709 |
\socket_new:nn{tag/check/parent-child-end}{0} |
| 710 |
\socket_new_plug:nnn {tag/check/parent-child-end}{check} |
| 711 |
{ |
| 712 |
\sys_if_engine_luatex:T |
| 713 |
{ |
| 714 |
\lua_now:e |
| 715 |
{ |
| 716 |
ltx.@@.func.check_parent_child_rules ( 2 ) |
| 717 |
} |
| 718 |
} |
| 719 |
} |
| 720 |
% \end{macrocode} |
| 721 |
% And a key to disable the check |
| 722 |
% \begin{macrocode} |
| 723 |
\keys_define:nn { @@ / setup} |
| 724 |
{ |
| 725 |
debug / parent-child-check .choice:, |
| 726 |
debug / parent-child-check / on .code:n = |
| 727 |
{ |
| 728 |
\socket_assign_plug:nn {tag/check/parent-child}{identity} |
| 729 |
}, |
| 730 |
debug / parent-child-check / off .code:n= |
| 731 |
{ |
| 732 |
\socket_assign_plug:nn {tag/check/parent-child}{noop} |
| 733 |
\socket_assign_plug:nn {tag/check/parent-child-end}{noop} |
| 734 |
}, |
| 735 |
debug / parent-child-check / atend .code:n= |
| 736 |
{ |
| 737 |
\socket_assign_plug:nn {tag/check/parent-child}{noop} |
| 738 |
\socket_assign_plug:nn {tag/check/parent-child-end}{check} |
| 739 |
} |
| 740 |
} |
| 741 |
% \end{macrocode} |
| 742 |
% \end{macro} |
| 743 |
% |
| 744 |
% |
| 745 |
% \begin{macro}{role-remapping} |
| 746 |
% This is info and warning message about role-remapping |
| 747 |
% \begin{macrocode} |
| 748 |
\msg_new:nnn { tag } {role-remapping} |
| 749 |
{ remapping~tag~to~#1 } |
| 750 |
% \end{macrocode} |
| 751 |
% \end{macro} |
| 752 |
% \begin{macro}{role-tag,new-tag} |
| 753 |
% Info messages. |
| 754 |
% \begin{macrocode} |
| 755 |
\msg_new:nnn { tag } {role-tag} { mapping~tag~#1~to~role~#2 } |
| 756 |
\msg_new:nnn { tag } {new-tag} { adding~new~tag~#1 } |
| 757 |
\msg_new:nnn { tag } {read-namespace} { reading~namespace~definitions~tagpdf-ns-#1.def } |
| 758 |
\msg_new:nnn { tag } {namespace-missing}{ namespace~definitions~tagpdf-ns-#1.def~not~found } |
| 759 |
\msg_new:nnn { tag } {namespace-unknown}{ namespace~#1~is~not~declared } |
| 760 |
% \end{macrocode} |
| 761 |
% \end{macro} |
| 762 |
% |
| 763 |
% \subsection{Miscellaneous} |
| 764 |
% \begin{macro}{wrong-pdfversion} |
| 765 |
% Used a begin document if the pdfversion has been changed after the reading. |
| 766 |
% \begin{macrocode} |
| 767 |
\msg_new:nnn { tag } {wrong-pdfversion} |
| 768 |
{ |
| 769 |
The~PDF~version~has~changed~after~the~loading~of~tagpdf~from~#1~to~#2.\\ |
| 770 |
The~structure~will~be~faulty.\\ |
| 771 |
Trying~to~revert~to~#1. |
| 772 |
} |
| 773 |
% \end{macrocode} |
| 774 |
% \end{macro} |
| 775 |
% \begin{macro}{tree-mcid-index-wrong} |
| 776 |
% Used in the tree code, typically indicates the document must be rerun. |
| 777 |
% \begin{macrocode} |
| 778 |
\msg_new:nnn { tag } {tree-mcid-index-wrong} |
| 779 |
{something~is~wrong~with~the~mcid--rerun} |
| 780 |
% \end{macrocode} |
| 781 |
% \end{macro} |
| 782 |
% \begin{macro}{sys-no-interwordspace} |
| 783 |
% Currently only pdflatex and lualatex have some support for real spaces. |
| 784 |
% \begin{macrocode} |
| 785 |
\msg_new:nnn { tag } {sys-no-interwordspace} |
| 786 |
{engine/output~mode~#1~doesn't~support~the~interword~spaces} |
| 787 |
% \end{macrocode} |
| 788 |
% \end{macro} |
| 789 |
% |
| 790 |
% \begin{macro}{\@@_check_typeout_v:n} |
| 791 |
% A simple logging function. By default is gobbles its argument, but |
| 792 |
% the log-keys sets it to typeout. |
| 793 |
% \begin{macrocode} |
| 794 |
\cs_set_eq:NN \@@_check_typeout_v:n \use_none:n |
| 795 |
% \end{macrocode} |
| 796 |
% \end{macro} |
| 797 |
% |
| 798 |
% \begin{macro}{para-hook-count-wrong} |
| 799 |
% At the end of the document we check if the count of para-begin and para-end is |
| 800 |
% identical. If not we issue a warning: this is normally a coding error and |
| 801 |
% and breaks the structure. |
| 802 |
% \begin{macrocode} |
| 803 |
\msg_new:nnnn { tag } {para-hook-count-wrong} |
| 804 |
{The~number~of~automatic~begin~(#1)~and~end~(#2)~#3~para~hooks~differ!} |
| 805 |
{This~quite~probably~a~coding~error~and~the~structure~will~be~wrong!} |
| 806 |
%</package> |
| 807 |
% \end{macrocode} |
| 808 |
% \end{macro} |
| 809 |
% \section{Retrieving data} |
| 810 |
% \begin{macro}[EXP]{\tag_get:n} |
| 811 |
% This retrieves some data. |
| 812 |
% This is a generic command to retrieve data. Currently |
| 813 |
% the only sensible values for the argument are |mc_tag|, |struct_tag| |
| 814 |
% and |struct_num|. |
| 815 |
% \begin{macrocode} |
| 816 |
%<base>\cs_new:Npn \tag_get:n #1 { \use:c {@@_get_data_#1: } } |
| 817 |
% \end{macrocode} |
| 818 |
% \end{macro} |
| 819 |
% |
| 820 |
% \section{PDF version check} |
| 821 |
% \begin{macrocode} |
| 822 |
%<*package> |
| 823 |
\tl_const:Ne\c_@@_check_pdfversion_tl {\pdf_version:} |
| 824 |
\AddToHook{begindocument/before} |
| 825 |
{ |
| 826 |
\tl_if_eq:eeF{\c_@@_check_pdfversion_tl}{\pdf_version:} |
| 827 |
{ |
| 828 |
\msg_error:nnee {tag}{wrong-pdfversion}{\c_@@_check_pdfversion_tl}{\pdf_version:} |
| 829 |
\pdf_version_gset:e {\c_@@_check_pdfversion_tl} |
| 830 |
\pdf_object_unnamed_write:nn{dict}{} |
| 831 |
} |
| 832 |
} |
| 833 |
%</package> |
| 834 |
% \end{macrocode} |
| 835 |
% \section{User conditionals} |
| 836 |
% \begin{macro}[pTF]{\tag_if_active:} |
| 837 |
% This tests if tagging is active. This allows packages |
| 838 |
% to add conditional code. |
| 839 |
% The test is true if all booleans, the global and the two local one are true. |
| 840 |
% \changes{v0.99j}{2024-11-22}{test if it exists already in the kernel} |
| 841 |
% \begin{macrocode} |
| 842 |
%<*base> |
| 843 |
\cs_if_exist:NF\tag_if_active:T |
| 844 |
{ |
| 845 |
\prg_new_conditional:Npnn \tag_if_active: { p , T , TF, F } |
| 846 |
{ \prg_return_false: } |
| 847 |
} |
| 848 |
%</base> |
| 849 |
%<*package> |
| 850 |
\prg_set_conditional:Npnn \tag_if_active: { p , T , TF, F } |
| 851 |
{ |
| 852 |
\bool_lazy_all:nTF |
| 853 |
{ |
| 854 |
{\g_@@_active_struct_bool} |
| 855 |
{\g_@@_active_mc_bool} |
| 856 |
{\g_@@_active_tree_bool} |
| 857 |
{\l_@@_active_struct_bool} |
| 858 |
{\l_@@_active_mc_bool} |
| 859 |
} |
| 860 |
{ |
| 861 |
\prg_return_true: |
| 862 |
} |
| 863 |
{ |
| 864 |
\prg_return_false: |
| 865 |
} |
| 866 |
} |
| 867 |
%</package> |
| 868 |
% \end{macrocode} |
| 869 |
% \end{macro} |
| 870 |
% |
| 871 |
% \begin{macro}[pTF]{\tag_if_box_tagged:N} |
| 872 |
% This tests if a box contains tagging commands. |
| 873 |
% It relies on that the code that saved the box correctly set |
| 874 |
% \verb+\l_tag_box_<box number>_tl+ to a positive value. |
| 875 |
% The LaTeX commands will do that automatically |
| 876 |
% at some time but it is in the responsibility of the user to |
| 877 |
% ensure that when using low-level code. |
| 878 |
% If the internal command doesn't exist the box is assumed to be untagged. |
| 879 |
% \begin{macrocode} |
| 880 |
%<*base> |
| 881 |
\prg_new_conditional:Npnn \tag_if_box_tagged:N #1 {p,T,F,TF} |
| 882 |
{ |
| 883 |
\tl_if_exist:cTF {l_tag_box_\int_use:N #1_tl} |
| 884 |
{ |
| 885 |
\int_compare:nNnTF {0\tl_use:c{l_tag_box_\int_use:N #1_tl}}>{0} |
| 886 |
{ \prg_return_true: } |
| 887 |
{ \prg_return_false: } |
| 888 |
} |
| 889 |
{ |
| 890 |
\prg_return_false: |
| 891 |
% warning?? |
| 892 |
} |
| 893 |
} |
| 894 |
%</base> |
| 895 |
% \end{macrocode} |
| 896 |
% \end{macro} |
| 897 |
% |
| 898 |
% |
| 899 |
% \begin{macro}{\tag_if_in:n} |
| 900 |
% This tests if we are in a specific structure, so if the structure is part of the |
| 901 |
% current stack. The argument must be a standard structure |
| 902 |
% type as no role mapping is applied. The main use case is to test if we are in a |
| 903 |
% paragraph P. |
| 904 |
% \begin{macrocode} |
| 905 |
%<*package> |
| 906 |
\prg_new_conditional:Npnn\tag_if_in:n #1 {T,F,TF} |
| 907 |
{ |
| 908 |
\seq_if_in:NnTF \g_@@_struct_roletag_stack_seq {#1} |
| 909 |
{\prg_return_true:} |
| 910 |
{\prg_return_false:} |
| 911 |
} |
| 912 |
%</package> |
| 913 |
% \end{macrocode} |
| 914 |
% \end{macro} |
| 915 |
% |
| 916 |
% \section{Internal checks} |
| 917 |
% These are checks used in various places in the code. |
| 918 |
% |
| 919 |
% \subsection{checks for active tagging} |
| 920 |
% \begin{macro}[TF]{\@@_check_if_active_mc:,\@@_check_if_active_struct:} |
| 921 |
% This checks if mc are active. |
| 922 |
% \begin{macrocode} |
| 923 |
%<*package> |
| 924 |
\prg_new_conditional:Npnn \@@_check_if_active_mc: {T,F,TF} |
| 925 |
{ |
| 926 |
\bool_lazy_and:nnTF { \g_@@_active_mc_bool } { \l_@@_active_mc_bool } |
| 927 |
{ |
| 928 |
\prg_return_true: |
| 929 |
} |
| 930 |
{ |
| 931 |
\prg_return_false: |
| 932 |
} |
| 933 |
} |
| 934 |
\prg_new_conditional:Npnn \@@_check_if_active_struct: {T,F,TF} |
| 935 |
{ |
| 936 |
\bool_lazy_and:nnTF { \g_@@_active_struct_bool } { \l_@@_active_struct_bool } |
| 937 |
{ |
| 938 |
\prg_return_true: |
| 939 |
} |
| 940 |
{ |
| 941 |
\prg_return_false: |
| 942 |
} |
| 943 |
} |
| 944 |
% \end{macrocode} |
| 945 |
% \end{macro} |
| 946 |
% \subsection{Checks related to structures} |
| 947 |
% \begin{macro}{\@@_check_structure_has_tag:n} |
| 948 |
% Structures must have a tag, so we check if the S entry is in the property. |
| 949 |
% It is an error if this is missing. The argument is a number. |
| 950 |
% The tests for existence and type is split in structures, |
| 951 |
% as the tags are stored differently to the mc case. |
| 952 |
% \begin{macrocode} |
| 953 |
\cs_new_protected:Npn \@@_check_structure_has_tag:n #1 %#1 struct num |
| 954 |
{ |
| 955 |
\prop_get:cnNF |
| 956 |
{ g_@@_struct_#1_prop } |
| 957 |
{S} |
| 958 |
\l_@@_tmp_unused_tl |
| 959 |
{ |
| 960 |
\msg_error:nn { tag } {struct-missing-tag} |
| 961 |
} |
| 962 |
} |
| 963 |
% \end{macrocode} |
| 964 |
% \end{macro} |
| 965 |
% \begin{macro}{\@@_check_structure_tag:N} |
| 966 |
% This checks if the name of the tag is known, |
| 967 |
% either because it is a standard type or has been rolemapped. |
| 968 |
% This always used with commands, so the argument is N. |
| 969 |
% \begin{macrocode} |
| 970 |
\cs_new_protected:Npn \@@_check_structure_tag:N #1 |
| 971 |
{ |
| 972 |
\prop_get:NoNF \g_@@_role_tags_NS_prop {#1}\l_@@_tmp_unused_tl |
| 973 |
{ |
| 974 |
\msg_warning:nne { tag } {role-unknown-tag} {#1} |
| 975 |
} |
| 976 |
} |
| 977 |
% \end{macrocode} |
| 978 |
% \end{macro} |
| 979 |
% \begin{macro}{\@@_check_info_closing_struct:n} |
| 980 |
% This info message is issued at a closing structure, the use should be guarded by |
| 981 |
% log-level. |
| 982 |
% \begin{macrocode} |
| 983 |
\cs_new_protected:Npn \@@_check_info_closing_struct:n #1 %#1 struct num |
| 984 |
{ |
| 985 |
\int_compare:nNnT {\l_@@_loglevel_int} > { 0 } |
| 986 |
{ |
| 987 |
\msg_info:nnn { tag } {struct-show-closing} {#1} |
| 988 |
} |
| 989 |
} |
| 990 |
|
| 991 |
\cs_generate_variant:Nn \@@_check_info_closing_struct:n {o,e} |
| 992 |
% \end{macrocode} |
| 993 |
% \end{macro} |
| 994 |
% \begin{macro}{\@@_check_no_open_struct:} |
| 995 |
% This checks if there is an open structure. It should be used when trying to |
| 996 |
% close a structure. It errors if false.% |
| 997 |
% \begin{macrocode} |
| 998 |
\cs_new_protected:Npn \@@_check_no_open_struct: |
| 999 |
{ |
| 1000 |
\msg_error:nn { tag } {struct-faulty-nesting} |
| 1001 |
} |
| 1002 |
% \end{macrocode} |
| 1003 |
% \end{macro} |
| 1004 |
% \begin{macro}{\@@_check_struct_used:n} |
| 1005 |
% This checks if a stashed structure has already been used. |
| 1006 |
% \begin{macrocode} |
| 1007 |
\cs_new_protected:Npn \@@_check_struct_used:n #1 %#1 label |
| 1008 |
{ |
| 1009 |
\prop_get:cnNT |
| 1010 |
{g_@@_struct_\property_ref:enn{tagpdfstruct-#1}{tagstruct}{unknown}_prop} |
| 1011 |
{parentnum} |
| 1012 |
\l_@@_tmpa_tl |
| 1013 |
{ |
| 1014 |
\msg_warning:nnn { tag } {struct-used-twice} {#1} |
| 1015 |
} |
| 1016 |
} |
| 1017 |
% \end{macrocode} |
| 1018 |
% \end{macro} |
| 1019 |
% |
| 1020 |
% \subsection{Checks related to roles} |
| 1021 |
% \begin{macro}{\@@_check_add_tag_role:nn} |
| 1022 |
% This check is used when defining a new role mapping. |
| 1023 |
% \begin{macrocode} |
| 1024 |
\cs_new_protected:Npn \@@_check_add_tag_role:nn #1 #2 %#1 tag, #2 role |
| 1025 |
{ |
| 1026 |
\tl_if_empty:nTF {#2} |
| 1027 |
{ |
| 1028 |
\msg_error:nnn { tag } {role-missing} {#1} |
| 1029 |
} |
| 1030 |
{ |
| 1031 |
\prop_get:NnNTF \g_@@_role_tags_NS_prop {#2} \l_@@_tmpa_tl |
| 1032 |
{ |
| 1033 |
\int_compare:nNnT {\l_@@_loglevel_int} > { 0 } |
| 1034 |
{ |
| 1035 |
\msg_info:nnnn { tag } {role-tag} {#1} {#2} |
| 1036 |
} |
| 1037 |
} |
| 1038 |
{ |
| 1039 |
\msg_error:nnn { tag } {role-unknown} {#2} |
| 1040 |
} |
| 1041 |
} |
| 1042 |
} |
| 1043 |
% \end{macrocode} |
| 1044 |
% Similar with a namespace |
| 1045 |
% \begin{macrocode} |
| 1046 |
\cs_new_protected:Npn \@@_check_add_tag_role:nnn #1 #2 #3 %#1 tag/NS, #2 role #3 namespace |
| 1047 |
{ |
| 1048 |
\tl_if_empty:nTF {#2} |
| 1049 |
{ |
| 1050 |
\msg_error:nnn { tag } {role-missing} {#1} |
| 1051 |
} |
| 1052 |
{ |
| 1053 |
\prop_get:cnNTF { g_@@_role_NS_#3_prop } {#2} \l_@@_tmpa_tl |
| 1054 |
{ |
| 1055 |
\int_compare:nNnT {\l_@@_loglevel_int} > { 0 } |
| 1056 |
{ |
| 1057 |
\msg_info:nnnn { tag } {role-tag} {#1} {#2/#3} |
| 1058 |
} |
| 1059 |
} |
| 1060 |
{ |
| 1061 |
\msg_error:nnn { tag } {role-unknown} {#2/#3} |
| 1062 |
} |
| 1063 |
} |
| 1064 |
} |
| 1065 |
% \end{macrocode} |
| 1066 |
% \end{macro} |
| 1067 |
|
| 1068 |
% \subsection{Check related to mc-chunks} |
| 1069 |
% |
| 1070 |
% \begin{macro}{\@@_check_mc_if_nested:,\@@_check_mc_if_open:} |
| 1071 |
% Two tests if a mc is currently open. One for the true (for begin |
| 1072 |
% code), one for the false part (for end code). |
| 1073 |
% \begin{macrocode} |
| 1074 |
\cs_new_protected:Npn \@@_check_mc_if_nested: |
| 1075 |
{ |
| 1076 |
\@@_mc_if_in:T |
| 1077 |
{ |
| 1078 |
\msg_warning:nne { tag } {mc-nested} { \@@_get_mc_abs_cnt: } |
| 1079 |
} |
| 1080 |
} |
| 1081 |
|
| 1082 |
\cs_new_protected:Npn \@@_check_mc_if_open: |
| 1083 |
{ |
| 1084 |
\@@_mc_if_in:F |
| 1085 |
{ |
| 1086 |
\msg_warning:nne { tag } {mc-not-open} { \@@_get_mc_abs_cnt: } |
| 1087 |
} |
| 1088 |
} |
| 1089 |
% \end{macrocode} |
| 1090 |
% \end{macro} |
| 1091 |
% \begin{macro}{\@@_check_mc_pushed_popped:nn} |
| 1092 |
% This creates an information message if mc's are pushed or popped. |
| 1093 |
% The first argument is a word (pushed or popped), the second the tag name. |
| 1094 |
% With larger log-level the stack is shown too. |
| 1095 |
% \begin{macrocode} |
| 1096 |
\cs_new_protected:Npn \@@_check_mc_pushed_popped:nn #1 #2 |
| 1097 |
{ |
| 1098 |
\int_compare:nNnT |
| 1099 |
{ \l_@@_loglevel_int } ={ 2 } |
| 1100 |
{ \msg_info:nne {tag}{mc-#1}{#2} } |
| 1101 |
\int_compare:nNnT |
| 1102 |
{ \l_@@_loglevel_int } > { 2 } |
| 1103 |
{ |
| 1104 |
\msg_info:nne {tag}{mc-#1}{#2} |
| 1105 |
\seq_log:N \g_@@_mc_stack_seq |
| 1106 |
} |
| 1107 |
} |
| 1108 |
% \end{macrocode} |
| 1109 |
% \end{macro} |
| 1110 |
% \begin{macro}{\@@_check_mc_tag:N} |
| 1111 |
% This checks if the mc has a (known) tag, if it is empty |
| 1112 |
% (e.g. if due to a call to the output routine, see issue https://github.com/latex3/tagpdf/issues/111) |
| 1113 |
% then we fall back to the structure name. |
| 1114 |
% \begin{macrocode} |
| 1115 |
\cs_new_protected:Npn \@@_check_mc_tag:N #1 %#1 is var with a tag name in it |
| 1116 |
{ |
| 1117 |
\tl_if_empty:NTF #1 |
| 1118 |
{ |
| 1119 |
\tl_set:No #1 { \g_@@_struct_tag_tl } |
| 1120 |
\msg_info:nnee { tag } {mc-tag-missing} { \g_@@_struct_tag_tl }{ \@@_get_mc_abs_cnt: } |
| 1121 |
} |
| 1122 |
{ |
| 1123 |
\prop_get:NoNF \g_@@_role_tags_NS_prop {#1}\l_@@_tmp_unused_tl |
| 1124 |
{ |
| 1125 |
\msg_warning:nne { tag } {role-unknown-tag} {#1} |
| 1126 |
} |
| 1127 |
} |
| 1128 |
} |
| 1129 |
% \end{macrocode} |
| 1130 |
% \end{macro} |
| 1131 |
% |
| 1132 |
% \begin{variable}{\g_@@_check_mc_used_intarray, \@@_check_init_mc_used:} |
| 1133 |
% This variable holds the list of used mc numbers. |
| 1134 |
% Everytime we store a mc-number we will add one the relevant array index |
| 1135 |
% If everything is right at the end there should be only 1 until the max count |
| 1136 |
% of the mcid. 2 indicates that one mcid was used twice, 0 that we lost one. |
| 1137 |
% In engines other than luatex the total number of all intarray entries |
| 1138 |
% are restricted so we use only a rather small value of 65536, and we initialize |
| 1139 |
% the array only at first used, guarded by the log-level. |
| 1140 |
% This check is probably only needed for debugging. |
| 1141 |
% TODO does this really make sense to check? When can it happen?? |
| 1142 |
% \begin{macrocode} |
| 1143 |
\cs_new_protected:Npn \@@_check_init_mc_used: |
| 1144 |
{ |
| 1145 |
\intarray_new:Nn \g_@@_check_mc_used_intarray { 65536 } |
| 1146 |
\cs_gset_eq:NN \@@_check_init_mc_used: \prg_do_nothing: |
| 1147 |
} |
| 1148 |
% \end{macrocode} |
| 1149 |
% \end{variable} |
| 1150 |
% |
| 1151 |
% \begin{macro}{\@@_check_mc_used:n} |
| 1152 |
% This checks if a mc is used twice. |
| 1153 |
% \begin{macrocode} |
| 1154 |
\cs_new_protected:Npn \@@_check_mc_used:n #1 %#1 mcid abscnt |
| 1155 |
{ |
| 1156 |
\int_compare:nNnT {\l_@@_loglevel_int} > { 2 } |
| 1157 |
{ |
| 1158 |
\@@_check_init_mc_used: |
| 1159 |
\intarray_gset:Nnn \g_@@_check_mc_used_intarray |
| 1160 |
{#1} |
| 1161 |
{ \intarray_item:Nn \g_@@_check_mc_used_intarray {#1} + 1 } |
| 1162 |
\int_compare:nNnT |
| 1163 |
{ |
| 1164 |
\intarray_item:Nn \g_@@_check_mc_used_intarray {#1} |
| 1165 |
} |
| 1166 |
> |
| 1167 |
{ 1 } |
| 1168 |
{ |
| 1169 |
\msg_warning:nnn { tag } {mc-used-twice} {#1} |
| 1170 |
} |
| 1171 |
} |
| 1172 |
} |
| 1173 |
% \end{macrocode} |
| 1174 |
% \end{macro} |
| 1175 |
% \begin{macro}{\@@_check_show_MCID_by_page:} |
| 1176 |
% This allows to show the mc on a page. Currently unused. |
| 1177 |
% \begin{macrocode} |
| 1178 |
\cs_new_protected:Npn \@@_check_show_MCID_by_page: |
| 1179 |
{ |
| 1180 |
\tl_set:Ne \l_@@_tmpa_tl |
| 1181 |
{ |
| 1182 |
\@@_property_ref_lastpage:nn |
| 1183 |
{abspage} |
| 1184 |
{-1} |
| 1185 |
} |
| 1186 |
\int_step_inline:nnnn {1}{1} |
| 1187 |
{ |
| 1188 |
\l_@@_tmpa_tl |
| 1189 |
} |
| 1190 |
{ |
| 1191 |
\seq_clear:N \l_@@_tmpa_seq |
| 1192 |
\int_step_inline:nnnn |
| 1193 |
{1} |
| 1194 |
{1} |
| 1195 |
{ |
| 1196 |
\@@_property_ref_lastpage:nn |
| 1197 |
{tagmcabs} |
| 1198 |
{-1} |
| 1199 |
} |
| 1200 |
{ |
| 1201 |
\int_compare:nT |
| 1202 |
{ |
| 1203 |
\property_ref:enn |
| 1204 |
{mcid-####1} |
| 1205 |
{tagabspage} |
| 1206 |
{-1} |
| 1207 |
= |
| 1208 |
##1 |
| 1209 |
} |
| 1210 |
{ |
| 1211 |
\seq_gput_right:Ne \l_@@_tmpa_seq |
| 1212 |
{ |
| 1213 |
Page##1-####1- |
| 1214 |
\property_ref:enn |
| 1215 |
{mcid-####1} |
| 1216 |
{tagmcid} |
| 1217 |
{-1} |
| 1218 |
} |
| 1219 |
} |
| 1220 |
} |
| 1221 |
\seq_show:N \l_@@_tmpa_seq |
| 1222 |
} |
| 1223 |
} |
| 1224 |
% \end{macrocode} |
| 1225 |
% \end{macro} |
| 1226 |
% |
| 1227 |
% \subsection{Checks related to the state of MC on a page or in a split stream} |
| 1228 |
% The following checks are currently only usable in generic mode as they |
| 1229 |
% rely on the marks defined in the mc-generic module. They are used to detect |
| 1230 |
% if a mc-chunk has been split by a page break or similar and additional |
| 1231 |
% end/begin commands are needed. |
| 1232 |
% |
| 1233 |
% \begin{macro}[pTF]{\@@_check_mc_in_galley:} |
| 1234 |
% At first we need a test to decide if |\tag_mc_begin:n| (tmb) and |\tag_mc_end:| |
| 1235 |
% (tme) has been used at all on the current galley. As each command issues |
| 1236 |
% two slightly different marks we can do it by comparing firstmarks and botmarks. |
| 1237 |
% The test assumes that the marks have been already mapped into the sequence with |
| 1238 |
% |\@@_mc_get_marks:|. As |\seq_if_eq:NNTF| doesn't exist we use the tl-test. |
| 1239 |
% \begin{macrocode} |
| 1240 |
\prg_new_conditional:Npnn \@@_check_if_mc_in_galley: { T,F,TF } |
| 1241 |
{ |
| 1242 |
\tl_if_eq:NNTF \l_@@_mc_firstmarks_seq \l_@@_mc_botmarks_seq |
| 1243 |
{ \prg_return_false: } |
| 1244 |
{ \prg_return_true: } |
| 1245 |
} |
| 1246 |
% \end{macrocode} |
| 1247 |
% \end{macro} |
| 1248 |
|
| 1249 |
% \begin{macro}[pTF]{\@@_check_if_mc_tmb_missing:} |
| 1250 |
% This checks if a extra top mark (\enquote{extra-tmb}) is needed. |
| 1251 |
% According to the analysis this the case if the firstmarks start with |
| 1252 |
% |e-| or |b+|. |
| 1253 |
% Like above we assume that the marks content is already in the seq's. |
| 1254 |
% \begin{macrocode} |
| 1255 |
\prg_new_conditional:Npnn \@@_check_if_mc_tmb_missing: { T,F,TF } |
| 1256 |
{ |
| 1257 |
\bool_if:nTF |
| 1258 |
{ |
| 1259 |
\str_if_eq_p:ee {\seq_item:Nn \l_@@_mc_firstmarks_seq {1}}{e-} |
| 1260 |
|| |
| 1261 |
\str_if_eq_p:ee {\seq_item:Nn \l_@@_mc_firstmarks_seq {1}}{b+} |
| 1262 |
} |
| 1263 |
{ \prg_return_true: } |
| 1264 |
{ \prg_return_false: } |
| 1265 |
} |
| 1266 |
% \end{macrocode} |
| 1267 |
% \end{macro} |
| 1268 |
|
| 1269 |
% \begin{macro}[pTF]{\@@_check_if_mc_tme_missing:} |
| 1270 |
% This checks if a extra bottom mark (\enquote{extra-tme}) is needed. |
| 1271 |
% According to the analysis this the case if the botmarks starts with |
| 1272 |
% |b+|. |
| 1273 |
% Like above we assume that the marks content is already in the seq's. |
| 1274 |
% \begin{macrocode} |
| 1275 |
\prg_new_conditional:Npnn \@@_check_if_mc_tme_missing: { T,F,TF } |
| 1276 |
{ |
| 1277 |
\str_if_eq:eeTF {\seq_item:Nn \l_@@_mc_botmarks_seq {1}}{b+} |
| 1278 |
{ \prg_return_true: } |
| 1279 |
{ \prg_return_false: } |
| 1280 |
} |
| 1281 |
% \end{macrocode} |
| 1282 |
% \end{macro} |
| 1283 |
% \begin{macrocode} |
| 1284 |
%</package> |
| 1285 |
% \end{macrocode} |
| 1286 |
% \begin{macrocode} |
| 1287 |
%<*debug> |
| 1288 |
% \end{macrocode} |
| 1289 |
% Code for tagpdf-debug. This will probably change over time. |
| 1290 |
% At first something for the mc commands. |
| 1291 |
% \begin{macrocode} |
| 1292 |
\msg_new:nnn { tag / debug } {mc-begin} { MC~begin~#1~with~options:~\tl_to_str:n{#2}~[\msg_line_context:] } |
| 1293 |
\msg_new:nnn { tag / debug } {mc-end} { MC~end~#1~[\msg_line_context:] } |
| 1294 |
|
| 1295 |
\cs_new_protected:Npn \@@_debug_mc_begin_insert:n #1 |
| 1296 |
{ |
| 1297 |
\int_compare:nNnT { \l_@@_loglevel_int } > {0} |
| 1298 |
{ |
| 1299 |
\msg_note:nnnn { tag / debug } {mc-begin} {inserted} { #1 } |
| 1300 |
} |
| 1301 |
} |
| 1302 |
\cs_new_protected:Npn \@@_debug_mc_begin_ignore:n #1 |
| 1303 |
{ |
| 1304 |
\int_compare:nNnT { \l_@@_loglevel_int } > {0} |
| 1305 |
{ |
| 1306 |
\msg_note:nnnn { tag / debug } {mc-begin } {ignored} { #1 } |
| 1307 |
} |
| 1308 |
} |
| 1309 |
\cs_new_protected:Npn \@@_debug_mc_end_insert: |
| 1310 |
{ |
| 1311 |
\int_compare:nNnT { \l_@@_loglevel_int } > {0} |
| 1312 |
{ |
| 1313 |
\msg_note:nnn { tag / debug } {mc-end} {inserted} |
| 1314 |
} |
| 1315 |
} |
| 1316 |
\cs_new_protected:Npn \@@_debug_mc_end_ignore: |
| 1317 |
{ |
| 1318 |
\int_compare:nNnT { \l_@@_loglevel_int } > {0} |
| 1319 |
{ |
| 1320 |
\msg_note:nnn { tag / debug } {mc-end } {ignored} |
| 1321 |
} |
| 1322 |
} |
| 1323 |
% \end{macrocode} |
| 1324 |
% And now something for the structures |
| 1325 |
% \begin{macrocode} |
| 1326 |
\msg_new:nnn { tag / debug } {struct-begin} |
| 1327 |
{ |
| 1328 |
Struct~\tag_get:n{struct_num}~begin~#1~with~options:~\tl_to_str:n{#2}~\\[\msg_line_context:] |
| 1329 |
} |
| 1330 |
\msg_new:nnn { tag / debug } {struct-end} |
| 1331 |
{ |
| 1332 |
Struct~end~#1~[\msg_line_context:] |
| 1333 |
} |
| 1334 |
\msg_new:nnn { tag / debug } {struct-end-wrong} |
| 1335 |
{ |
| 1336 |
Struct~end~'#1'~doesn't~fit~start~'#2'~[\msg_line_context:] |
| 1337 |
} |
| 1338 |
|
| 1339 |
\cs_new_protected:Npn \@@_debug_struct_begin_insert:n #1 |
| 1340 |
{ |
| 1341 |
\int_compare:nNnT { \l_@@_loglevel_int } > {0} |
| 1342 |
{ |
| 1343 |
\msg_note:nnnn { tag / debug } {struct-begin} {inserted} { #1 } |
| 1344 |
\seq_log:N \g_@@_struct_tag_stack_seq |
| 1345 |
} |
| 1346 |
} |
| 1347 |
\cs_new_protected:Npn \@@_debug_struct_begin_ignore:n #1 |
| 1348 |
{ |
| 1349 |
\int_compare:nNnT { \l_@@_loglevel_int } > {0} |
| 1350 |
{ |
| 1351 |
\msg_note:nnnn { tag / debug } {struct-begin } {ignored} { #1 } |
| 1352 |
} |
| 1353 |
} |
| 1354 |
\cs_new_protected:Npn \@@_debug_struct_end_insert: |
| 1355 |
{ |
| 1356 |
\int_compare:nNnT { \l_@@_loglevel_int } > {0} |
| 1357 |
{ |
| 1358 |
\msg_note:nnn { tag / debug } {struct-end} {inserted} |
| 1359 |
\seq_log:N \g_@@_struct_tag_stack_seq |
| 1360 |
} |
| 1361 |
} |
| 1362 |
\cs_new_protected:Npn \@@_debug_struct_end_ignore: |
| 1363 |
{ |
| 1364 |
\int_compare:nNnT { \l_@@_loglevel_int } > {0} |
| 1365 |
{ |
| 1366 |
\msg_note:nnn { tag / debug } {struct-end } {ignored} |
| 1367 |
} |
| 1368 |
} |
| 1369 |
\cs_new_protected:Npn \@@_debug_struct_end_check:n #1 |
| 1370 |
{ |
| 1371 |
\int_compare:nNnT { \l_@@_loglevel_int } > {0} |
| 1372 |
{ |
| 1373 |
\seq_get:NNT \g_@@_struct_tag_stack_seq \l_@@_tmpa_tl |
| 1374 |
{ |
| 1375 |
\str_if_eq:eeF |
| 1376 |
{#1} |
| 1377 |
{\exp_last_unbraced:No \use_i:nn { \l_@@_tmpa_tl }} |
| 1378 |
{ |
| 1379 |
\msg_warning:nnee { tag/debug }{ struct-end-wrong } |
| 1380 |
{#1} |
| 1381 |
{\exp_last_unbraced:No \use_i:nn { \l_@@_tmpa_tl }} |
| 1382 |
} |
| 1383 |
} |
| 1384 |
} |
| 1385 |
} |
| 1386 |
% \end{macrocode} |
| 1387 |
% This tracks tag suspend and resume. |
| 1388 |
% The tag-suspend message should go before the int is increased. |
| 1389 |
% The tag-resume message after the int is decreased. |
| 1390 |
% \begin{macrocode} |
| 1391 |
\msg_new:nnn { tag / debug } {tag-suspend} |
| 1392 |
{ |
| 1393 |
\int_if_zero:nTF |
| 1394 |
{#1} |
| 1395 |
{Tagging~suspended} |
| 1396 |
{Tagging~(not)~suspended~(already~inactive)}\\ |
| 1397 |
level:~#1~==>~\int_eval:n{#1+1}\tl_if_empty:nF{#2}{,~label:~#2}~[\msg_line_context:] |
| 1398 |
} |
| 1399 |
\msg_new:nnn { tag / debug } {tag-resume} |
| 1400 |
{ |
| 1401 |
\int_if_zero:nTF |
| 1402 |
{#1} |
| 1403 |
{Tagging~resumed} |
| 1404 |
{Tagging~(not)~resumed}\\ |
| 1405 |
level:~\int_eval:n{#1+1}~==>~#1\tl_if_empty:nF{#2}{,~label:~#2}~[\msg_line_context:] |
| 1406 |
} |
| 1407 |
% \end{macrocode} |
| 1408 |
% \begin{macrocode} |
| 1409 |
%</debug> |
| 1410 |
% \end{macrocode} |
| 1411 |
% |
| 1412 |
% \subsection{Benchmarks} |
| 1413 |
% It doesn't make much sense to do benchmarks in debug mode or in combination |
| 1414 |
% with a log-level as this would slow down the compilation. |
| 1415 |
% So we add simple commands that can be activated if l3benchmark has been loaded. |
| 1416 |
% TODO: is a warning needed? |
| 1417 |
% \begin{macrocode} |
| 1418 |
%<*package> |
| 1419 |
\cs_new_protected:Npn \@@_check_benchmark_tic:{} |
| 1420 |
\cs_new_protected:Npn \@@_check_benchmark_toc:{} |
| 1421 |
\cs_new_protected:Npn \tag_check_benchmark_on: |
| 1422 |
{ |
| 1423 |
\cs_if_exist:NT \benchmark_tic: |
| 1424 |
{ |
| 1425 |
\cs_set_eq:NN \@@_check_benchmark_tic: \benchmark_tic: |
| 1426 |
\cs_set_eq:NN \@@_check_benchmark_toc: \benchmark_toc: |
| 1427 |
} |
| 1428 |
} |
| 1429 |
%</package> |
| 1430 |
% \end{macrocode} |
| 1431 |
% \end{implementation} |
| 1432 |
% \PrintIndex |