summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/tagpdf-user.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdf-user.dtx')
-rw-r--r--macros/latex/contrib/tagpdf/tagpdf-user.dtx217
1 files changed, 206 insertions, 11 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdf-user.dtx b/macros/latex/contrib/tagpdf/tagpdf-user.dtx
index 4b408a60ea..23737dfc29 100644
--- a/macros/latex/contrib/tagpdf/tagpdf-user.dtx
+++ b/macros/latex/contrib/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.