summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/tagpdf.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-12-19 03:00:50 +0000
committerNorbert Preining <norbert@preining.info>2023-12-19 03:00:50 +0000
commit60e9a31bad8271499f6b5f9280174e76bd62814f (patch)
treec33ee4a5f7e5fb95bab9a06c6a5121e1f4728db1 /macros/latex/contrib/tagpdf/tagpdf.dtx
parente7154d152b4c047832de9bd4cf0d2bc3efe4125a (diff)
CTAN sync 202312190300
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdf.dtx')
-rw-r--r--macros/latex/contrib/tagpdf/tagpdf.dtx118
1 files changed, 63 insertions, 55 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdf.dtx b/macros/latex/contrib/tagpdf/tagpdf.dtx
index 907f466a43..37de4d9927 100644
--- a/macros/latex/contrib/tagpdf/tagpdf.dtx
+++ b/macros/latex/contrib/tagpdf/tagpdf.dtx
@@ -18,27 +18,19 @@
%
% The development version of the bundle can be found at
%
-% https://github.com/u-fischer/tagpdf
+% https://github.com/latex3/tagpdf
%
% for those people who are interested.
%
% \fi
% \begin{documentation}
-% \begin{function}{\ref_value:nnn}
-% This is a temporary definition which will be removed once properties have been
-% released. It allows to locally set a default value if the label or the attribute
-% doesn't exist.
-% \begin{syntax}
-% \cs{ref_value:nnn}\Arg{label}\Arg{attribute}\Arg{fallback default}
-% \end{syntax}
-% \end{function}
-%
-% \begin{function}{ \tag_stop_group_begin:, \tag_stop_group_end:,
+% \begin{function}{
% \tag_stop:, \tag_start:,
% \tagstop, \tagstart }
% We need commands to stop tagging in some places.
-% They simply switches the two local booleans. The grouping commands
-% can be used to group the effect.
+% They switches three local booleans and also stop the counting
+% of paragraphs. If they are nested an inner \cs{tag_start:} will not
+% restart tagging.
% \end{function}
%
% \begin{function}{\tag_stop:n, \tag_start:n }%
@@ -46,9 +38,8 @@
% \cs{tag_stop:n}\Arg{label}
% \cs{tag_start:n}\Arg{label}\\
% \end{syntax}
-% This commands are intended as a pair. The start command
-% will only restart tagging if the previous stop command
-% with the same label actually stopped tagging.
+% The commands with argument allow to give a label. This is only used
+% in debugging messages to allow to follow the nesting.
% \end{function}
%
% \begin{function}{activate-space (setup-key)}
@@ -93,7 +84,7 @@
% \begin{macrocode}
%<@@=tag>
%<*package>
-\ProvidesExplPackage {tagpdf} {2023-11-19} {0.98q}
+\ProvidesExplPackage {tagpdf} {2023-12-18} {0.98r}
{ A package to experiment with pdf tagging }
\bool_if:nF
@@ -119,7 +110,7 @@
% \end{macrocode}
%<*debug>
% \begin{macrocode}
-\ProvidesExplPackage {tagpdf-debug} {2023-11-19} {0.98q}
+\ProvidesExplPackage {tagpdf-debug} {2023-12-18} {0.98r}
{ debug code for tagpdf }
\@ifpackageloaded{tagpdf}{}{\PackageWarning{tagpdf-debug}{tagpdf~not~loaded,~quitting}\endinput}
% \end{macrocode}
@@ -142,7 +133,7 @@
% we define a base package with dummy functions
% \begin{macrocode}
%<*base>
-\ProvidesExplPackage {tagpdf-base} {2023-11-19} {0.98q}
+\ProvidesExplPackage {tagpdf-base} {2023-12-18} {0.98r}
{part of tagpdf - provide base, no-op versions of the user commands }
%</base>
% \end{macrocode}
@@ -281,7 +272,7 @@
% }
% These booleans should help to control the global behaviour of tagpdf.
% Ideally it should more or less do nothing if all are false.
-% The space-boolean controles the interword space code,
+% The space-boolean controls the interword space code,
% the mc-boolean activates \cs{tag_mc_begin:n},
% the tree-boolean activates writing the finish code and the pdfmanagement related
% commands, the struct-boolean activates the storing of the structure data.
@@ -306,7 +297,8 @@
% \begin{variable}
% {
% \l_@@_active_mc_bool,
-% \l_@@_active_struct_bool
+% \l_@@_active_struct_bool,
+% \l_@@_active_socket_bool
% }
% These booleans should help to control the \emph{local} behaviour of tagpdf.
% In some cases it could e.g. be necessary to stop tagging completely.
@@ -317,6 +309,7 @@
\bool_set_true:N \l_@@_active_mc_bool
\bool_new:N \l_@@_active_struct_bool
\bool_set_true:N \l_@@_active_struct_bool
+\bool_new:N \l_@@_active_socket_bool
% \end{macrocode}
% \end{variable}
%
@@ -378,7 +371,7 @@
\cs_generate_variant:Nn \@@_property_record:nn {en,eV}
% \end{macrocode}
% \end{macro}
-%
+%
% \begin{macro}{\@@_property_ref_lastpage:nn}
% A command to retrieve the lastpage label, this will be adapted when there
% is a proper, kernel lastpage label.
@@ -456,68 +449,83 @@
\cs_generate_variant:Nn \@@_seq_new:N { c }
\cs_generate_variant:Nn \@@_seq_show:N { c }
\cs_generate_variant:Nn \@@_prop_show:N { c }
+%</package>
% \end{macrocode}
% \end{macro}
%
% \section{General tagging commands}
%
-% \begin{macro}{\tag_stop_group_begin:,
-% \tag_stop_group_end:,
+% \begin{macro}{
% \tag_stop:,\tag_start:,
% \tag_stop:n,\tag_start:n}
% We need commands to stop tagging in some places.
-% This simply switches the two local booleans.
-% In some cases tagging should only restart, if
-% it actually was stopped before. For this it is possible
-% to label a stop.
+% They switch local booleans and also stop the counting of paragraphs.
+% The commands keep track of the nesting with a local
+% counter. Tagging only is only restarted at the outer level,
+% if the current level is 1.
+% The commands with argument allow to give a label. This is only used
+% in debugging messages to allow to follow the nesting.
+%
+% \begin{variable}{\l_@@_tag_stop_int}
+% When stop/start pairs are nested we do not want the inner
+% start command to restart tagging. To control this we use a
+% local int: The stop command will increase it. The starting
+% will decrease it and only restart tagging, if it is zero.
+% This will replace the label version.
+% \begin{macrocode}
+%<*package|debug>
+%<package>\int_new:N \l_@@_tag_stop_int
+% \end{macrocode}
+% \end{variable}
+%
% \begin{macrocode}
-\cs_new_protected:Npn \tag_stop_group_begin:
- {
- \group_begin:
- \bool_set_false:N \l_@@_active_struct_bool
- \bool_set_false:N \l_@@_active_mc_bool
- \@@_stop_para_ints:
- }
-\cs_set_eq:NN \tag_stop_group_end: \group_end:
\cs_set_protected:Npn \tag_stop:
{
+%<debug> \msg_note:nnx {tag / debug }{tag-stop}{ \int_use:N \l_@@_tag_stop_int }
+ \int_incr:N \l_@@_tag_stop_int
\bool_set_false:N \l_@@_active_struct_bool
\bool_set_false:N \l_@@_active_mc_bool
+ \bool_set_false:N \l_@@_active_socket_bool
\@@_stop_para_ints:
}
\cs_set_protected:Npn \tag_start:
{
- \bool_set_true:N \l_@@_active_struct_bool
- \bool_set_true:N \l_@@_active_mc_bool
- \@@_start_para_ints:
+ \int_if_zero:nF { \l_@@_tag_stop_int } { \int_decr:N \l_@@_tag_stop_int }
+ \int_if_zero:nT { \l_@@_tag_stop_int }
+ {
+ \bool_set_true:N \l_@@_active_struct_bool
+ \bool_set_true:N \l_@@_active_mc_bool
+ \bool_set_true:N \l_@@_active_socket_bool
+ \@@_start_para_ints:
+ }
+%<debug> \msg_note:nnx {tag / debug }{tag-start}{ \int_use:N \l_@@_tag_stop_int }
}
\cs_set_eq:NN\tagstop\tag_stop:
\cs_set_eq:NN\tagstart\tag_start:
-\prop_new:N\g_@@_state_prop
+% \end{macrocode}
+% \begin{macrocode}
\cs_set_protected:Npn \tag_stop:n #1
{
- \tag_if_active:TF
- {
- \bool_set_false:N \l_@@_active_struct_bool
- \bool_set_false:N \l_@@_active_mc_bool
- \@@_stop_para_ints:
- \prop_gput:Nnn \g_@@_state_prop { #1 }{ 1 }
- }
- {
- \prop_gremove:Nn \g_@@_state_prop { #1 }
- }
+%<debug> \msg_note:nnxx {tag / debug }{tag-stop}{ \int_use:N \l_@@_tag_stop_int }{#1}
+ \int_incr:N \l_@@_tag_stop_int
+ \bool_set_false:N \l_@@_active_struct_bool
+ \bool_set_false:N \l_@@_active_mc_bool
+ \bool_set_false:N \l_@@_active_socket_bool
+ \@@_stop_para_ints:
}
\cs_set_protected:Npn \tag_start:n #1
{
- \prop_gpop:NnN \g_@@_state_prop {#1}\l_@@_tmpa_tl
- \quark_if_no_value:NF \l_@@_tmpa_tl
+ \int_if_zero:nF { \l_@@_tag_stop_int } { \int_decr:N \l_@@_tag_stop_int }
+ \int_if_zero:nT { \l_@@_tag_stop_int }
{
\bool_set_true:N \l_@@_active_struct_bool
\bool_set_true:N \l_@@_active_mc_bool
+ \bool_set_true:N \l_@@_active_socket_bool
\@@_start_para_ints:
- }
+ }
+%<debug> \msg_note:nnxx {tag / debug }{tag-start}{ \int_use:N \l_@@_tag_stop_int }{#1}
}
-%</package>
+%</package|debug>
%<*base>
\cs_new_protected:Npn \tag_stop:{}
\cs_new_protected:Npn \tag_start:{}
@@ -541,7 +549,7 @@
% activate-tree (setup-key),
% activate-struct (setup-key),
% activate-all (setup-key),
-% no-struct-dest (setup-key)
+% no-struct-dest (setup-key),
% }
% Keys to (globally) activate tagging.
% |activate-space| activates the additional parsing needed for