[latex3-commits] [latex3/tagpdf] faster-ref: merge ref command into general gput command (59cd93b)
github at latex-project.org
github at latex-project.org
Wed Sep 11 12:10:40 CEST 2024
Repository : https://github.com/latex3/tagpdf
On branch : faster-ref
Link : https://github.com/latex3/tagpdf/commit/59cd93b7897a3ed96962af20da091e0dba8a3f4e
>---------------------------------------------------------------
commit 59cd93b7897a3ed96962af20da091e0dba8a3f4e
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Wed Sep 11 12:10:40 2024 +0200
merge ref command into general gput command
>---------------------------------------------------------------
59cd93b7897a3ed96962af20da091e0dba8a3f4e
doc/tagpdf.tex | 15 ++++----
tagpdf-struct.dtx | 109 +++++++++++++++++++++++++++++++-----------------------
tagpdf.dtx | 4 +-
3 files changed, 72 insertions(+), 56 deletions(-)
diff --git a/doc/tagpdf.tex b/doc/tagpdf.tex
index 50d56d9..d0a5a4b 100644
--- a/doc/tagpdf.tex
+++ b/doc/tagpdf.tex
@@ -1879,24 +1879,25 @@ These commands insert a structure previously stashed away as kid into the
currently active structure. A structure should be used only once, if the
structure already has a parent you will get a warning.
-\subsubsection{Handling the \texttt{Ref} key in structures}\label{sec:Refkey}
+\subsubsection{Updating the \texttt{Ref} key in structures}\label{sec:Refkey}
Structures that cross reference other structures, e.g. citation commands, table of
content entries, footnote require often a \texttt{Ref} key. \texttt{Ref}
-can be added with the |ref| key if \cs{tagstructbegin} described above
+can be added with the |ref| key of \cs{tagstructbegin} described above
but as it is a task that often has to be done automatically in code
-there exist also a command. The target structure of a \texttt{Ref} key
-can be identified with three methods: through a label name set with the |label| key,
-through a destination name if a \cs{MakeLinkTarget} has been used in
+there exist also a command that allows to extend the \texttt{Ref} key (and perhaps in future also other keys) later.
+This command allows to add the value, the target structure of the \texttt{Ref} key,
+with four methods: directly as object reference, through a label name set with the |label| key, through a destination name if a \cs{MakeLinkTarget} has been used in
the target structure---this also works if hyperref has not been loaded---and through
the structure number, which has been stored e.g. in a label.
\begin{docCommands}
{
- {doc name=\tag_struct_gput_ref:nnn,doc parameter=\marg{structure number}\marg{keyword}\marg{value}},
+ {doc name=\tag_struct_gput:nnn,doc parameter=\marg{structure number}\marg{keyword}\marg{value}},
}\end{docCommands}
-
+The allowed \meta{keywords} are \texttt{ref}, \texttt{ref\_label} \texttt{ref\_dest}
+and \texttt{ref_num}.
\subsubsection{Root structure}
diff --git a/tagpdf-struct.dtx b/tagpdf-struct.dtx
index f4c7dd3..d524275 100644
--- a/tagpdf-struct.dtx
+++ b/tagpdf-struct.dtx
@@ -1276,13 +1276,22 @@
% It therefore stores it values as
% clist of commands which are executed at the end of the document,
% when the structure elements are written.
-% \begin{macro}{\@@_struct_Ref_label:nN,\@@_struct_Ref_dest:nN,\@@_struct_Ref_num:nN,}
+% \begin{macro}{\@@_struct_Ref_obj:nN,\@@_struct_Ref_label:nN,
+% \@@_struct_Ref_dest:nN,\@@_struct_Ref_num:nN}
% this commands are helper commands that are stored as clist
% in the Ref key of a structure. They are executed when the structure
% elements are written in \cs{@@_struct_write_obj}. They are used
-% in \cs{@@_struct_format_Ref}. They allow to add a Ref by label, destname
-% and structure number
+% in \cs{@@_struct_format_Ref}. They allow to add a Ref by object reference,
+% label, destname and structure number
% \begin{macrocode}
+\cs_new_protected:Npn \@@_struct_Ref_obj:nN #1 #2 %#1 a object reference
+ {
+ \tl_put_right:Ne#2
+ {
+ \c_space_tl#1
+ }
+ }
+
\cs_new_protected:Npn \@@_struct_Ref_label:nN #1 #2 %#1 a label
{
\prop_get:NnNTF \g_@@_struct_label_num_prop {#1} \l_@@_tmpb_tl
@@ -1325,14 +1334,11 @@
{
ref .code:n = % ref property
{
- \tl_clear:N\l_@@_tmpa_tl
\clist_map_inline:on {#1}
{
- \tl_put_right:Ne \l_@@_tmpa_tl
- {\exp_not:N\@@_struct_Ref_label:nN{##1},}
+ \tag_struct_gput:nne
+ {\int_use:N \c at g_@@_struct_abs_int}{ref_level}{ ##1 }
}
- \@@_struct_gput_data_ref:no
- { \int_use:N \c at g_@@_struct_abs_int } {\l_@@_tmpa_tl}
},
E .code:n = % E property
{
@@ -1933,6 +1939,7 @@
\pdf_object_ref_indexed:nn {@@/struct}{ #1 }
}
\cs_generate_variant:Nn \tag_struct_object_ref:n {e}
+%</package>
% \end{macrocode}
%
% \end{macro}
@@ -1944,10 +1951,18 @@
% adjusted to the key in question.
% The first argument is the number of the structure,
% the second a keyword referring to a function,
-% the third the value. Currently the only keyword is \texttt{ref} which updates
-% the Ref key (an array)
-% \begin{macrocode}
-\cs_new_protected:Npn \tag_struct_gput:nnn #1 #2 #3
+% the third the value. Currently the existing keywords are all related
+% to the \texttt{Ref} key (an array}.
+% The keyword \texttt{ref} takes as value an explicit object reference to
+% a structure. The keyword \texttt{ref_label} expects as value a label name (from
+% a label set in a \cs{tagstructbegin} command). The keyword \texttt{ref_dest}
+% expects a destination name set with \cs{MakeLinkTarget}. It then will refer to
+% the structure in which this \cs{MakeLinkTarget} was used. At last
+% the keyword \texttt{ref_num} expects a structure number.
+% \begin{macrocode}
+%<base>\cs_new_protected:Npn \tag_struct_gput:nnn #1 #2 #3{}
+%<*package>
+\cs_set_protected:Npn \tag_struct_gput:nnn #1 #2 #3
{
\cs_if_exist_use:cF {@@_struct_gput_data_#2:nn}
{ %warning??
@@ -1960,46 +1975,46 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\tag_struct_gput_ref:nnn}
-% This is an user interface to add a Ref key to an
-% existing structure. The target structure doesn't have to exist yet
-% but can be addressed by label, destname or even num.
+% \begin{macro}{\@@_struct_gput_data_ref_aux:nnn}
% \begin{macrocode}
-%<base>\cs_new_protected:Npn \tag_struct_gput_ref:nnn #1 #2 #3{}
%<*package>
-\cs_set_protected:Npn \tag_struct_gput_ref:nnn #1 #2 #3
-%#1 structnum, #2 label, dest or num, #3 value
- {
- \@@_struct_gput_data_ref:no
- { #1 } {\cs:w @@_struct_Ref_#2:nN \cs_end: { #3 } , }
- }
-%</package>
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_struct_gput_data_ref:nn}
-% \begin{macrocode}
-%<*package>
-\cs_new_protected:Npn \@@_struct_gput_data_ref:nn #1 #2
- % #1 receiving struct num, #2 list of object ref
+\cs_new_protected:Npn \@@_struct_gput_data_ref_aux:nnn #1 #2 #3
+ % #1 receiving struct num, #2 key word #3 value
{
\prop_get:cnNTF
- { g_@@_struct_#1_prop }
- {Ref}
- \l_@@_get_tmpc_tl
- {
- \@@_struct_prop_gput:nno
- { #1 }
- { Ref }
- { \l_@@_get_tmpc_tl,#2 }
- }
- {
- \@@_struct_prop_gput:nnn
- { #1 }
- { Ref }
- { #2 }
- }
+ { g_@@_struct_#1_prop }
+ {Ref}
+ \l_@@_get_tmpc_tl
+ {
+ \tl_put_right:No \l_@@_get_tmpc_tl
+ {\cs:w @@_struct_Ref_#2:nN \cs_end: {#3},}
+ }
+ {
+ \tl_set:No \l_@@_get_tmpc_tl
+ {\cs:w @@_struct_Ref_#2:nN \cs_end: {#3},}
+ }
+ \@@_struct_prop_gput:nno
+ { #1 }
+ { Ref }
+ { \l_@@_get_tmpc_tl }
}
+\cs_new_protected:Npn \@@_struct_gput_data_ref:nn #1 #2
+ {
+ \@@_struct_gput_data_ref_aux:nnn {#1}{obj}{#2}
+ }
+\cs_new_protected:Npn \@@_struct_gput_data_ref_label:nn #1 #2
+ {
+ \@@_struct_gput_data_ref_aux:nnn {#1}{label}{#2}
+ }
+\cs_new_protected:Npn \@@_struct_gput_data_ref_dest:nn #1 #2
+ {
+ \@@_struct_gput_data_ref_aux:nnn {#1}{dest}{#2}
+ }
+\cs_new_protected:Npn \@@_struct_gput_data_ref_num:nn #1 #2
+ {
+ \@@_struct_gput_data_ref_aux:nnn {#1}{num}{#2}
+ }
+
\cs_generate_variant:Nn \@@_struct_gput_data_ref:nn {ee,no}
% \end{macrocode}
% \end{macro}
diff --git a/tagpdf.dtx b/tagpdf.dtx
index 4842bff..ac3f555 100644
--- a/tagpdf.dtx
+++ b/tagpdf.dtx
@@ -200,7 +200,7 @@
{
\cs_set_protected:Npn \__fnote_gput_ref:nn #1 #2 %#1 the structure number receiving the ref #2
{
- \tag_struct_gput_ref:nnn {#1}{num}{#2}
+ \tag_struct_gput:nnn {#1}{ref_num}{#2}
}
}
\AddToHook{package/latex-lab-testphase-toc/after}
@@ -209,7 +209,7 @@
{
\prop_map_inline:Nn\g_@@_struct_ref_by_dest_prop
{
- \tag_struct_gput_ref:nnn {##1}{dest}{##2}
+ \tag_struct_gput:nnn {##1}{ref_dest}{##2}
}
}
}
More information about the latex3-commits
mailing list.