summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/tagpdf.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdf.dtx')
-rw-r--r--macros/latex/contrib/tagpdf/tagpdf.dtx123
1 files changed, 112 insertions, 11 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdf.dtx b/macros/latex/contrib/tagpdf/tagpdf.dtx
index 32b4100163..51d67e2ae9 100644
--- a/macros/latex/contrib/tagpdf/tagpdf.dtx
+++ b/macros/latex/contrib/tagpdf/tagpdf.dtx
@@ -33,12 +33,23 @@
% \end{syntax}
% \end{function}
%
-% \begin{function}{ \tag_stop_group_begin:, \tag_stop_group_end:, \tag_stop: }
-% We need a command to stop tagging in some places.
-% This simply switches the two local booleans. The grouping commands
+% \begin{function}{ \tag_stop_group_begin:, \tag_stop_group_end:,
+% \tag_stop:, \tag_start:, \tag_stop:n, \tag_start:n }
+% We need commands to stop tagging in some places.
+% There simply switches the two local booleans. The grouping commands
% can be used to group the effect.
% \end{function}
%
+% \begin{function}{\tag_stop:n, \tag_start:n }%
+% \begin{syntax}
+% \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.
+% \end{function}
+%
% \begin{function}{activate-space (setup-key)}
% |activate-space| activates the additional parsing needed for
% interword spaces. It is not documented, the parsing is currently
@@ -81,7 +92,7 @@
% \begin{macrocode}
%<@@=tag>
%<*package>
-\ProvidesExplPackage {tagpdf} {2022-05-29} {0.95}
+\ProvidesExplPackage {tagpdf} {2022-08-06} {0.96}
{ A package to experiment with pdf tagging }
\bool_if:nF
@@ -107,10 +118,10 @@
% \end{macrocode}
%<*debug>
% \begin{macrocode}
-\ProvidesExplPackage {tagpdf-debug} {2022-05-29} {0.95}
+\ProvidesExplPackage {tagpdf-debug} {2022-08-06} {0.96}
{ debug code for tagpdf }
\@ifpackageloaded{tagpdf}{}{\PackageWarning{tagpdf-debug}{tagpdf~not~loaded,~quitting}\endinput}
- \end{macrocode}
+% \end{macrocode}
%</debug>
% We map the internal module name \enquote{tag} to \enquote{tagpdf} in messages.
% \begin{macrocode}
@@ -148,7 +159,7 @@
% \end{macrocode}
% \begin{macrocode}
%<*base>
-\ProvidesExplPackage {tagpdf-base} {2022-05-29} {0.95}
+\ProvidesExplPackage {tagpdf-base} {2022-08-06} {0.96}
{part of tagpdf - provide base, no-op versions of the user commands }
%</base>
% \end{macrocode}
@@ -171,6 +182,50 @@
% \end{macrocode}
% \section{Temporary code}
% This is code which will be removed when proper support exists in LaTeX
+% \subsection{Faster object writing}
+%
+% \begin{macrocode}
+%<*package>
+\cs_if_free:NT \pdf_object_write_dict:nn
+ {
+ \cs_set_eq:NN \pdf_object_write_dict:nn \pdf_object_write:nn
+ }
+\cs_generate_variant:Nn \pdf_object_write_dict:nn {nx}
+
+\str_if_eq:VnT \c_sys_backend_str {pdftex}
+ {
+ \cs_if_free:NT \__pdf_backend_object_write_dict:nn
+ {
+ \cs_new_protected:Npn \__pdf_backend_object_write_dict:nn #1#2
+ {
+ \tex_immediate:D \tex_pdfobj:D
+ useobjnum ~
+ \int_use:c
+ { c__pdf_backend_object_ \tl_to_str:n {#1} _int }
+ { << ~ \exp_not:n {#2} ~ >> }
+ }
+ \cs_set_eq:NN \pdf_object_write_dict:nn \__pdf_backend_object_write_dict:nn
+ }
+ }
+
+\str_if_eq:VnT \c_sys_backend_str {luatex}
+ {
+ \cs_if_free:NT \__pdf_backend_object_write_dict:nn
+ {
+ \cs_new_protected:Npn \__pdf_backend_object_write_dict:nn #1#2
+ {
+ \tex_immediate:D \tex_pdfextension:D obj ~
+ useobjnum ~
+ \int_use:c
+ { c__pdf_backend_object_ \tl_to_str:n {#1} _int }
+ { << ~ \exp_not:n {#2} ~ >> }
+ }
+ \cs_set_eq:NN \pdf_object_write_dict:nn \__pdf_backend_object_write_dict:nn
+ }
+ }
+%</package>
+% \end{macrocode}
+
% \subsection{a LastPage label}
% See also issue \#2 in Accessible-xref
% \begin{macro}{\@@_lastpagelabel:}
@@ -225,6 +280,7 @@
% \begin{variable}
% {
% \l_@@_tmpa_tl,
+% \l_@@_tmpb_tl
% \l_@@_tmpa_str,
% \l_@@_tmpa_prop,
% \l_@@_tmpa_seq,
@@ -237,6 +293,7 @@
% A few temporary variables
% \begin{macrocode}
\tl_new:N \l_@@_tmpa_tl
+\tl_new:N \l_@@_tmpb_tl
\str_new:N \l_@@_tmpa_str
\prop_new:N \l_@@_tmpa_prop
\seq_new:N \l_@@_tmpa_seq
@@ -333,9 +390,11 @@
\cs_generate_variant:Nn \pdffile_embed_stream:nnn {nxx,oxx}
\cs_generate_variant:Nn \prop_gput:Nnn {Nxx,Nen}
\cs_generate_variant:Nn \prop_put:Nnn {Nxx}
+\cs_generate_variant:Nn \prop_item:Nn {No}
\cs_generate_variant:Nn \ref_label:nn { nv }
\cs_generate_variant:Nn \seq_set_split:Nnn{Nne}
\cs_generate_variant:Nn \str_set_convert:Nnnn {Nonn, Noon, Nnon }
+\cs_generate_variant:Nn \clist_map_inline:nn {on}
% \end{macrocode}
% \section{Setup label attributes}
@@ -444,10 +503,16 @@
% \end{macro}
%
% \section{General tagging commands}
-
-% \begin{macro}{ \tag_stop_group_begin:, \tag_stop_group_end: }
-% We need a command to stop tagging in some places.
+%
+% \begin{macro}{\tag_stop_group_begin:,
+% \tag_stop_group_end:,
+% \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.
% \begin{macrocode}
\cs_new_protected:Npn \tag_stop_group_begin:
{
@@ -456,14 +521,49 @@
\bool_set_false:N \l_@@_active_mc_bool
}
\cs_set_eq:NN \tag_stop_group_end: \group_end:
-\cs_new_protected:Npn \tag_stop:
+\cs_set_protected:Npn \tag_stop:
{
\bool_set_false:N \l_@@_active_struct_bool
\bool_set_false:N \l_@@_active_mc_bool
}
+\cs_set_protected:Npn \tag_start:
+ {
+ \bool_set_true:N \l_@@_active_struct_bool
+ \bool_set_true:N \l_@@_active_mc_bool
+ }
+\prop_new:N\g_@@_state_prop
+\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
+ \prop_gput:Nnn \g_@@_state_prop { #1 }{ 1 }
+ }
+ {
+ \prop_gremove:Nn \g_@@_state_prop { #1 }
+ }
+ }
+\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
+ {
+ \bool_set_true:N \l_@@_active_struct_bool
+ \bool_set_true:N \l_@@_active_mc_bool
+ }
+ }
+%</package>
+%<*base>
+\cs_new_protected:Npn \tag_stop:{}
+\cs_new_protected:Npn \tag_start:{}
+\cs_new_protected:Npn \tag_stop:n{}
+\cs_new_protected:Npn \tag_start:n{}
+%</base>
% \end{macrocode}
% \end{macro}
%
+%
% \section{Keys for tagpdfsetup}
% TODO: the log-levels must be sorted
@@ -484,6 +584,7 @@
% perhaps move to some other place, now that it is better separated.
% |no-struct-dest| allows to suppress structure destinations.
% \begin{macrocode}
+%<*package>
\keys_define:nn { @@ / setup }
{
activate-space .bool_gset:N = \g_@@_active_space_bool,