summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/tagpdf-struct.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-01-14 03:01:14 +0000
committerNorbert Preining <norbert@preining.info>2022-01-14 03:01:14 +0000
commit45623da68203ac8d7aa04b779a6ed65c92c3f866 (patch)
tree151ca3ede3ee826360d4b32c0029cfc106346ec9 /macros/latex/contrib/tagpdf/tagpdf-struct.dtx
parentee3f9ca89b21a2174f7e427d9d48247b1912e130 (diff)
CTAN sync 202201140301
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdf-struct.dtx')
-rw-r--r--macros/latex/contrib/tagpdf/tagpdf-struct.dtx200
1 files changed, 149 insertions, 51 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdf-struct.dtx b/macros/latex/contrib/tagpdf/tagpdf-struct.dtx
index 610d631333..6f03c5ac0f 100644
--- a/macros/latex/contrib/tagpdf/tagpdf-struct.dtx
+++ b/macros/latex/contrib/tagpdf/tagpdf-struct.dtx
@@ -2,7 +2,7 @@
%
%% File: tagpdf-struct.dtx
%
-% Copyright (C) 2019-2021 Ulrike Fischer
+% Copyright (C) 2019-2022 Ulrike Fischer
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -50,7 +50,7 @@
% }^^A
% }
%
-% \date{Version 0.92, released 2021-08-27}
+% \date{Version 0.93, released 2022-01-13}
% \maketitle
% \begin{documentation}
% \section{Public Commands}
@@ -94,9 +94,9 @@
% \end{function}
% \section{Public keys}
% \subsection{Keys for the structure commands}
-% \begin{function}{tag}
+% \begin{function}{tag (struct-key)}
% This is required. The value of the key is normally one of the
-% standard types listed in section \ref{sec:new-tag}.
+% standard types listed in the main tagpdf documentation.
% It is possible to setup new tags/types.
% The value can also be of the form |type/NS|, where |NS| is the
% shorthand of a declared name space.
@@ -104,54 +104,54 @@
% This allows to use a different name space than
% the one connected by default to the tag. But normally this should not be needed.
% \end{function}
-% \begin{function}{stash}
+% \begin{function}{stash (struct-key)}
% Normally a new structure inserts itself as a kid
% into the currently active structure. This key prohibits this.
% The structure is nevertheless from now on
% \enquote{the current active structure}
% and parent for following marked content and structures.
% \end{function}
-% \begin{function}{label}
+% \begin{function}{label (struct-key)}
% This key sets a label by which
% one can use the structure later in another structure.
% Internally the label name will start with \texttt{tagpdfstruct-}.
% \end{function}
-% \begin{function}{title,title-o}
+% \begin{function}{title (struct-key),title-o (struct-key)}
% This keys allows to set the dictionary entry
% \texttt{/Title} in the structure object.
% The value is handled as verbatim string and hex encoded.
% Commands are not expanded. |title-o| will expand the value once.
% \end{function}
%
-% \begin{function}{alttext}
+% \begin{function}{alttext (struct-key)}
% This key inserts an \texttt{/Alt} value in the dictionary of structure object.
% The value is handled as verbatim string and hex encoded.
% The value will be expanded first once.
% \end{function}
-% \begin{function}{actualtext}
+% \begin{function}{actualtext (struct-key)}
% This key inserts an \texttt{/ActualText} value in the dictionary of structure object.
% The value is handled as verbatim string and hex encoded.
% The value will be expanded first once.
% \end{function}
-% \begin{function}{lang}
+% \begin{function}{lang (struct-key)}
% This key allows to set the language for a structure element. The value should be a bcp-identifier,
% e.g. |de-De|.
% \end{function}
-% \begin{function}{ref}
+% \begin{function}{ref (struct-key)}
% This key allows to add references to other structure elements,
% it adds the |/Ref| array to the structure.
% The value should be a comma separated list of structure labels
% set with the |label| key. e.g. |ref={label1,label2}|.
% \end{function}
-% \begin{function}{E}
+% \begin{function}{E (struct-key)}
% This key sets the |/E| key, the expanded form of an
% abbreviation or an acronym
% (I couldn't think of a better name, so I sticked to E).
% \end{function}
-% \begin{function}{AF,AFinline,AFinline-o}
+% \begin{function}{AF (struct-key),AFinline (struct-key),AFinline-o (struct-key)}
% \begin{syntax}
% AF = \meta{object name}\\
-% AF-inline = \meta{text content}
+% AF-inline = \meta{text content}\\
% \end{syntax}
% These keys allows to reference an associated file in the structure element.
% The value \meta{object name} should be the name of an object pointing
@@ -165,9 +165,11 @@
% Future versions will perhaps extend this to more mime types, but it is
% still a research task to find out what is really needed.
%
+% |AF| can be used more than once, to associate more than one file. The inline
+% keys can be used only once per structure. Additional calls are ignored.
% \end{function}
%
-% \begin{function}{attribute}
+% \begin{function}{attribute (struct-key)}
% This key takes as argument a comma list of attribute names
% (use braces to protect the commas from the external key-val parser)
% and allows to add one or more attribute dictionary entries in
@@ -179,7 +181,7 @@
%
% \end{function}
%
-% \begin{function}{attribute-class}
+% \begin{function}{attribute-class (struct-key)}
% This key takes as argument a comma list of attribute class names
% (use braces to protect the commas from the external key-val parser)
% and allows to add one or more attribute classes to the structure object.
@@ -188,7 +190,7 @@
% must be declared first in \cs{tagpdfsetup}.
% \end{function}
% \subsection{Setup keys}
-% \begin{function}{newattribute}
+% \begin{function}{newattribute (setup-key)}
% \begin{syntax}
% newattribute = \Arg{name}\Arg{Content}
% \end{syntax}
@@ -206,12 +208,20 @@
% \end{verbatim}
%
% \end{function}
+% \begin{function}{root-AF (setup-key)}
+% \begin{syntax}
+% root-AF = \meta{object name}
+% \end{syntax}
+% This key can be used in the setup command \cs{tagpdfsetup} and allows
+% to add associated files to the root structure. Like |AF| it can be used more than
+% once to add more than one file.
+% \end{function}
% \end{documentation}
% \begin{implementation}
% \begin{macrocode}
%<@@=tag>
%<*header>
-\ProvidesExplPackage {tagpdf-struct-code} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-struct-code} {2022-01-13} {0.93}
{part of tagpdf - code related to storing structure}
%</header>
% \end{macrocode}
@@ -313,7 +323,8 @@
ParentTreeNextKey, % optional
RoleMap,
ClassMap,
- Namespaces
+ Namespaces,
+ AF %pdf 2.0
}
\seq_const_from_clist:Nn \c_@@_struct_StructElem_entries_seq
@@ -742,11 +753,16 @@
% at the begin.
% \begin{macro}
% {
-% label,stash,tag,
-% title,title-o,
-% alttext,
-% actualtext,
-% lang,ref,E
+% label (struct-key),
+% stash (struct-key),
+% tag (struct-key),
+% title (struct-key),
+% title-o (struct-key),
+% alttext (struct-key),
+% actualtext (struct-key),
+% lang (struct-key),
+% ref (struct-key),
+% E (struct-key)
% }
% \begin{macrocode}
\keys_define:nn { @@ / struct }
@@ -854,22 +870,51 @@
}
% \end{macrocode}
% \end{macro}
-% \begin{macro}{AF,AFinline,AFinline-o}
+% \begin{macro}{AF (struct-key),AFinline (struct-key),AFinline-o (struct-key)}
% keys for the AF keys (associated files). They use commands from l3pdffile!
% The stream variants use txt as extension to get the mimetype.
% TODO: check if this should be configurable. For math we will perhaps need another
% extension.
+% AF is an array and can be used more than once, so we store it in a tl.
+% which is expanded.
+% AFinline can be use only once (more quite probably doesn't make sense).
% \begin{macrocode}
+\cs_new_protected:Npn \@@_struct_add_AF:nn #1 #2 % #1 struct num #2 object name
+ {
+ \tl_if_exist:cTF
+ {
+ g_@@_struct_#1_AF_tl
+ }
+ {
+ \tl_gput_right:cx
+ { g_@@_struct_#1_AF_tl }
+ { ~ \pdf_object_ref:n {#2} }
+ }
+ {
+ \tl_new:c
+ { g_@@_struct_#1_AF_tl }
+ \tl_gset:cx
+ { g_@@_struct_#1_AF_tl }
+ { \pdf_object_ref:n {#2} }
+ }
+ }
+\cs_generate_variant:Nn \@@_struct_add_AF:nn {en,ee}
\keys_define:nn { @@ / struct }
{
AF .code:n = % AF property
{
\pdf_object_if_exist:nTF {#1}
{
+ \@@_struct_add_AF:en { \int_eval:n {\c@g_@@_struct_abs_int} }{#1}
\@@_prop_gput:cnx
{ g_@@_struct_\int_eval:n {\c@g_@@_struct_abs_int}_prop }
{ AF }
- { \pdf_object_ref:n {#1} }
+ {
+ [
+ \tl_use:c
+ { g_@@_struct_\int_eval:n {\c@g_@@_struct_abs_int}_AF_tl }
+ ]
+ }
}
{
@@ -879,16 +924,24 @@
{
\group_begin:
\pdf_object_if_exist:eF {@@/fileobj\int_use:N\c@g_@@_struct_abs_int}
- {
- \pdffile_embed_stream:nxx
- {#1}
- {tag-AFfile\int_use:N\c@g_@@_struct_abs_int.txt}
- {@@/fileobj\int_use:N\c@g_@@_struct_abs_int}
- }
- \@@_prop_gput:cnx
- { g_@@_struct_\int_use:N\c@g_@@_struct_abs_int _prop }
- { AF }
- { \pdf_object_ref:e {@@/fileobj\int_use:N\c@g_@@_struct_abs_int } }
+ {
+ \pdffile_embed_stream:nxx
+ {#1}
+ {tag-AFfile\int_use:N\c@g_@@_struct_abs_int.txt}
+ {@@/fileobj\int_use:N\c@g_@@_struct_abs_int}
+ \@@_struct_add_AF:ee
+ { \int_eval:n {\c@g_@@_struct_abs_int} }
+ { @@/fileobj\int_use:N\c@g_@@_struct_abs_int }
+ \@@_prop_gput:cnx
+ { g_@@_struct_\int_use:N\c@g_@@_struct_abs_int _prop }
+ { AF }
+ {
+ [
+ \tl_use:c
+ { g_@@_struct_\int_eval:n {\c@g_@@_struct_abs_int}_AF_tl }
+ ]
+ }
+ }
\group_end:
}
,AFinline-o .code:n =
@@ -900,24 +953,63 @@
{#1}
{tag-AFfile\int_use:N\c@g_@@_struct_abs_int.txt}
{@@/fileobj\int_use:N\c@g_@@_struct_abs_int}
+ \@@_struct_add_AF:ee
+ { \int_eval:n {\c@g_@@_struct_abs_int} }
+ { @@/fileobj\int_use:N\c@g_@@_struct_abs_int }
+ \@@_prop_gput:cnx
+ { g_@@_struct_\int_use:N\c@g_@@_struct_abs_int _prop }
+ { AF }
+ {
+ [
+ \tl_use:c
+ { g_@@_struct_\int_eval:n {\c@g_@@_struct_abs_int}_AF_tl }
+ ]
+ }
}
- \@@_prop_gput:cnx
- { g_@@_struct_\int_use:N\c@g_@@_struct_abs_int _prop }
- { AF }
- { \pdf_object_ref:e {@@/fileobj\int_use:N\c@g_@@_struct_abs_int } }
\group_end:
}
}
+%</package>
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{root-AF (setup-key)}
+% The root structure can take AF keys too, so we provide a key for it.
+% This key is used with |\tagpdfsetup|, not in a structure!
+% \begin{macrocode}
+\keys_define:nn { @@ / setup }
+ {
+ root-AF .code:n =
+ {
+ \pdf_object_if_exist:nTF {#1}
+ {
+ \@@_struct_add_AF:en { 0 }{#1}
+ \@@_prop_gput:cnx
+ { g_@@_struct_0_prop }
+ { AF }
+ {
+ [
+ \tl_use:c
+ { g_@@_struct_0_AF_tl }
+ ]
+ }
+ }
+ {
+
+ }
+ },
+ }
% \end{macrocode}
% \end{macro}
-%
% \section{User commands}
%
% \begin{macro}{\tag_struct_begin:n,\tag_struct_end:}
% \begin{macrocode}
-\cs_new_protected:Npn \tag_struct_begin:n #1 %#1 key-val
+%<*package|debug>
+%<package>\cs_new_protected:Npn \tag_struct_begin:n #1 %#1 key-val
+%<debug>\cs_set_protected:Npn \tag_struct_begin:n #1 %#1 key-val
{
- \@@_check_if_active_struct:T
+%<package>\@@_check_if_active_struct:T
+%<debug>\@@_check_if_active_struct:TF
{
\group_begin:
\int_gincr:N \c@g_@@_struct_abs_int
@@ -970,16 +1062,18 @@
}
%\prop_show:c { g_@@_struct_\g_@@_struct_stack_current_tl _prop }
%\seq_show:c {g_@@_struct_kids_\l_@@_struct_stack_parent_tmpa_tl _seq}
+%<debug> \@@_debug_struct_begin_insert:n { #1 }
\group_end:
}
+%<debug>{ \@@_debug_struct_begin_ignore:n { #1 }}
}
-
-
-\cs_new_protected:Nn \tag_struct_end:
+%<package>\cs_new_protected:Nn \tag_struct_end:
+%<debug>\cs_set_protected:Nn \tag_struct_end:
{ %take the current structure num from the stack:
%the objects are written later, lua mode hasn't all needed info yet
%\seq_show:N \g_@@_struct_stack_seq
- \@@_check_if_active_struct:T
+%<package>\@@_check_if_active_struct:T
+%<debug>\@@_check_if_active_struct:TF
{
\seq_gpop:NN \g_@@_struct_tag_stack_seq \l_@@_tmpa_tl
\seq_gpop:NNTF \g_@@_struct_stack_seq \l_@@_tmpa_tl
@@ -999,14 +1093,18 @@
{
\tl_gset:NV \g_@@_struct_tag_tl \l_@@_tmpa_tl
}
+%<debug>\@@_debug_struct_end_insert:
}
+%<debug>{\@@_debug_struct_end_ignore:}
}
+%</package|debug>
% \end{macrocode}
% \end{macro}
% \begin{macro}{\tag_struct_use:n}
% This command allows to use a stashed structure in another place.
% TODO: decide how it should be guarded. Probably by the struct-check.
% \begin{macrocode}
+%<*package>
\cs_new_protected:Nn \tag_struct_use:n %#1 is the label
{
\@@_check_if_active_struct:T
@@ -1073,7 +1171,7 @@
% \section{Attributes and attribute classes}
% \begin{macrocode}
%<*header>
-\ProvidesExplPackage {tagpdf-attr-code} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf-attr-code} {2022-01-13} {0.93}
{part of tagpdf - code related to attributes and attribute classes}
%</header>
% \end{macrocode}
@@ -1101,7 +1199,7 @@
% \end{macrocode}
% \end{variable}
% \subsection{Commands and keys}
-% \begin{macro}{\@@_attr_new_entry:nn,newattribute}
+% \begin{macro}{\@@_attr_new_entry:nn,newattribute (setup-key)}
% This allows to define attributes. Defined attributes
% are stored in a global property. |newattribute| expects
% two brace group, the name and the content. The content typically
@@ -1132,7 +1230,7 @@
}
% \end{macrocode}
% \end{macro}
-% \begin{macro}{attribute-class}
+% \begin{macro}{attribute-class (struct-key)}
% attribute-class has to store the used attribute names so that
% they can be added to the ClassMap later.
% \begin{macrocode}
@@ -1172,7 +1270,7 @@
}
% \end{macrocode}
% \end{macro}
-% \begin{macro}{attribute}
+% \begin{macro}{attribute (struct-key)}
% \begin{macrocode}
\keys_define:nn { @@ / struct }
{