diff options
author | Norbert Preining <norbert@preining.info> | 2021-05-16 03:00:44 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-05-16 03:00:44 +0000 |
commit | 2fc2609488764102ce43194e9288b7bd8e25f17f (patch) | |
tree | 9cf16b567d06c110c71e2c121c7cf5c16a086f02 /macros/latex/contrib/tagpdf/tagpdf-struct.dtx | |
parent | ff5439d00ba53d3e4b82d79f78ce65524f3684fd (diff) |
CTAN sync 202105160300
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdf-struct.dtx')
-rw-r--r-- | macros/latex/contrib/tagpdf/tagpdf-struct.dtx | 120 |
1 files changed, 77 insertions, 43 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdf-struct.dtx b/macros/latex/contrib/tagpdf/tagpdf-struct.dtx index 09ea351188..9e66d4913d 100644 --- a/macros/latex/contrib/tagpdf/tagpdf-struct.dtx +++ b/macros/latex/contrib/tagpdf/tagpdf-struct.dtx @@ -27,30 +27,37 @@ % \begin{macrocode} %<@@=tag> %<*struct> -\ProvidesExplPackage {tagpdf-struct-code} {2021/02/23} {0.80} +\ProvidesExplPackage {tagpdf-struct-code} {2021/05/14} {0.81} {part of tagpdf - code related to storing structure} - +% \end{macrocode} % I will use a latex counter for the structure count % to have a chance to avoid double structures in align etc - +% \begin{macrocode} \newcounter { g_@@_struct_abs_int } \int_gzero:N \c@g_@@_struct_abs_int - -% ref code is in tagpdf.dtx - -% a sequence stores structnum -> the obj numbers +% \end{macrocode} +% a sequence to store structnum -> the obj numbers % to allow easy mapping over the structures - +% \begin{macrocode} \@@_seq_new:N \g_@@_struct_objR_seq - -% a sequence for the structure stack. When a sequence is opened it's number is put on the stack. +% \end{macrocode} +% a sequence for the structure stack. +% When a sequence is opened it's number is put on the stack. +% \begin{macrocode} \seq_new:N \g_@@_struct_stack_seq \seq_gpush:Nn \g_@@_struct_stack_seq {0} - -%this variables will hold the top entry and the parent on the stack +% \end{macrocode} +% We will perhaps also need the tags. While it is possible to get them from the +% numbered stack, lets build a tag stack too. +% \begin{macrocode} +\seq_new:N \g_@@_struct_tag_stack_seq +\seq_gpush:Nn \g_@@_struct_tag_stack_seq {Root} +% \end{macrocode} +%this variables will hold the number of top entry and the parent on the stack +% \begin{macrocode} \tl_new:N \l_@@_struct_stack_parent_tmp_tl \tl_new:N \g_@@_struct_stack_current_tl - +% \end{macrocode} % I need at least one structure: the StructTreeRoot % normally it should have only one kid, e.g. the document element. @@ -65,8 +72,7 @@ % (the root has a special set of properties). % the values of the prop should be already escaped properly % when the entries are created (title,lange,alt,E,actualtext) - - +% \begin{macrocode} \seq_const_from_clist:Nn \c_@@_struct_StructTreeRoot_entries_seq {%p. 857/858 Type, % always /StructTreeRoot @@ -75,7 +81,8 @@ ParentTree, % required,obj ref to the parent tree ParentTreeNextKey, %optional RoleMap, - ClassMap + ClassMap, + Namespaces } \seq_const_from_clist:Nn \c_@@_struct_StructElem_entries_seq @@ -131,19 +138,13 @@ \@@_seq_new:c { g_@@_struct_kids_0_seq } -% deprecated -%\@@_prop_gput:cno -% { g_@@_struct_0_prop } -% { objnum} -% { \c_@@_tree_obj_structtreeroot_tl } - % new -\@@_prop_gput:cno +\@@_prop_gput:cnx { g_@@_struct_0_prop } { objref} - { \pdf_object_ref:n { c_@@_struct_0_obj } } + { \pdf_object_ref:n { @@/struct/0 } } -\@@_prop_gput:cno +\@@_prop_gput:cnn { g_@@_struct_0_prop } { Type } { /StructTreeRoot } @@ -152,23 +153,30 @@ \@@_prop_gput:cnx { g_@@_struct_0_prop } { ParentTree } - { \pdf_object_ref:n { c_@@_tree_parenttree_obj } } + { \pdf_object_ref:n { @@/tree/parenttree } } \@@_prop_gput:cnx { g_@@_struct_0_prop } { RoleMap } - { \pdf_object_ref:n { c_@@_tree_rolemap_obj } } + { \pdf_object_ref:n { @@/tree/rolemap } } -\@@_prop_gput:cno +\@@_prop_gput:cnn { g_@@_struct_0_prop } { entries } { StructTreeRoot } -\@@_prop_gput:cno +\@@_prop_gput:cnn { g_@@_struct_0_prop } { num } { 0 } +%Namespaces are pdf 2.0 but it doesn't harm to have an empty entry +\@@_prop_gput:cnx + { g_@@_struct_0_prop } + { Namespaces } + { \pdf_object_ref:n { @@/tree/namespaces } } + + % commands to store the kids % I don't compare the page objects number yet, but always add the /Pg key, perhaps later @@ -316,7 +324,7 @@ \@@_struct_get_dict_content:n { #1 } \exp_args:Nx \pdf_object_write:nx - { c_@@_struct_#1_obj } + { @@/struct/#1 } { \l_@@_struct_dict_content_tl } @@ -326,23 +334,48 @@ } } +% this command allows to get the current structure tag. We will need to handle nesting +% P +\cs_new:Nn \@@_get_data_struct_tag: + { + \exp_args:Ne + \tl_tail:n + { + \prop_item:cn {g_@@_struct_\g__tag_struct_stack_current_tl _prop}{S} + } + } + % keys for the user commands % should I pass the values (e.g. the tag) through an escape command? +% we store the tag in a variable. But we should be careful, it is only reliable +% at the begin +\tl_new:N \g_@@_struct_tag_tl +\tl_new:N \g_@@_struct_tag_NS_tl +\cs_generate_variant:Nn \seq_set_split:Nnn{Nne} \keys_define:nn { @@ / struct } { label .tl_set:N = \l_@@_struct_key_label_tl, stash .bool_set:N = \l_@@_struct_elem_stash_bool, tag .code:n = % S property - {%%????????? \pdfescapename?? - \tl_set:Nx \l_@@_tmpa_tl { #1 } + {%%????????? \pdfescapename?? slash/not slash is here the question ... + \seq_set_split:Nne \l_tmpa_seq { / } {#1/\prop_item:Nn\g__tag_role_tags_NS_prop{#1}} + \tl_gset:Nx \g_@@_struct_tag_tl { \seq_item:Nn\l_tmpa_seq {1} } + \tl_gset:Nx \g_@@_struct_tag_NS_tl { \seq_item:Nn\l_tmpa_seq {2} } \bool_if:NT \g_@@_check_tags_bool { - \@@_check_structure_tag:N \l_@@_tmpa_tl + \@@_check_structure_tag:N \g_@@_struct_tag_tl } \@@_prop_gput:cnx { g_@@_struct_\int_eval:n {\c@g_@@_struct_abs_int}_prop } { S } - { /\exp_not:V\l_@@_tmpa_tl } + { \pdf_name_from_unicode_e:n{ \g_@@_struct_tag_tl} } % + \prop_get:NVNT \g_@@_role_NS_prop\g_@@_struct_tag_NS_tl\l_@@_tmpa_tl + { + \@@_prop_gput:cnx + { g_@@_struct_\int_eval:n {\c@g_@@_struct_abs_int}_prop } + { NS } + { \l_@@_tmpa_tl } % + } }, title .code:n = % T property { @@ -513,7 +546,7 @@ %\@@_pdfreserveobjnum:N \l_tmpa_tl \exp_args:Ne \pdf_object_new:nn - { c_@@_struct_\int_eval:n { \c@g_@@_struct_abs_int }_obj } + { @@/struct/\int_eval:n { \c@g_@@_struct_abs_int } } { dict } \@@_prop_gput:cnx { g_@@_struct_\int_eval:n { \c@g_@@_struct_abs_int }_prop } @@ -521,7 +554,7 @@ { \exp_args:Ne \pdf_object_ref:n - {c_@@_struct_\int_eval:n { \c@g_@@_struct_abs_int }_obj} + {@@/struct/\int_eval:n { \c@g_@@_struct_abs_int }} } % \prop_show:c { g_@@_struct_\int_eval:n { \c@g_@@_struct_abs_int }_prop } \@@_prop_gput:cnx @@ -551,6 +584,7 @@ \msg_error:nn { tag } { struct-faulty-nesting } } \seq_gpush:NV \g_@@_struct_stack_seq \c@g_@@_struct_abs_int + \seq_gpush:NV \g_@@_struct_tag_stack_seq \g_@@_struct_tag_tl \tl_gset:NV \g_@@_struct_stack_current_tl \c@g_@@_struct_abs_int %\seq_show:N \g_@@_struct_stack_seq \bool_if:NF @@ -578,13 +612,12 @@ \group_end: } -%deprecated -\cs_set_eq:NN \uftag_struct_begin:n \tag_struct_begin:n \cs_new_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 + \seq_gpop:NN \g_@@_struct_tag_stack_seq \l_tmpa_tl \seq_gpop:NNTF \g_@@_struct_stack_seq \l_tmpa_tl { \int_compare:nNnT {\l_@@_loglevel_int} > { 0 } @@ -601,10 +634,13 @@ { \@@_check_no_open_struck: } + \seq_get:NNT \g_@@_struct_tag_stack_seq \l_tmpa_tl + { + \tl_gset:NV \g_@@_struct_tag_tl \l_tmpa_tl + } } -%deprecated -\cs_set_eq:NN \uftag_struct_end: \tag_struct_end: + \cs_new_protected:Nn \tag_struct_use:n %#1 is the label { @@ -631,8 +667,6 @@ } } -\cs_set_eq:NN \uftag_struct_use:n \tag_struct_use:n - %%%% Code to tag links %%%% this works for url, see exp-link.pdf. @@ -677,7 +711,7 @@ % \end{macrocode} % \begin{macrocode} %<*attr> -\ProvidesExplPackage {tagpdf-attr-code} {2021/02/23} {0.80} +\ProvidesExplPackage {tagpdf-attr-code} {2021/05/14} {0.81} {part of tagpdf - code related to attributes and attribute classes} % the obj is written in tagpdf-tree-code. |