summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/tagpdf
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-08-29 20:26:17 +0000
committerKarl Berry <karl@freefriends.org>2021-08-29 20:26:17 +0000
commite83c955532d6bf7a44ee1702489dbf3cd74cf7c1 (patch)
tree228648882873c58e36eaade4d747adbec6cb3598 /Master/texmf-dist/source/latex/tagpdf
parente16bd0149bf77bb72427f1421046aa7ccdf1a9c5 (diff)
tagpdf (29aug21)
git-svn-id: svn://tug.org/texlive/trunk@60366 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/tagpdf')
-rw-r--r--Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx8
-rw-r--r--Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx92
-rw-r--r--Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx437
-rw-r--r--Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx49
-rw-r--r--Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx31
-rw-r--r--Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx4
-rw-r--r--Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx4
-rw-r--r--Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx96
-rw-r--r--Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx4
-rw-r--r--Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx217
-rw-r--r--Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx14
11 files changed, 817 insertions, 139 deletions
diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx
index 6f92a5fc096..f28a02ea6eb 100644
--- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx
+++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx
@@ -51,13 +51,13 @@
% }^^A
% }
%
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
% \maketitle
% \begin{implementation}
% \begin{macrocode}
%<@@=tag>
%<*luatex>
-\ProvidesExplFile {tagpdf-luatex.def} {2021-07-03} {0.91}
+\ProvidesExplFile {tagpdf-luatex.def} {2021-08-27} {0.92}
{tagpdf~driver~for~luatex}
% \end{macrocode}
% \section{Loading the lua}
@@ -161,8 +161,8 @@
local ProvidesLuaModule = {
name = "tagpdf",
- version = "0.91", --TAGVERSION
- date = "2021-07-03", --TAGDATE
+ version = "0.92", --TAGVERSION
+ date = "2021-08-27", --TAGDATE
description = "tagpdf lua code",
license = "The LATEX Project Public License 1.3c"
}
diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx
index 7ae61bb8089..5cdbc60cf65 100644
--- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx
+++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx
@@ -52,7 +52,7 @@
% }^^A
% }
%
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
% \maketitle
% \begin{documentation}
% \section{Commands}
@@ -174,9 +174,21 @@
% & |tree-mcid-index-wrong|
% & warning
% TODO: should trigger a standard rerun message.
+% \\
+% in |enddocument/info|-hook
+% & |para-hook-count-wrong|
+% & error (warning?)
% \end{tabular}
%
% \normalsize
+% \subsection{Messages from the ptagging code}
+% A few messages are issued in generic
+% mode from the code which reinserts missing TMB/TME.
+% This is currently done if log-level is larger than zero.
+% TODO: reconsider log-level and messages when this code
+% settles down.
+%
+%
% \subsection{Warning messages from the lua-code}
% The messages are triggered if the log-level is at least equal to the number.
%
@@ -239,7 +251,7 @@
% \begin{macrocode}
%<@@=tag>
%<*header>
-\ProvidesExplPackage {tagpdf-checks-code} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-checks-code} {2021-08-27} {0.92}
{part of tagpdf - code related to checks, conditionals, debugging and messages}
%</header>
% \end{macrocode}
@@ -383,6 +395,25 @@
{engine/output~mode~#1~doesn't~support~the~interword~spaces}
% \end{macrocode}
% \end{macro}
+%
+% \begin{macro}{\@@_check_typeout_v:n}
+% A simple logging function. By default is gobbles its argument, but
+% the log-keys sets it to typeout.
+% \begin{macrocode}
+\cs_set_eq:NN \@@_check_typeout_v:n \use_none:n
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{para-hook-count-wrong}
+% At the end of the document we check if the count of para-begin and para-end is
+% identical. If not we issue a warning: this is normally a coding error and
+% and breaks the structure.
+% \begin{macrocode}
+\msg_new:nnnn { tag } {para-hook-count-wrong}
+ {The~number~of~automatic~begin~(#1)~and~end~(#2)~para~hooks~differ!}
+ {This~quite~probably~a~coding~error~and~the~structure~will~be~wrong!}
+% \end{macrocode}
+% \end{macro}
% \section{Retrieving data}
% \begin{macro}[EXP]{\tag_get:n}
% This retrieves some data.
@@ -700,6 +731,63 @@
}
% \end{macrocode}
% \end{macro}
+%
+% \subsection{Checks related to the state of MC on a page or in a split stream}
+% The following checks are currently only usable in generic mode as they
+% rely on the marks defined in the mc-generic module. They are used to detect
+% if a mc-chunk has been split by a page break or similar and additional
+% end/begin commands are needed.
+%
+% \begin{macro}[pTF]{\@@_check_mc_in_galley:}
+% At first we need a test to decide if |\tag_mc_begin:n| (tmb) and |\tag_mc_end:|
+% (tme) has been used at all on the current galley. As each command issues
+% two slightly different marks we can do it by comparing firstmarks and botmarks.
+% The test assumes that the marks have been already mapped into the sequence with
+% |\@@_mc_get_marks:|. As |\seq_if_eq:NNTF| doesn't exist we use the tl-test.
+% \begin{macrocode}
+\prg_new_conditional:Npnn \@@_check_if_mc_in_galley: { T,F,TF }
+ {
+ \tl_if_eq:NNTF \l_@@_mc_firstmarks_seq \l_@@_mc_botmarks_seq
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}[pTF]{\@@_check_if_mc_tmb_missing:}
+% This checks if a extra top mark (\enquote{extra-tmb}) is needed.
+% According to the analysis this the case if the firstmarks start with
+% |e-| or |b+|.
+% Like above we assume that the marks content is already in the seq's.
+% \begin{macrocode}
+\prg_new_conditional:Npnn \@@_check_if_mc_tmb_missing: { T,F,TF }
+ {
+ \bool_if:nTF
+ {
+ \str_if_eq_p:ee {\seq_item:Nn \l_@@_mc_firstmarks_seq {1}}{e-}
+ ||
+ \str_if_eq_p:ee {\seq_item:Nn \l_@@_mc_firstmarks_seq {1}}{b+}
+ }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}[pTF]{\@@_check_if_mc_tme_missing:}
+% This checks if a extra bottom mark (\enquote{extra-tme}) is needed.
+% According to the analysis this the case if the botmarks starts with
+% |b+|.
+% Like above we assume that the marks content is already in the seq's.
+% \begin{macrocode}
+\prg_new_conditional:Npnn \@@_check_if_mc_tme_missing: { T,F,TF }
+ {
+ \str_if_eq:eeTF {\seq_item:Nn \l_@@_mc_botmarks_seq {1}}{b+}
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
% \begin{macrocode}
%</package>
% \end{macrocode}
diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx
index 6c617e00ff7..903b38d5a35 100644
--- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx
+++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx
@@ -50,14 +50,16 @@
% }^^A
% }
%
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
% \maketitle
+% \begin{documentation}
+% \end{documentation}
% \begin{implementation}
% \section{Marked content code -- generic mode}
% \begin{macrocode}
%<@@=tag>
%<*generic>
-\ProvidesExplPackage {tagpdf-mc-code-generic} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-mc-code-generic} {2021-08-27} {0.92}
{part of tagpdf - code related to marking chunks - generic mode}
%</generic>
% \end{macrocode}
@@ -91,11 +93,411 @@
% \end{macrocode}
% \end{variable}
+% \begin{variable}
+% {
+% \g_@@_mc_marks,
+% }
+% a marks register to keep track of the mc's at page breaks and a sequence
+% to keep track of the data for the continuation
+% extra-tmb. We probably will need to track mc-marks
+% in more than one stream, so the seq contains the name of the stream.
+%
+% \begin{macrocode}
+\newmarks \g_@@_mc_marks
+% \end{macrocode}
+% \end{variable}
+%
+% \begin{variable}
+% {
+% \g_@@_mc_main_marks_seq,
+% \g_@@_mc_footnote_marks_seq,
+% \g_@@_mc_multicol_marks_seq
+% }
+% Each stream has an associated global seq variable holding the
+% bottom marks from the/a previous chunk in the stream.
+% We provide three by default: main, footnote and multicol.
+% TODO: perhaps an interface for more streams will be needed.
+% \begin{macrocode}
+\seq_new:N \g_@@_mc_main_marks_seq
+\seq_new:N \g_@@_mc_footnote_marks_seq
+\seq_new:N \g_@@_mc_multicol_marks_seq
+% \end{macrocode}
+% \end{variable}
+
+% \begin{variable}{\l_@@_mc_firstmarks_seq,\l_@@_mc_botmarks_seq}
+% The marks content contains a number of data which we will have to access and
+% compare, so we will store it locally in two sequences.
+% topmarks is unusable in LaTeX so we ignore it.
+%
+% \begin{macrocode}
+\seq_new:N \l_@@_mc_firstmarks_seq
+\seq_new:N \l_@@_mc_botmarks_seq
+% \end{macrocode}
+% \end{variable}
+%
% \subsection{Functions}
+%
+% \begin{macro}{\@@_mc_begin_marks:nn,\@@_mc_artifact_begin_marks:n,\@@_mc_end_marks:}
+% Generic mode need to set marks for the page break and split stream handling.
+% We always set two marks to be able to detect the case when no mark is on a
+% page/galley. MC-begin commands will set (b,-,data) and (b,+,data),
+% MC-end commands will set (e,-,data) and (e,+,data).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_mc_begin_marks:nn #1 #2 %#1 tag, #2 label
+ {
+ \tex_marks:D \g_@@_mc_marks
+ {
+ b-, %first of begin pair
+ \int_use:N\c@g_@@_MCID_abs_int, %mc-num
+ \g_@@_struct_stack_current_tl, %structure num
+ #1, %tag
+ \bool_if:NT \l_@@_mc_key_stash_bool{stash}, % stash info
+ #2, %label
+ }
+ \tex_marks:D \g_@@_mc_marks
+ {
+ b+, % second of begin pair
+ \int_use:N\c@g_@@_MCID_abs_int, %mc-num
+ \g_@@_struct_stack_current_tl, %structure num
+ #1, %tag
+ \bool_if:NT \l_@@_mc_key_stash_bool{stash}, % stash info
+ #2, %label
+ }
+ }
+\cs_generate_variant:Nn \@@_mc_begin_marks:nn {oo}
+\cs_new_protected:Npn \@@_mc_artifact_begin_marks:n #1 %#1 type
+ {
+ \tex_marks:D \g_@@_mc_marks
+ {
+ b-, %first of begin pair
+ \int_use:N\c@g_@@_MCID_abs_int, %mc-num
+ -1, %structure num
+ #1 %type
+ }
+ \tex_marks:D \g_@@_mc_marks
+ {
+ b+, %first of begin pair
+ \int_use:N\c@g_@@_MCID_abs_int, %mc-num
+ -1, %structure num
+ #1 %Type
+ }
+ }
+
+\cs_new_protected:Npn \@@_mc_end_marks:
+ {
+ \tex_marks:D \g_@@_mc_marks
+ {
+ e-, %first of end pair
+ \int_use:N\c@g_@@_MCID_abs_int, %mc-num
+ \g_@@_struct_stack_current_tl, %structure num
+ }
+ \tex_marks:D \g_@@_mc_marks
+ {
+ e+, %second of end pair
+ \int_use:N\c@g_@@_MCID_abs_int, %mc-num
+ \g_@@_struct_stack_current_tl, %structure num
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@@_mc_disable_marks:}
+% This disables the marks. They can't be reenabled, so it should only
+% be used in groups.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_mc_disable_marks:
+ {
+ \cs_set_eq:NN \@@_mc_begin_marks:nn \use_none:nn
+ \cs_set_eq:NN \@@_mc_artifact_begin_marks:n \use_none:n
+ \cs_set_eq:NN \@@_mc_end_marks: \prg_do_nothing:
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@@_mc_get_marks:}
+% This stores the current content of the marks in the sequences. It naturally
+% should only be used in places where it makes sense.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_mc_get_marks:
+ {
+ \exp_args:NNx
+ \seq_set_from_clist:Nn \l_@@_mc_firstmarks_seq
+ { \tex_firstmarks:D \g_@@_mc_marks }
+ \exp_args:NNx
+ \seq_set_from_clist:Nn \l_@@_mc_botmarks_seq
+ { \tex_botmarks:D \g_@@_mc_marks }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_mc_store:nnn}
+% This inserts the mc-chunk \meta{mc-num} into the structure {struct-num}
+% after the \meta{mc-prev}.
+% The structure must already exist.
+% The additional mcid dictionary is stored in a property. The item is retrieved
+% when the kid entry is built. We test if there is already
+% an addition and append if needed.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_mc_store:nnn #1 #2 #3 %#1 mc-prev, #2 mc-num #3 structure-num
+ {
+ %\prop_show:N \g_@@_struct_cont_mc_prop
+ \prop_get:NnNTF \g_@@_struct_cont_mc_prop {#1} \l_@@_tmpa_tl
+ {
+ \prop_gput:Nnx \g_@@_struct_cont_mc_prop {#1}{ \l_@@_tmpa_tl \@@_struct_mcid_dict:n {#2}}
+ }
+ {
+ \prop_gput:Nnx \g_@@_struct_cont_mc_prop {#1}{ \@@_struct_mcid_dict:n {#2}}
+ }
+ \prop_gput:Nxx \g_@@_mc_parenttree_prop
+ {#2}
+ {#3}
+ }
+\cs_generate_variant:Nn \@@_mc_store:nnn {xxx}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_mc_insert_extra_tmb:n,\@@_mc_insert_extra_tme:n}
+% These two functions should be used in the output routine at the place
+% where a mc-literal could be missing due to a page break or some other split.
+% They check (with the help of the marks) if a extra-tmb or extra-tme is needed.
+% The tmb command stores also the mc into the structure, the tme has to store
+% the data for a following extra-tmb.
+% The argument takes a stream name like main or footnote to allow different handling
+% there.
+% The content of the marks must be stored before (with |\@@_mc_get_marks:|
+% or manually)
+% into |\l_@@_mc_firstmarks_seq| and |\l_@@_mc_botmarks_seq| so that the tests
+% can use them.
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_mc_insert_extra_tmb:n #1 % #1 stream: e.g. main or footnote
+ {
+ \@@_check_typeout_v:n {=>~ first~ \seq_use:Nn \l__tag_mc_firstmarks_seq {,~}}
+ \@@_check_typeout_v:n {=>~ bot~ \seq_use:Nn \l__tag_mc_botmarks_seq {,~}}
+ \@@_check_if_mc_tmb_missing:TF
+ {
+ \@@_check_typeout_v:n {=>~ TMB~ ~ missing~ --~ inserted}
+ %test if artifact
+ \int_compare:nNnTF { \seq_item:cn { g_@@_mc_#1_marks_seq } {3} } = {-1}
+ {
+ \tl_set:Nx \l_@@_tmpa_tl { \seq_item:cn { g_@@_mc_#1_marks_seq } {4} }
+ \@@_mc_handle_artifact:N \l_@@_tmpa_tl
+ }
+ {
+ \exp_args:Nx
+ \@@_mc_bdc_mcid:n
+ {
+ \seq_item:cn { g_@@_mc_#1_marks_seq } {4}
+ }
+ \str_if_eq:eeTF
+ {
+ \seq_item:cn { g_@@_mc_#1_marks_seq } {5}
+ }
+ {}
+ {
+ %store
+ \@@_mc_store:xxx
+ {
+ \seq_item:cn { g_@@_mc_#1_marks_seq } {2}
+ }
+ { \int_eval:n{\c@g__tag_MCID_abs_int} }
+ {
+ \seq_item:cn { g_@@_mc_#1_marks_seq } {3}
+ }
+ }
+ {
+ %stashed -> warning!!
+ }
+ }
+ }
+ {
+ \@@_check_typeout_v:n {=>~ TMB~ not~ missing}
+ }
+ }
+\cs_new_protected:Npn \@@_mc_insert_extra_tme:n #1 % #1 stream, eg. main or footnote
+ {
+ \@@_check_if_mc_tme_missing:TF
+ {
+ \@@_check_typeout_v:n {=>~ TME~ ~ missing~ --~ inserted}
+ \@@_mc_emc:
+ \seq_gset_eq:cN
+ { g_@@_mc_#1_marks_seq }
+ \l_@@_mc_botmarks_seq
+ }
+ {
+ \@@_check_typeout_v:n {=>~ TME~ not~ missing}
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Looking at MC marks in boxes}
+% \begin{macro}{\@@_add_missing_mcs:Nn}
+% Assumptions:
+% \begin{itemize}
+% \item
+% test for tagging active outside;
+% \item
+% mark retrieval also outside.
+% \end{itemize}
+%
+% This takes a box register as its first argument (or the register
+% number in a count register, as used by \pkg{multicol}). It adds
+% an extra tmb at the top of the box if necessary and similarly
+% an extra tme at the end. This is done by adding hboxes in a way
+% that the positioning and the baseline of the given box is not
+% altered. The result is written back to the box.
+%
+% The second argument is the stream this box belongs to und is
+% currently either \texttt{main} for the main galley,
+% \texttt{footnote} for footnote note text, or \texttt{multicol}
+% for boxes produced for columns in that environment. Other streams
+% may follow over time.
+% \begin{macrocode}
+\cs_new:Npn\@@_add_missing_mcs:Nn #1 #2 {
+ \vbadness \@M
+ \vfuzz \c_max_dim
+ \vbox_set_to_ht:Nnn #1 { \box_ht:N #1 } {
+ \hbox_set:Nn \l_@@_tmpa_box { \@@_mc_insert_extra_tmb:n {#2} }
+ \hbox_set:Nn \l_@@_tmpb_box { \@@_mc_insert_extra_tme:n {#2} }
+ \int_compare:nNnT {\l_@@_loglevel_int} > { 0 }
+ {
+ \seq_log:c { g_@@_mc_#2_marks_seq}
+ }
+% \end{macrocode}
+% The box placed on the top gets zero size and thus will not affect
+% the box dimensions of the box we are modifying.
+% \begin{macrocode}
+ \box_set_ht:Nn \l_@@_tmpa_box \c_zero_dim
+ \box_set_dp:Nn \l_@@_tmpa_box \c_zero_dim
+% \end{macrocode}
+% The box added at the bottom will get the depth of the original
+% box. This way we can arrange that from the outside everything
+% looks as before.
+% \begin{macrocode}
+ \box_set_ht:Nn \l_@@_tmpb_box \c_zero_dim
+ \box_set_dp:Nn \l_@@_tmpb_box { \box_dp:N #1 }
+% \end{macrocode}
+% We need to set \cs{boxmaxdepth} in case the original box has an
+% unusually large depth, otherwise that depth is not preserved when
+% we string things together.
+% \begin{macrocode}
+ \boxmaxdepth \@maxdepth
+ \box_use_drop:N \l_@@_tmpa_box
+ \vbox_unpack_drop:N #1
+% \end{macrocode}
+% Back up by the depth of the box as we add that later again.
+% \begin{macrocode}
+ \tex_kern:D -\box_dp:N \l_@@_tmpb_box
+% \end{macrocode}
+% And we don't want any glue added when we add the box.
+% \begin{macrocode}
+ \nointerlineskip
+ \box_use_drop:N \l_@@_tmpb_box
+ }
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\@@_add_missing_mcs_to_stream:Nn}
+% This is the main command to add mc to the stream. It is therefor
+% guarded by the mc-boolean.
+%
+% If we aren't in the main stream then processing is a bit more
+% complicated because to get at the marks in the box we need to
+% artifically split it and then look at the split marks.
+%
+% First argument is the box to update and the second is the \enquote{stream}.
+% In lua mode the command is a no-op.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_add_missing_mcs_to_stream:Nn #1#2
+ {
+ \@@_check_if_active_mc:T {
+% \end{macrocode}
+% First set up a temp box for trial splitting.
+% \begin{macrocode}
+ \vbadness\maxdimen
+ \box_set_eq:NN \l_@@_tmpa_box #1
+% \end{macrocode}
+% Split the box to the largest size available. This should give us
+% all content (but to be sure that there is no issue we could test
+% out test box is empty now (not done).
+% \begin{macrocode}
+ \vbox_set_split_to_ht:NNn \l_@@_tmpa_box \l_@@_tmpa_box \c_max_dim
+% \end{macrocode}
+% As a side effect of this split we should now have the first and
+% bottom split marks set up. We use this to set up
+% \cs{l_@@_mc_firstmarks_seq}
+% \begin{macrocode}
+ \exp_args:NNx
+ \seq_set_from_clist:Nn \l_@@_mc_firstmarks_seq
+ { \tex_splitfirstmarks:D \g_@@_mc_marks }
+% \end{macrocode}
+% Some debugging info:
+% \begin{macrocode}
+% \iow_term:n { First~ mark~ from~ this~ box: }
+% \seq_log:N \l__tag_mc_firstmarks_seq
+% \end{macrocode}
+% If this mark was empty then clearly the bottom mark will too be
+% empty. Thus in this case we make use of the saved bot mark from
+% the previous chunk. Note that if this is the first chunk in the
+% stream the global seq would contain a random value, but then we
+% can't end in this branch because the basis assumption is that
+% streams are properly marked up so the first chunk would always
+% have a mark at the beginning!
+% \begin{macrocode}
+ \seq_if_empty:NTF \l_@@_mc_firstmarks_seq
+ {
+ \@@_check_typeout_v:n
+ {
+ No~ marks~ so~ use~ saved~ bot~ mark:~
+ \seq_use:cn {g__tag_mc_#2_marks_seq} {,~} \iow_newline:
+ }
+ \seq_set_eq:Nc \l_@@_mc_firstmarks_seq {g_@@_mc_#2_marks_seq}
+% \end{macrocode}
+% We also update the bot mark to the same value so that we can
+% later apply \cs{@@_add_missing_mcs:Nn} with the data
+% structures in place (see assumptions made there).
+% \begin{macrocode}
+ \seq_set_eq:NN \l_@@_mc_botmarks_seq \l_@@_mc_firstmarks_seq
+ }
+% \end{macrocode}
+% If there was a first mark then there is also a bot mark (and it
+% can't be the same as our marks always come in pairs).
+% So if that branch is chosen we update
+% \cs{l_@@_mc_botmarks_seq} from the bot mark.
+% \begin{macrocode}
+ {
+ \@@_check_typeout_v:n
+ {
+ Pick~ up~ new~ bot~ mark!
+ }
+ \exp_args:NNx
+ \seq_set_from_clist:Nn \l_@@_mc_botmarks_seq
+ { \tex_splitbotmarks:D \g_@@_mc_marks }
+ }
+% \end{macrocode}
+% Finally we call \cs{@@_add_missing_mcs:Nn} to add any missing
+% tmb/tme as needed,
+% \begin{macrocode}
+ \@@_add_missing_mcs:Nn #1 {#2}
+%%
+ \seq_gset_eq:cN {g_@@_mc_#2_marks_seq} \l_@@_mc_botmarks_seq
+%%
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}[pTF]{\@@_mc_if_in:,\tag_mc_if_in:}
% This is a test if a mc is open or not. It depends simply on a global boolean:
% mc-chunks are added linearly so nesting should not be relevant.
+%
+% One exception are header and footer (perhaps they are more, but for now
+% it doesn't seem so, so there are no dedicated code to handle this situation):
+% When they are built and added to the page we could be both inside or outside a mc-chunk.
+% But header and footer should ignore this and not push/pop or warn about nested mc.
+% It is therefore important there to set and reset the boolean manually.
+% See the tagpddocu-patches.sty for an example.
% \begin{macrocode}
\prg_new_conditional:Nnn \@@_mc_if_in: {p,T,F,TF}
{
@@ -238,6 +640,7 @@
\cs_new_protected:Npn \@@_mc_handle_artifact:N #1
% #1 is a var containing the artifact type
{
+ \int_gincr:N \c@g_@@_MCID_abs_int
\tl_if_empty:NTF #1
{ \@@_mc_bmc_artifact: }
{ \exp_args:NV\@@_mc_bmc_artifact:n #1 }
@@ -271,12 +674,15 @@
\bool_if:NTF \l_@@_mc_artifact_bool
{ %handle artifact
\@@_mc_handle_artifact:N \l_@@_mc_artifact_type_tl
+ \exp_args:NV
+ \@@_mc_artifact_begin_marks:n \l_@@_mc_artifact_type_tl
}
{ %handle mcid type
\@@_check_mc_tag:N \l_@@_mc_key_tag_tl
\@@_mc_handle_mcid:VV
\l_@@_mc_key_tag_tl
\l_@@_mc_key_properties_tl
+ \@@_mc_begin_marks:oo{\l_@@_mc_key_tag_tl}{\l_@@_mc_key_label_tl}
\tl_if_empty:NF {\l_@@_mc_key_label_tl}
{
\exp_args:NV
@@ -298,6 +704,7 @@
\bool_gset_false:N \g_@@_in_mc_bool
\tl_gset:Nn \g_@@_mc_key_tag_tl { }
\@@_mc_emc:
+ \@@_mc_end_marks:
}
}
% \end{macrocode}
@@ -311,8 +718,8 @@
% \begin{macro}
% {
% tag,raw,
-% alttext,alttext-o,
-% actualtext,actualtext-o,
+% alttext,
+% actualtext,
% label,artifact
% }
% \begin{macrocode}
@@ -327,17 +734,7 @@
{
\tl_put_right:Nx \l_@@_mc_key_properties_tl { #1 }
},
- alttext .code:n = % Alt property
- {
- \str_set_convert:Nnon
- \l_@@_tmpa_str
- { #1 }
- { default }
- { utf16/hex }
- \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< }
- \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
- },
- alttext-o .code:n = % Alt property
+ alttext .code:n = % Alt property
{
\str_set_convert:Noon
\l_@@_tmpa_str
@@ -349,16 +746,6 @@
},
actualtext .code:n = % ActualText property
{
- \str_set_convert:Nnon
- \l_@@_tmpa_str
- { #1 }
- { default }
- { utf16/hex }
- \tl_put_right:Nn \l_@@_mc_key_properties_tl { /ActualText~< }
- \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
- },
- actualtext-o .code:n = % ActualText property
- {
\str_set_convert:Noon
\l_@@_tmpa_str
{ #1 }
diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx
index 7fff1672ea7..2698b7ad594 100644
--- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx
+++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx
@@ -50,7 +50,7 @@
% }^^A
% }
%
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
% \maketitle
% \begin{implementation}
@@ -91,7 +91,7 @@
% \begin{macrocode}
%<@@=tag>
%<*luamode>
-\ProvidesExplPackage {tagpdf-mc-code-lua} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-mc-code-lua} {2021-08-27} {0.92}
{tagpdf - mc code only for the luamode }
%</luamode>
% \end{macrocode}
@@ -152,6 +152,13 @@
}
% \end{macrocode}
% \subsection{Commands}
+% \begin{macro}{\@@_add_missing_mcs_to_stream:Nn}
+% This command is used in the output routine by the ptagging code.
+% It should do nothing in luamode.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_add_missing_mcs_to_stream:Nn #1#2 {}
+% \end{macrocode}
+% \end{macro}
% \begin{macro}{\@@_mc_if_in:,\tag_mc_if_in:}
% This tests, if we are in an mc, for attributes
% this means to check against a number.
@@ -352,8 +359,8 @@
% \begin{macro}
% {
% tag,raw,
-% alttext,alttext-o,
-% actualtext,actualtext-o,
+% alttext,
+% actualtext,
% label,artifact
% }
% TODO: check conversion, check if local/global setting is right.
@@ -379,23 +386,6 @@
},
alttext .code:n = % Alt property
{
- \str_set_convert:Nnon
- \l_@@_tmpa_str
- { #1 }
- { default }
- { utf16/hex }
- \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< }
- \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
- \lua_now:e
- {
- ltx.@@.func.store_mc_data
- (
- \@@_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l_@@_tmpa_str>"
- )
- }
- },
- alttext-o .code:n = % Alt property
- {
\str_set_convert:Noon
\l_@@_tmpa_str
{ #1 }
@@ -413,23 +403,6 @@
},
actualtext .code:n = % Alt property
{
- \str_set_convert:Nnon
- \l_@@_tmpa_str
- { #1 }
- { default }
- { utf16/hex }
- \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< }
- \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ }
- \lua_now:e
- {
- ltx.@@.func.store_mc_data
- (
- \@@_get_mc_abs_cnt:,"actualtext","/ActualText~<\str_use:N \l_@@_tmpa_str>"
- )
- }
- },
- actualtext-o .code:n = % Alt property
- {
\str_set_convert:Noon
\l_@@_tmpa_str
{ #1 }
diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx
index 13f03105893..17f6df0fcfc 100644
--- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx
+++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx
@@ -50,7 +50,7 @@
% }^^A
% }
%
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
% \maketitle
% \begin{documentation}
% \section{Public Commands}
@@ -145,17 +145,17 @@
% \verb+raw=/Alt (Hello)+ will insert an alternative Text.
% \end{function}
%
-% \begin{function}{alttext,alttext-o}
+% \begin{function}{alttext}
% This key inserts an \texttt{/Alt} value in the property dictionary of the BDC operator.
-% The value is handled as verbatim string, commands are not expanded. With |alttext-o|
-% the value is expanded once.
+% The value is handled as verbatim string, commands are not expanded.
+% The value will be expanded first once.
% \end{function}
%
-% \begin{function}{actualtext,actualtext-o}
+% \begin{function}{actualtext}
% This key inserts an \texttt{/ActualText} value in the property dictionary
% of the BDC operator. The value is handled as verbatim string,
-% commands are not expanded.With |actualtext-o|
-% the value is expanded once.
+% commands are not expanded.
+% The value will be expanded first once.
% \end{function}
%
% \begin{function}{label}
@@ -178,7 +178,7 @@
% \begin{macrocode}
%<@@=tag>
%<*header>
-\ProvidesExplPackage {tagpdf-mc-code-shared} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-mc-code-shared} {2021-08-27} {0.92}
{part of tagpdf - code related to marking chunks -
code shared by generic and luamode }
%</header>
@@ -217,7 +217,7 @@
% \end{variable}
%
% \begin{variable}{\g_@@_in_mc_bool}
-% This booleans records if a mc is open, to test nesting.
+% This booleans record if a mc is open, to test nesting.
% \begin{macrocode}
\bool_new:N \g_@@_in_mc_bool
% \end{macrocode}
@@ -273,6 +273,7 @@
% \end{macrocode}
% \end{variable}
%
+%
% \subsection{Functions}
% \begin{macro}{\_@@_mc_handle_mc_label:n}
% The commands labels a mc-chunk. It is used if the user explicitly
@@ -408,6 +409,10 @@
%
% \begin{macro}{stash,__artifact-bool,__artifact-type}
% the two internal artifact keys are use to define the public |artifact|.
+% For now we add support for the subtypes Header and Footer.
+% Watermark,PageNum, LineNum,Redaction,Bates will be added if some use case
+% emerges. If some use case for /BBox and /Attached emerges, it will be perhaps
+% necessary to adapt the code.
% \begin{macrocode}
\keys_define:nn { @@ / mc }
{
@@ -418,6 +423,14 @@
{
\tl_set:Nn \l_@@_mc_artifact_type_tl { Pagination }
},
+ __artifact-type / pagination/header .code:n =
+ {
+ \tl_set:Nn \l_@@_mc_artifact_type_tl { Pagination/Subtype/Header }
+ },
+ __artifact-type / pagination/footer .code:n =
+ {
+ \tl_set:Nn \l_@@_mc_artifact_type_tl { Pagination/Subtype/Footer }
+ },
__artifact-type / layout .code:n =
{
\tl_set:Nn \l_@@_mc_artifact_type_tl { Layout }
diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx
index 5cc18b0b0f3..78dccdc02ac 100644
--- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx
+++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx
@@ -50,13 +50,13 @@
% }^^A
% }
%
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
% \maketitle
% \begin{implementation}
% \begin{macrocode}
%<@@=tag>
%<*header>
-\ProvidesExplPackage {tagpdf-roles-code} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-roles-code} {2021-08-27} {0.92}
{part of tagpdf - code related to roles and structure names}
%</header>
% \end{macrocode}
diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx
index ea847297189..c2a999cc1bd 100644
--- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx
+++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx
@@ -50,13 +50,13 @@
% }^^A
% }
%
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
% \maketitle
% \begin{implementation}
% \begin{macrocode}
%<@@=tag>
%<*header>
-\ProvidesExplPackage {tagpdf-space-code} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-space-code} {2021-08-27} {0.92}
{part of tagpdf - code related to real space chars}
%</header>
% \end{macrocode}
diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx
index 3d2dace5d78..610d6313331 100644
--- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx
+++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx
@@ -50,7 +50,7 @@
% }^^A
% }
%
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
% \maketitle
% \begin{documentation}
% \section{Public Commands}
@@ -123,15 +123,15 @@
% Commands are not expanded. |title-o| will expand the value once.
% \end{function}
%
-% \begin{function}{alttext,alttext-o}
+% \begin{function}{alttext}
% This key inserts an \texttt{/Alt} value in the dictionary of structure object.
% The value is handled as verbatim string and hex encoded.
-% |alttext-o| will expand the value once.
+% The value will be expanded first once.
% \end{function}
-% \begin{function}{actualtext,actualtext-o}
+% \begin{function}{actualtext}
% This key inserts an \texttt{/ActualText} value in the dictionary of structure object.
% The value is handled as verbatim string and hex encoded.
-% |actualtext-o| will expand the value once.
+% The value will be expanded first once.
% \end{function}
% \begin{function}{lang}
% This key allows to set the language for a structure element. The value should be a bcp-identifier,
@@ -211,7 +211,7 @@
% \begin{macrocode}
%<@@=tag>
%<*header>
-\ProvidesExplPackage {tagpdf-struct-code} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-struct-code} {2021-08-27} {0.92}
{part of tagpdf - code related to storing structure}
%</header>
% \end{macrocode}
@@ -238,6 +238,16 @@
\@@_seq_new:N \g_@@_struct_objR_seq
% \end{macrocode}
% \end{variable}
+
+% \begin{variable}{\g_@@_struct_cont_mc_prop}
+% in generic mode it can happen after
+% a page break that we have to inject into a structure
+% sequence an additional mc after. We will store this additional
+% info in a property. The key is the absolut mc num, the value the pdf directory.
+% \begin{macrocode}
+\@@_prop_new:N \g_@@_struct_cont_mc_prop
+% \end{macrocode}
+% \end{variable}
%
% \begin{variable}{\g_@@_struct_stack_seq}
% A stack sequence for the structure stack.
@@ -426,28 +436,44 @@
% Commands to store the kids. Kids in a structure can be a reference to a mc-chunk,
% an object reference to another structure element, or a object reference to an
% annotation (through an OBJR object).
-% \begin{macro}{\@@_struct_kid_mc_gput_right:nn}
+% \begin{macro}{\@@_struct_kid_mc_gput_right:nn,\@@_struct_kid_mc_gput_right:nx}
% The command to store an mc-chunk, this is a dictionary of type MCR.
% It would be possible to write out the content directly as unnamed object
% and to store only the object reference, but probably this would be slower,
% and the PDF is more readable like this.
% The code doesn't try to avoid the use of the /Pg key by checking page numbers.
% That imho only slows down without much gain.
+% In generic mode the page break code will perhaps to have to insert
+% an additional mcid after an existing one. For this we use a property list
+% At first an auxiliary to write the MCID dict. This should normally be expanded!
+% \begin{macrocode}
+\cs_new:Npn \@@_struct_mcid_dict:n #1 %#1 MCID absnum
+ {
+ <<
+ /Type \c_space_tl /MCR \c_space_tl
+ /Pg
+ \c_space_tl
+ \pdf_pageobject_ref:n { \@@_ref_value:enn{mcid-#1}{tagabspage}{1} }
+ /MCID \c_space_tl \@@_ref_value:enn{mcid-#1}{tagmcid}{1}
+ >>
+ }
+% \end{macrocode}
% \begin{macrocode}
\cs_new_protected:Npn \@@_struct_kid_mc_gput_right:nn #1 #2 %#1 structure num, #2 MCID absnum%
{
\@@_seq_gput_right:cx
{ g_@@_struct_kids_#1_seq }
{
- <<
- /Type \c_space_tl /MCR \c_space_tl
- /Pg
- \c_space_tl
- \pdf_pageobject_ref:n { \@@_ref_value:enn{mcid-#2}{tagabspage}{1} }
- /MCID \c_space_tl \@@_ref_value:enn{mcid-#2}{tagmcid}{1}
- >>
+ \@@_struct_mcid_dict:n {#2}
+ }
+ \@@_seq_gput_right:cn
+ { g_@@_struct_kids_#1_seq }
+ {
+ \prop_item:Nn \g_@@_struct_cont_mc_prop {#2}
}
}
+\cs_generate_variant:Nn \@@_struct_kid_mc_gput_right:nn {nx}
+
% \end{macrocode}
% \end{macro}
% \begin{macro}
@@ -522,6 +548,18 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_struct_fill_kid_key:n #1 %#1 is the struct num
{
+ \bool_if:NF\g_@@_mode_lua_bool
+ {
+ \seq_clear:N \l_@@_tmpa_seq
+ \seq_map_inline:cn { g_@@_struct_kids_#1_seq }
+ { \seq_put_right:Nx \l_@@_tmpa_seq { ##1 } }
+ %\seq_show:c { g_@@_struct_kids_#1_seq }
+ %\seq_show:N \l_@@_tmpa_seq
+ \seq_remove_all:Nn \l_@@_tmpa_seq {}
+ %\seq_show:N \l_@@_tmpa_seq
+ \seq_gset_eq:cN { g_@@_struct_kids_#1_seq } \l_@@_tmpa_seq
+ }
+
\int_case:nnF
{
\seq_count:c
@@ -706,8 +744,8 @@
% {
% label,stash,tag,
% title,title-o,
-% alttext,alttext-o,
-% actualtext,actualtext-o
+% alttext,
+% actualtext,
% lang,ref,E
% }
% \begin{macrocode}
@@ -759,18 +797,6 @@
},
alttext .code:n = % Alt property
{
- \str_set_convert:Nnon
- \l_@@_tmpa_str
- { #1 }
- { default }
- { utf16/hex }
- \@@_prop_gput:cnx
- { g_@@_struct_\int_eval:n {\c@g_@@_struct_abs_int}_prop }
- { Alt }
- { <\l_@@_tmpa_str> }
- },
- alttext-o .code:n = % Alt property
- {
\str_set_convert:Noon
\l_@@_tmpa_str
{ #1 }
@@ -783,18 +809,6 @@
},
actualtext .code:n = % ActualText property
{
- \str_set_convert:Nnon
- \l_@@_tmpa_str
- { #1 }
- { default }
- { utf16/hex }
- \@@_prop_gput:cnx
- { g_@@_struct_\int_eval:n {\c@g_@@_struct_abs_int}_prop }
- { ActualText }
- { <\l_@@_tmpa_str>}
- },
- actualtext-o .code:n = % ActualText property
- {
\str_set_convert:Noon
\l_@@_tmpa_str
{ #1 }
@@ -1059,7 +1073,7 @@
% \section{Attributes and attribute classes}
% \begin{macrocode}
%<*header>
-\ProvidesExplPackage {tagpdf-attr-code} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-attr-code} {2021-08-27} {0.92}
{part of tagpdf - code related to attributes and attribute classes}
%</header>
% \end{macrocode}
diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx
index 1f9c12fb35c..b8e1b0d54ac 100644
--- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx
+++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx
@@ -51,13 +51,13 @@
% }^^A
% }
%
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
% \maketitle
% \begin{implementation}
% \begin{macrocode}
%<@@=tag>
%<*header>
-\ProvidesExplPackage {tagpdf-tree-code} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-tree-code} {2021-08-27} {0.92}
{part of tagpdf - code related to writing trees and dictionaries to the pdf}
%</header>
% \end{macrocode}
diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx
index 4b408a60ea8..23737dfc292 100644
--- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx
+++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx
@@ -50,7 +50,7 @@
% }^^A
% }
%
-% \date{Version 0.91, released 2021-07-03}
+% \date{Version 0.92, released 2021-08-27}
% \maketitle
% \begin{documentation}
% \section{Setup commands}
@@ -179,6 +179,18 @@
% faster then |\tagpdfsetup|. But I'm not sure if the names are good.
% \end{function}
%
+% \subsection{Header and footer}
+% Header and footer are automatically excluded from tagging. This can for
+% now to allow debugging be disabled with the following key, but probably
+% this key will disappear again. If some real content is in the header and
+% footer, tagging must be restarted there explicitly.
+%
+% \begin{function}{exclude-header-footer}
+% \begin{syntax}
+% |exclude-header-footer| = |true|\verb+|+|false|
+% \end{syntax}%
+% \end{function}
+
% \subsection{Link tagging}
% Links need a special structure and cross reference system.
% This is added through hooks of the l3pdfannot module and will work
@@ -201,7 +213,7 @@
% \begin{macrocode}
%<@@=tag>
%<*header>
-\ProvidesExplPackage {tagpdf-user} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf-user} {2021-08-27} {0.92}
{tagpdf - user commands}
%</header>
% \end{macrocode}
@@ -385,7 +397,56 @@
}
% \end{macrocode}
% \end{macro}
-%
+% \begin{macro}{mc-marks}
+% It maps the mc-marks into the sequences and then shows them.
+% This allows to inspect the first and last mc-Mark on a page.
+% It should only be used in the shipout (header/footer).
+% \begin{macrocode}
+\keys_define:nn { @@ / show }
+ {
+ mc-marks .choice: ,
+ mc-marks / show .code:n =
+ {
+ \@@_mc_get_marks:
+ \@@_check_if_mc_in_galley:TF
+ {
+ \iow_term:n {Marks~from~this~page:~}
+ }
+ {
+ \iow_term:n {Marks~from~a~previous~page:~}
+ }
+ \seq_show:N \l_@@_mc_firstmarks_seq
+ \seq_show:N \l_@@_mc_botmarks_seq
+ \@@_check_if_mc_tmb_missing:T
+ {
+ \iow_term:n {BDC~missing~on~this~page!}
+ }
+ \@@_check_if_mc_tme_missing:T
+ {
+ \iow_term:n {EMC~missing~on~this~page!}
+ }
+ },
+ mc-marks / use .code:n =
+ {
+ \@@_mc_get_marks:
+ \@@_check_if_mc_in_galley:TF
+ { Marks~from~this~page:~}
+ { Marks~from~a~previous~page:~}
+ \seq_use:Nn \l_@@_mc_firstmarks_seq {,~}\quad
+ \seq_use:Nn \l_@@_mc_botmarks_seq {,~}\quad
+ \@@_check_if_mc_tmb_missing:T
+ {
+ BDC~missing~
+ }
+ \@@_check_if_mc_tme_missing:T
+ {
+ EMC~missing
+ }
+ },
+ mc-marks .default:n = show
+ }
+% \end{macrocode}
+% \end{macro}
% \begin{macro}{struct-stack}
% \begin{macrocode}
\keys_define:nn { @@ / show }
@@ -449,7 +510,8 @@
% \begin{macrocode}
\bool_new:N \l_@@_para_bool
\bool_new:N \l_@@_para_show_bool
-\int_new:N \g_@@_para_int
+\int_new:N \g_@@_para_begin_int
+\int_new:N \g_@@_para_end_int
% \end{macrocode}
% \end{macro}
%
@@ -475,13 +537,13 @@
% \begin{macrocode}
\AddToHook{para/begin}
{
- \int_gincr:N \g_@@_para_int
- \bool_if:NT \l__tag_para_bool
+ \bool_if:NT \l_@@_para_bool
{
+ \int_gincr:N \g_@@_para_begin_int
\tag_struct_begin:n {tag=P}
\bool_if:NT \l_@@_para_show_bool
{ \tag_mc_begin:n{artifact}
- \llap{\color_select:n{red}\tiny\int_use:N\g_@@_para_int\ }
+ \llap{\color_select:n{red}\tiny\int_use:N\g_@@_para_begin_int\ }
\tag_mc_end:
}
\tag_mc_begin:n {tag=P}
@@ -489,17 +551,57 @@
}
\AddToHook{para/end}
{
- \bool_if:NT \l__tag_para_bool
+ \bool_if:NT \l_@@_para_bool
{
+ \int_gincr:N \g_@@_para_end_int
\tag_mc_end:
\bool_if:NT \l_@@_para_show_bool
{ \tag_mc_begin:n{artifact}
- \rlap{\color_select:n{red}\tiny\ \int_use:N\g_@@_para_int}
+ \rlap{\color_select:n{red}\tiny\ \int_use:N\g_@@_para_end_int}
\tag_mc_end:
}
\tag_struct_end:
}
}
+\AddToHook{enddocument/info}
+ {
+ \int_compare:nNnF {\g__tag_para_begin_int}={\g__tag_para_end_int}
+ {
+ \msg_error:nnxx
+ {tag}
+ {para-hook-count-wrong}
+ {\int_use:N\g__tag_para_begin_int}
+ {\int_use:N\g__tag_para_end_int}
+ }
+ }
+% \end{macrocode}
+% In generic mode we need the additional code from the ptagging tests.
+% \begin{macrocode}
+\AddToHook{begindocument/before}
+ {
+ \bool_if:NF \g_@@_mode_lua_bool
+ {
+ \cs_if_exist:NT \@kernel@before@footins
+ {
+ \tl_put_right:Nn \@kernel@before@footins
+ { \@@_add_missing_mcs_to_stream:Nn \footins {footnote} }
+ \tl_put_right:Nn \@kernel@before@cclv
+ {
+ \@@_check_typeout_v:n {====>~In~\token_to_str:N \@makecol\c_space_tl\the\c@page}
+ \@@_add_missing_mcs_to_stream:Nn \@cclv {main}
+ }
+ \tl_put_right:Nn \@mult@ptagging@hook
+ {
+ \@@_check_typeout_v:n {====>~In~\string\page@sofar}
+ \process@cols\mult@gfirstbox
+ {
+ \@@_add_missing_mcs_to_stream:Nn \count@ {multicol}
+ }
+ \@@_add_missing_mcs_to_stream:Nn \mult@rightbox {multicol}
+ }
+ }
+ }
+ }
% \end{macrocode}
% \begin{macro}
% {
@@ -509,11 +611,104 @@
% This two command switch para mode on and off. |\tagpdfsetup| could be used
% too but is longer.
% \begin{macrocode}
-\newcommand\tagpdfparaOn {\bool_set_true:N \l__tag_para_bool}
-\newcommand\tagpdfparaOff{\bool_set_false:N \l__tag_para_bool}
+\newcommand\tagpdfparaOn {\bool_set_true:N \l_@@_para_bool}
+\newcommand\tagpdfparaOff{\bool_set_false:N \l_@@_para_bool}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}
+% {
+% \tagpdfsuppressmarks
+% }
+% This command allows to suppress the creation of the marks. It takes an argument
+% which should normally be one of the mc-commands, puts a group around it and
+% suppress the marks creation in this group. This command should be used if
+% the begin and end command are at different boxing levels. E.g.
+% \begin{verbatim}
+% \@hangfrom
+% {
+% \tagstructbegin{tag=H1}%
+% \tagmcbegin {tag=H1}%
+% #2
+% }
+% {#3\tagpdfsuppressmarks{\tagmcend}\tagstructend}%
+% \end{verbatim}
+% \begin{macrocode}
+\NewDocumentCommand\tagpdfsuppressmarks{m}
+ {{\use:c{@@_mc_disable_marks:} #1}}
+% \end{macrocode}
+% \end{macro}
+% \subsection{Header and footer}
+% Header and footer should normally be tagged as artifacts. The following code
+% requires the new hooks.
+% For now we allow to disable this function, but probably the code should always there at
+% the end.
+% TODO check if Pagination should be changeable.
+% \begin{macrocode}
+\cs_new_protected:Npn\@@_hook_kernel_before_head:{}
+\cs_new_protected:Npn\@@_hook_kernel_after_head:{}
+\cs_new_protected:Npn\@@_hook_kernel_before_foot:{}
+\cs_new_protected:Npn\@@_hook_kernel_after_foot:{}
+
+\AddToHook{begindocument}
+ {
+ \cs_if_exist:NT \@kernel@before@head
+ {
+ \tl_put_right:Nn \@kernel@before@head {\@@_hook_kernel_before_head:}
+ \tl_put_left:Nn \@kernel@after@head {\@@_hook_kernel_after_head:}
+ \tl_put_right:Nn \@kernel@before@foot {\@@_hook_kernel_before_foot:}
+ \tl_put_left:Nn \@kernel@after@foot {\@@_hook_kernel_after_foot:}
+ }
+ }
+
+\bool_new:N \g_@@_saved_in_mc_bool
+\cs_new_protected:Npn \@@_exclude_headfoot_begin:
+ {
+ \bool_set_false:N \l_@@_para_bool
+ \bool_if:NTF \g_@@_mode_lua_bool
+ {
+ \tag_mc_end_push:
+ }
+ {
+ \bool_gset_eq:NN \g_@@_saved_in_mc_bool \g_@@_in_mc_bool
+ \bool_gset_false:N \g_@@_in_mc_bool
+ }
+ \tag_mc_begin:n {artifact}
+ }
+\cs_new_protected:Npn \@@_exclude_headfoot_end:
+ {
+ \tag_mc_end:
+ \bool_if:NTF \g_@@_mode_lua_bool
+ {
+ \tag_mc_begin_pop:n{}
+ }
+ {
+ \bool_gset_eq:NN \g_@@_in_mc_bool\g_@@_saved_in_mc_bool
+ }
+ }
+
+\keys_define:nn { @@ / setup }
+ {
+ exclude-header-footer .choice:,
+ exclude-header-footer / true .code:n =
+ {
+ \cs_set_eq:NN \@@_hook_kernel_before_head: \@@_exclude_headfoot_begin:
+ \cs_set_eq:NN \@@_hook_kernel_before_foot: \@@_exclude_headfoot_begin:
+ \cs_set_eq:NN \@@_hook_kernel_after_head: \@@_exclude_headfoot_end:
+ \cs_set_eq:NN \@@_hook_kernel_after_foot: \@@_exclude_headfoot_end:
+ },
+ exclude-header-footer / false .code:n =
+ {
+ \cs_set_eq:NN \@@_hook_kernel_before_head: \prg_do_nothing:
+ \cs_set_eq:NN \@@_hook_kernel_before_foot: \prg_do_nothing:
+ \cs_set_eq:NN \@@_hook_kernel_after_head: \prg_do_nothing:
+ \cs_set_eq:NN \@@_hook_kernel_after_foot: \prg_do_nothing:
+ },
+ exclude-header-footer .default:n = true,
+ exclude-header-footer .initial:n = true
+ }
+% \end{macrocode}
+
% \subsection{Links}
% We need to close and reopen mc-chunks around links.
% Currently we handle URI and GoTo (internal) links.
diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx
index 2cb6e3d0631..0aeac22d7fb 100644
--- a/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx
+++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx
@@ -29,7 +29,7 @@
% \begin{macrocode}
%<@@=tag>
%<*package>
-\ProvidesExplPackage {tagpdf} {2021-07-03} {0.91}
+\ProvidesExplPackage {tagpdf} {2021-08-27} {0.92}
{ A package to experiment with pdf tagging }
\bool_if:nF
@@ -139,7 +139,9 @@
% \l_@@_tmpa_seq,
% \l_@@_tmpb_seq,
% \l_@@_tmpa_clist,
-% \l_@@_tmpa_int
+% \l_@@_tmpa_int,
+% \l_@@_tmpa_box,
+% \l_@@_tmpb_box
% }
% A few temporary variables
% \begin{macrocode}
@@ -150,6 +152,8 @@
\seq_new:N \l_@@_tmpb_seq
\clist_new:N \l_@@_tmpa_clist
\int_new:N \l_@@_tmpa_int
+\box_new:N \l_@@_tmpa_box
+\box_new:N \l_@@_tmpb_box
% \end{macrocode}
% \end{variable}
% Attribute lists for the label command. We have a list for
@@ -393,7 +397,11 @@
% \begin{macrocode}
log .choice:,
log / none .code:n = {\int_set:Nn \l_@@_loglevel_int { 0 }},
- log / v .code:n = {\int_set:Nn \l_@@_loglevel_int { 1 }},
+ log / v .code:n =
+ {
+ \int_set:Nn \l_@@_loglevel_int { 1 }
+ \cs_set_protected:Nn \@@_check_typeout_v:n { \iow_term:x {##1} }
+ },
log / vv .code:n = {\int_set:Nn \l_@@_loglevel_int { 2 }},
log / vvv .code:n = {\int_set:Nn \l_@@_loglevel_int { 3 }},
log / all .code:n = {\int_set:Nn \l_@@_loglevel_int { 10 }},