summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/tagpdf-struct.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-03-27 03:02:20 +0000
committerNorbert Preining <norbert@preining.info>2024-03-27 03:02:20 +0000
commit31fa8cd73bab8480d38dae3a89ca578f337d6bbd (patch)
treeba550e99e0cb15dbf5405369d536b12b051c5155 /macros/latex/contrib/tagpdf/tagpdf-struct.dtx
parent904f56f2c26edc7eb11d5a27579bccbeca29c618 (diff)
CTAN sync 202403270302
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdf-struct.dtx')
-rw-r--r--macros/latex/contrib/tagpdf/tagpdf-struct.dtx100
1 files changed, 57 insertions, 43 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdf-struct.dtx b/macros/latex/contrib/tagpdf/tagpdf-struct.dtx
index 64bd8f4c56..8b1a9555d5 100644
--- a/macros/latex/contrib/tagpdf/tagpdf-struct.dtx
+++ b/macros/latex/contrib/tagpdf/tagpdf-struct.dtx
@@ -46,7 +46,7 @@
% }^^A
% }
%
-% \date{Version 0.98x, released 2024-02-29}
+% \date{Version 0.99a, released 2024-03-27}
% \maketitle
% \begin{documentation}
% \section{Public Commands}
@@ -285,7 +285,7 @@
% \begin{macrocode}
%<@@=tag>
%<*header>
-\ProvidesExplPackage {tagpdf-struct-code} {2024-02-29} {0.98x}
+\ProvidesExplPackage {tagpdf-struct-code} {2024-03-27} {0.99a}
{part of tagpdf - code related to storing structure}
%</header>
% \end{macrocode}
@@ -791,14 +791,14 @@
% break into two or more mcid. In this case the lua code has to convert
% put the dictionary of the kid into an array. See issue 13 at tagpdf repo.
% We exchange the dummy command for the kids to mark this case.
+% Change 2024-03-19: don't use a regex - that is slow.
% \begin{macrocode}
\cs_new_protected:Npn\@@_struct_exchange_kid_command:N #1 %#1 = seq var
{
\seq_gpop_left:NN #1 \l_@@_tmpa_tl
- \regex_replace_once:nnN
- { \c{\@@_mc_insert_mcid_kids:n} }
- { \c{\@@_mc_insert_mcid_single_kids:n} }
- \l_@@_tmpa_tl
+ \tl_replace_once:Nnn \l_@@_tmpa_tl
+ {\@@_mc_insert_mcid_kids:n}
+ {\@@_mc_insert_mcid_single_kids:n}
\seq_gput_left:NV #1 \l_@@_tmpa_tl
}
@@ -900,49 +900,41 @@
% \begin{macro}{\@@_struct_get_dict_content:nN}
% This maps the dictionary content of a structure into a tl-var.
% Basically it does what |\pdfdict_use:n| does.
-% TODO!! this looks over-complicated. Check if it can be done with pdfdict now.
+% This is used a lot so should be rather fast.
% \begin{macrocode}
\cs_new_protected:Npn \@@_struct_get_dict_content:nN #1 #2 %#1: stucture num
{
\tl_clear:N #2
- \seq_map_inline:cn
+ \prop_map_inline:cn { g_@@_struct_#1_prop }
{
- c_@@_struct_
- \int_compare:nNnTF{#1}={0}{StructTreeRoot}{StructElem}
- _entries_seq
- }
- {
- \tl_put_right:Ne
- #2
+ \tl_put_right:Ne #2
{
- \prop_if_in:cnT
- { g_@@_struct_#1_prop }
- { ##1 }
- {
- \c_space_tl/##1~
-% \end{macrocode}
-% Some keys needs the option to format the key, e.g. add brackets for an
-% array
-% \begin{macrocode}
- \cs_if_exist_use:cTF {@@_struct_format_##1:e}
- {
- { \prop_item:cn{ g_@@_struct_#1_prop } { ##1 } }
- }
- {
- \prop_item:cn{ g_@@_struct_#1_prop } { ##1 }
- }
- }
+% \end{macrocode}
+% Some keys needs the option to format the value, e.g. add brackets for an
+% array, we also need the option to ignore some entries in the properties.
+% \begin{macrocode}
+ \cs_if_exist_use:cTF {@@_struct_format_##1:nn}
+ {{##1}{##2}}
+ {\c_space_tl/##1~##2}
}
}
}
% \end{macrocode}
% \end{macro}
-% \begin{macro}{\@@_struct_format_Ref:n}
+%
+% \begin{macro}{\@@_struct_format_rolemap:nn,\@@_struct_format_parentrole:nn}
+% This two entries should not end in the PDF.
+% \begin{macrocode}
+\cs_new:Nn\@@_struct_format_rolemap:nn{}
+\cs_new:Nn\@@_struct_format_parentrole:nn{}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\@@_struct_format_Ref:nn}
% Ref is an array, we store only the content to be able to extend it
% so the formatting command adds the brackets:
% \begin{macrocode}
-\cs_new:Nn\__tag_struct_format_Ref:n{[#1]}
-\cs_generate_variant:Nn\__tag_struct_format_Ref:n{e}
+\cs_new:Nn\__tag_struct_format_Ref:nn{\c_space_tl/#1~[#2]}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@@_struct_write_obj:n}
@@ -1433,11 +1425,17 @@
}
},
}
-%</package>
% \end{macrocode}
% \end{macro}
% \section{User commands}
-%
+% We allow to set a language by default
+% \begin{macro}{\l_@@_struct_lang_tl}
+% \begin{macrocode}
+\tl_new:N \l_@@_struct_lang_tl
+%</package>
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\tag_struct_begin:n,\tag_struct_end:}
% \begin{macrocode}
%<base>\cs_new_protected:Npn \tag_struct_begin:n #1 {\int_gincr:N \c@g_@@_struct_abs_int}
@@ -1464,6 +1462,18 @@
{ \int_use:N \c@g_@@_struct_abs_int }
{ Type }
{ /StructElem }
+ \tl_if_empty:NF \l_@@_struct_lang_tl
+ {
+ \@@_struct_prop_gput:nne
+ { \int_use:N \c@g_@@_struct_abs_int }
+ { Lang }
+ { (\l_@@_struct_lang_tl) }
+ }
+ \@@_struct_prop_gput:nnn
+ { \int_use:N \c@g_@@_struct_abs_int }
+ { Type }
+ { /StructElem }
+
\tl_set:Nn \l_@@_struct_stack_parent_tmpa_tl {-1}
\keys_set:nn { @@ / struct} { #1 }
% \end{macrocode}
@@ -1626,7 +1636,7 @@
%<debug> {no~parent:~stashed}
%<debug> {
%<debug> parent~structure:~\l_@@_struct_stack_parent_tmpa_tl\c_space_tl =~
-%<debug> \l_@@_get_parent_tmpa_tl
+%<debug> \prop_item:cn{ g__tag_struct_\l_@@_struct_stack_parent_tmpa_tl _prop }{S}
%<debug> }
%<debug> }
%<debug> \prop_gput:cne
@@ -1928,7 +1938,7 @@
% \section{Attributes and attribute classes}
% \begin{macrocode}
%<*header>
-\ProvidesExplPackage {tagpdf-attr-code} {2024-02-29} {0.98x}
+\ProvidesExplPackage {tagpdf-attr-code} {2024-03-27} {0.99a}
{part of tagpdf - code related to attributes and attribute classes}
%</header>
% \end{macrocode}
@@ -1936,12 +1946,12 @@
% \begin{variable}
% {
% ,\g_@@_attr_entries_prop
-% ,\g_@@_attr_class_used_seq
+% ,\g_@@_attr_class_used_prop
% ,\g_@@_attr_objref_prop
% ,\l_@@_attr_value_tl
% }
% |\g_@@_attr_entries_prop| will store attribute names and their dictionary content.\\
-% |\g_@@_attr_class_used_seq| will hold the attributes which have been used as
+% |\g_@@_attr_class_used_prop| will hold the attributes which have been used as
% class name.
% |\l_@@_attr_value_tl| is used to build the attribute array or key.
% Every time an attribute is used for the first time, and object is created
@@ -1950,10 +1960,14 @@
% \begin{macrocode}
%<*package>
\prop_new:N \g_@@_attr_entries_prop
-\seq_new:N \g_@@_attr_class_used_seq
+\prop_new_linked:N \g_@@_attr_class_used_prop
\tl_new:N \l_@@_attr_value_tl
\prop_new:N \g_@@_attr_objref_prop %will contain obj num of used attributes
% \end{macrocode}
+% This seq is currently kept for compability with the table code.
+% \begin{macrocode}
+\seq_new:N\g_@@_attr_class_used_seq
+% \end{macrocode}
% \end{variable}
% \subsection{Commands and keys}
% \begin{macro}{\@@_attr_new_entry:nn,role/new-attribute (setup-key), newattribute (deprecated)}
@@ -2022,7 +2036,7 @@
{
\msg_error:nnn { tag } { attr-unknown } { ##1 }
}
- \seq_gput_left:Nn\g_@@_attr_class_used_seq { ##1}
+ \prop_gput:Nnn\g_@@_attr_class_used_prop { ##1} {}
}
\tl_set:Ne \l_@@_tmpa_tl
{