diff options
author | Norbert Preining <norbert@preining.info> | 2024-02-04 03:00:55 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2024-02-04 03:00:55 +0000 |
commit | 16f68bbec3cca735a695904227872abc2ace1f90 (patch) | |
tree | bcabe1bea02359da24036bb8e3a9741751516a84 /macros/latex/contrib/tagpdf/tagpdf-user.dtx | |
parent | 8d5a9f6bbecb297f513b9ed16e574db1c1310228 (diff) |
CTAN sync 202402040300
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdf-user.dtx')
-rw-r--r-- | macros/latex/contrib/tagpdf/tagpdf-user.dtx | 191 |
1 files changed, 124 insertions, 67 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdf-user.dtx b/macros/latex/contrib/tagpdf/tagpdf-user.dtx index ebdc8cece2..aea543ba40 100644 --- a/macros/latex/contrib/tagpdf/tagpdf-user.dtx +++ b/macros/latex/contrib/tagpdf/tagpdf-user.dtx @@ -46,7 +46,7 @@ % }^^A % } % -% \date{Version 0.98t, released 2024-01-26} +% \date{Version 0.98u, released 2024-02-02} % \maketitle % \begin{documentation} % \section{Setup commands} @@ -303,7 +303,7 @@ % \begin{macrocode} %<@@=tag> %<*header> -\ProvidesExplPackage {tagpdf-user} {2024-01-26} {0.98t} +\ProvidesExplPackage {tagpdf-user} {2024-02-02} {0.98u} {tagpdf - user commands} %</header> % \end{macrocode} @@ -736,6 +736,7 @@ % \g_@@_para_end_int, % \g_@@_para_main_begin_int, % \g_@@_para_main_end_int, +% \g_@@_para_main_struct_tl, % \l_@@_para_tag_default_tl, % \l_@@_para_tag_tl, % \l_@@_para_main_tag_tl, @@ -752,6 +753,10 @@ \int_new:N \g_@@_para_end_int \int_new:N \g_@@_para_main_begin_int \int_new:N \g_@@_para_main_end_int +% \end{macrocode} +% this will hold the structure number of the current text-unit. +% \begin{macrocode} +\tl_new:N \g_@@_para_main_struct_tl \tl_new:N \l_@@_para_tag_default_tl \tl_set:Nn \l_@@_para_tag_default_tl { text } \tl_new:N \l_@@_para_tag_tl @@ -795,7 +800,6 @@ } % \end{macrocode} % \end{macro} - % \begin{macro}{\@@_start_para_ints:,\@@_stop_para_ints:} % \begin{macrocode} \cs_new_protected:Npn \@@_start_para_ints: @@ -827,21 +831,31 @@ % \end{macrocode} % \end{macro} % +% We want to be able to inspect the current para main structure, so +% we need a command to store its structure number +% \begin{macro}{\@@_para_main_store_struct:} +% \begin{macrocode} +\cs_new:Npn \@@_para_main_store_struct: + { + \tl_gset:Ne \g_@@_para_main_struct_tl {\int_use:N \c@g_@@_struct_abs_int } + } +% \end{macrocode} +% \end{macro} % TEMPORARLY FIX (2023-11-17). Until latex-lab is updated we must adapt a sec command: % \begin{macrocode} \AddToHook{package/latex-lab-testphase-sec/after} { \cs_set_protected:Npn \@kernel@tag@hangfrom #1 { - \tagstructbegin{tag=\l__tag_para_tag_tl} - \__tag_gincr_para_begin_int: + \tagstructbegin{tag=\l_@@_para_tag_tl} + \@@_gincr_para_begin_int: \tagstructbegin{tag=Lbl} \setbox\@tempboxa \hbox { \bool_lazy_and:nnT {\tag_if_active_p:} - {\g__tag_mode_lua_bool} + {\g_@@_mode_lua_bool} {\tagmcbegin{tag=Lbl}} {#1} } @@ -852,7 +866,7 @@ } } % \end{macrocode} -% and two adaptions from the block module: +% and one temporary adaptions for the block module: % \begin{macrocode} \AddToHook{package/latex-lab-testphase-block/after} { @@ -860,49 +874,6 @@ { \tl_set:Nn \l_@@_para_attr_class_tl { \l_tag_para_attr_class_tl } } - \cs_set_protected:Npn \__block_start_para_structure:n #1 { - \__block_debug_typeout:n - { @endpe = \legacy_if:nTF { @endpe }{true}{false} - \on@line } - \legacy_if:nF { @endpe } - { - \bool_if:NF \l__tag_para_flattened_bool - { - \@@_gincr_para_main_begin_int: - \tag_struct_begin:n - { - tag=\l_@@_para_main_tag_tl, - attribute-class=\l_@@_para_main_attr_class_tl, - } - } - } - \@@_gincr_para_begin_int: - \__block_debug_typeout:n{increment~ P \on@line } - \tag_struct_begin:n - { - tag=\l__tag_para_tag_tl - ,attribute-class=\l_@@_para_attr_class_tl - } - \__tag_check_para_begin_show:nn {green}{#1} - \tag_mc_begin:n {} - } - \RemoveFromHook{para/end}[latex-lab-testphase-block] - \AddToHook{para/end}[latex-lab-testphase-block] - { - \bool_if:NT \l__tag_para_bool - { - \__tag_gincr_para_end_int: - \__block_debug_typeout:n{increment~ /P \on@line } - \tag_mc_end: - \__tag_check_para_end_show:nn {red}{} - \tag_struct_end: - \bool_if:NF \l__tag_para_flattened_bool - { - \__tag_gincr_para_main_end_int: - \tag_struct_end: - } - } - } } % \end{macrocode} @@ -934,7 +905,7 @@ } % \end{macrocode} % \end{macro} -% This fills the para hooks with the needed code. +% Helper command for debugging: % \begin{macrocode} \cs_new_protected:Npn \@@_check_para_begin_show:nn #1 #2 %#1 color, #2 prefix @@ -957,30 +928,82 @@ \tag_mc_end: } } - -\AddToHook{para/begin} - { +% \end{macrocode} +% +% The para/begin and para/end code. +% We have two variants here: a simpler one, which must be used +% if the block code is not used (and so probably will disappear +% at some time) and a more sophisticated one that must +% be used if the block code is used. +% It is possible that we will need more variants, so +% we setup a socket so that the code can be easily switched. +% \begin{macrocode} +\socket_new:nn {tagsupport/para/begin}{0} +\socket_new:nn {tagsupport/para/end}{0} + +\socket_new_plug:nnn{tagsupport/para/begin}{plain} + { \bool_if:NT \l_@@_para_bool { \bool_if:NF \l_@@_para_flattened_bool + { + \@@_gincr_para_main_begin_int: + \tag_struct_begin:n + { + tag=\l_@@_para_main_tag_tl, + } + \@@_para_main_store_struct: + } + \@@_gincr_para_begin_int: + \tag_struct_begin:n {tag=\l_@@_para_tag_tl} + \@@_check_para_begin_show:nn {green}{} + \tag_mc_begin:n {} + } + } +\socket_new_plug:nnn{tagsupport/para/begin}{block} + { + \bool_if:NT \l_@@_para_bool + { + \legacy_if:nF { @inlabel } { - \@@_gincr_para_main_begin_int: - \tag_struct_begin:n - { - tag=\l_@@_para_main_tag_tl, + \@@_check_typeout_v:n + {==>~ @endpe = \legacy_if:nTF { @endpe }{true}{false} \on@line } + \legacy_if:nF { @endpe } + { + \bool_if:NF \l_@@_para_flattened_bool + { + \@@_gincr_para_main_begin_int: + \tag_struct_begin:n + { + tag=\l_@@_para_main_tag_tl, + attribute-class=\l_@@_para_main_attr_class_tl, + } + \@@_para_main_store_struct: + } } - } - \@@_gincr_para_begin_int: - \tag_struct_begin:n {tag=\l_@@_para_tag_tl} - \@@_check_para_begin_show:nn {green}{} - \tag_mc_begin:n {} - } - } -\AddToHook{para/end} + \@@_gincr_para_begin_int: + \@@_check_typeout_v:n {==>~increment~ P \on@line } + \tag_struct_begin:n + { + tag=\l_@@_para_tag_tl + ,attribute-class=\l_@@_para_attr_class_tl + } + \@@_check_para_begin_show:nn {green}{\PARALABEL} + \tag_mc_begin:n {} + } + } + } +% \end{macrocode} +% there was no real difference between the original and +% in the block variant, only a debug message. We therefore +% define only a plain variant. +% \begin{macrocode} +\socket_new_plug:nnn{tagsupport/para/end}{plain} { \bool_if:NT \l_@@_para_bool { \@@_gincr_para_end_int: + \@@_check_typeout_v:n {==>~increment~ /P \on@line } \tag_mc_end: \@@_check_para_end_show:nn {red}{} \tag_struct_end: @@ -989,9 +1012,43 @@ \@@_gincr_para_main_end_int: \tag_struct_end: } - } + } } % \end{macrocode} +% By default we assign the plain plug: +% \begin{macrocode} +\socket_assign_plug:nn { tagsupport/para/begin}{plain} +\socket_assign_plug:nn { tagsupport/para/end}{plain} +% \end{macrocode} +% And use the sockets in the hooks. Once tagging sockets exist, this +% can be adapted. +% \begin{macrocode} +\AddToHook{para/begin}{ \socket_use:n { tagsupport/para/begin } + } +\AddToHook{para/end} { \socket_use:n { tagsupport/para/end } } +% \end{macrocode} +% +% If the block code is loaded we must ensure that it doesn't overwrite +% the hook again. And we must reassign the para/begin plug. +% This can go once the block code no longer tries to adapt the hooks. +% \begin{macrocode} +\AddToHook{package/latex-lab-testphase-block/after} + { + \RemoveFromHook{para/begin}[tagpdf] + \RemoveFromHook{para/end}[latex-lab-testphase-block] + \AddToHook{para/begin}[tagpdf] + { + \socket_use:n { tagsupport/para/begin } + } + \AddToHook{para/end}[tagpdf] + { + \socket_use:n { tagsupport/para/end } + } + \socket_assign_plug:nn { tagsupport/para/begin}{block} + } + +% \end{macrocode} +% % We check the para count at the end. If tagging is not active it is not a error, % but we issue a warning as it perhaps indicates that the testphase code didn't guard % everything correctly. |