diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty | 388 |
1 files changed, 242 insertions, 146 deletions
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty index d021f6d303c..2f85934f312 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty @@ -28,8 +28,8 @@ %% and all files in that bundle must be distributed together. %% %% File: tagpdf.dtx -\ProvidesExplPackage {tagpdf} {2024-04-12} {0.99b} - { A package to experiment with pdf tagging } +\ProvidesExplPackage {tagpdf} {2024-09-16} {0.99f} + { LaTeX kernel code for PDF tagging } \bool_if:nF { @@ -65,30 +65,23 @@ \ExecuteOptions{luamode} \ProcessOptions \RequirePackage{tagpdf-base} -\cs_if_free:NT \pdf_object_new_indexed:nn - { - \cs_generate_variant:Nn \pdf_object_new:n {e} - \cs_generate_variant:Nn \pdf_object_write:nnn {enn} - \cs_new_protected:Npn \pdf_object_new_indexed:nn #1 #2 - { - \pdf_object_new:e {#1/\int_eval:n{#2}} - } - \cs_new_protected:Npn \pdf_object_write_indexed:nnnn #1 #2 #3 #4 - { - \pdf_object_write:enn {#1/\int_eval:n{#2}}{#3}{#4} - } - \cs_generate_variant:Nn \pdf_object_write_indexed:nnnn {nnne} - \cs_new:Npn\pdf_object_ref_indexed:nn #1 #2 - { - \pdf_object_ref:e {#1/\int_eval:n{#2}} - } - \cs_new:Npn \__kernel_pdf_object_id_indexed:nn #1 #2 - { - \int_use:c - { c__pdf_object_ #1/\int_eval:n{#2} _int } - } - } - +\AddToHook{package/latex-lab-testphase-new-or-2/after} + { + \cs_set_protected:Npn \__fnote_gput_ref:nn #1 #2 %#1 the structure number receiving the ref #2 + { + \tag_struct_gput:nnn {#1}{ref_num}{#2} + } + } +\AddToHook{package/latex-lab-testphase-toc/after} + { + \cs_set_protected:Npn \g__tag_struct_ref_by_dest: + { + \prop_map_inline:Nn\g__tag_struct_ref_by_dest_prop + { + \tag_struct_gput:nnn {##1}{ref_dest}{##2} + } + } + } \cs_new_protected:Npn \__tag_lastpagelabel: { \legacy_if:nT { @filesw } @@ -110,6 +103,7 @@ {\__tag_lastpagelabel:} \tl_new:N \l__tag_tmpa_tl \tl_new:N \l__tag_tmpb_tl +\tl_new:N \l__tag_Ref_tmpa_tl \tl_new:N \l__tag_get_tmpc_tl \tl_new:N \l__tag_get_parent_tmpa_tl \tl_new:N \l__tag_get_parent_tmpb_tl @@ -137,6 +131,7 @@ \bool_set_true:N \l__tag_active_struct_bool \bool_new:N \l__tag_active_socket_bool \bool_new:N \g__tag_tagunmarked_bool +\bool_new:N \g__tag_softhyphen_bool \prg_generate_conditional_variant:Nnn \pdf_object_if_exist:n {e}{T,F,TF} \cs_generate_variant:Nn \pdf_object_ref:n {e} \cs_generate_variant:Nn \pdfannot_dict_put:nnn {nne} @@ -147,10 +142,6 @@ \cs_generate_variant:Nn \seq_set_split:Nnn{Nne} %** unneeded \cs_generate_variant:Nn \str_set_convert:Nnnn {Nonn, Noon, Nnon } \cs_generate_variant:Nn \clist_map_inline:nn {on} - \cs_new_eq:NN \__tag_property_new:nnnn \property_new:nnnn - \cs_new_eq:NN \__tag_property_gset:nnnn \property_gset:nnnn - \cs_new_eq:NN \__tag_property_ref:nnn \property_ref:nnn - \cs_new_eq:NN \__tag_property_ref:nn \property_ref:nn \cs_new_protected:Npn \__tag_property_record:nn #1#2 { \@bsphack @@ -158,29 +149,29 @@ \@esphack } -\cs_generate_variant:Nn \__tag_property_ref:nnn {enn} -\cs_generate_variant:Nn \__tag_property_ref:nn {en} +\cs_generate_variant:Nn \property_ref:nnn {enn} +\cs_generate_variant:Nn \property_ref:nn {en} \cs_generate_variant:Nn \__tag_property_record:nn {en,eV} \cs_new:Npn \__tag_property_ref_lastpage:nn #1 #2 { - \__tag_property_ref:nnn {@tag@LastPage}{#1}{#2} + \property_ref:nnn {@tag@LastPage}{#1}{#2} } -\__tag_property_new:nnnn +\property_new:nnnn { tagstruct } { now } - {0} { \int_use:N \c@g__tag_struct_abs_int } -\__tag_property_new:nnnn { tagstructobj } { now } {} + {1} { \int_use:N \c@g__tag_struct_abs_int } +\property_new:nnnn { tagstructobj } { now } {} { \pdf_object_ref_indexed:nn { __tag/struct } { \c@g__tag_struct_abs_int } } -\__tag_property_new:nnnn +\property_new:nnnn { tagabspage } { shipout } {0} { \int_use:N \g_shipout_readonly_int } -\__tag_property_new:nnnn { tagmcabs } { now } +\property_new:nnnn { tagmcabs } { now } {0} { \int_use:N \c@g__tag_MCID_abs_int } \flag_new:n { __tag/mcid } -\__tag_property_new:nnnn {tagmcid } { shipout } +\property_new:nnnn {tagmcid } { shipout } {0} { \flag_height:n { __tag/mcid } } @@ -189,12 +180,14 @@ \cs_set_eq:NN \__tag_seq_new:N \seq_new:N \cs_set_eq:NN \__tag_prop_gput:Nnn \prop_gput:Nnn \cs_set_eq:NN \__tag_seq_gput_right:Nn \seq_gput_right:Nn +\cs_set_eq:NN \__tag_seq_gput_left:Nn \seq_gput_left:Nn \cs_set_eq:NN \__tag_seq_item:cn \seq_item:cn \cs_set_eq:NN \__tag_prop_item:cn \prop_item:cn \cs_set_eq:NN \__tag_seq_show:N \seq_show:N \cs_set_eq:NN \__tag_prop_show:N \prop_show:N \cs_generate_variant:Nn \__tag_prop_gput:Nnn { Nen , Nee, Nne , cnn, cen, cne, cno, cnx} \cs_generate_variant:Nn \__tag_seq_gput_right:Nn { Ne , No, cn, ce } +\cs_generate_variant:Nn \__tag_seq_gput_left:Nn { ce } \cs_generate_variant:Nn \__tag_prop_new:N { c } \cs_generate_variant:Nn \__tag_seq_new:N { c } \cs_generate_variant:Nn \__tag_seq_show:N { c } @@ -221,7 +214,7 @@ } \cs_set_eq:NN\tagstop\tag_stop: \cs_set_eq:NN\tagstart\tag_start: -\cs_set_protected:Npn \tag_stop:n #1 +\cs_set_protected:Npn \tag_suspend:n #1 { \int_incr:N \l__tag_tag_stop_int \bool_set_false:N \l__tag_active_struct_bool @@ -229,7 +222,8 @@ \bool_set_false:N \l__tag_active_socket_bool \__tag_stop_para_ints: } -\cs_set_protected:Npn \tag_start:n #1 +\cs_set_eq:NN \tag_stop:n \tag_suspend:n +\cs_set_protected:Npn \tag_resume:n #1 { \int_if_zero:nF { \l__tag_tag_stop_int } { \int_decr:N \l__tag_tag_stop_int } \int_if_zero:nT { \l__tag_tag_stop_int } @@ -240,6 +234,7 @@ \__tag_start_para_ints: } } +\cs_set_eq:NN \tag_start:n \tag_resume:n \keys_define:nn { __tag / setup } { activate/mc .bool_gset:N = \g__tag_active_mc_bool, @@ -273,6 +268,8 @@ activate/tagunmarked .bool_gset:N = \g__tag_tagunmarked_bool, activate/tagunmarked .initial:n = true, tagunmarked .bool_gset:N = \g__tag_tagunmarked_bool, + activate/softhyphen .bool_gset:N = \g__tag_softhyphen_bool, + activate/softhyphen .initial:n = true, page/tabsorder .choice:, page/tabsorder / row .code:n = \pdfmanagement_add:nnn { Page } {Tabs}{/R}, @@ -326,6 +323,11 @@ { structure~with~label~#1~is~unknown~rerun} \msg_new:nnn { tag } {struct-show-closing} { closing~structure~#1~tagged~\use:e{\prop_item:cn{g__tag_struct_#1_prop}{S}} } +\msg_new:nnn { tag } {struct-Ref-unknown} + { + #1~has~no~related~structure.\\ + /Ref~not~updated. + } \msg_new:nnn { tag } {tree-struct-still-open} { There~are~still~open~structures~on~the~stack!\\ @@ -432,7 +434,7 @@ \cs_new_protected:Npn \__tag_check_struct_used:n #1 %#1 label { \prop_get:cnNT - {g__tag_struct_\__tag_property_ref:enn{tagpdfstruct-#1}{tagstruct}{unknown}_prop} + {g__tag_struct_\property_ref:enn{tagpdfstruct-#1}{tagstruct}{unknown}_prop} {P} \l__tag_tmpa_tl { @@ -565,7 +567,7 @@ { \int_compare:nT { - \__tag_property_ref:enn + \property_ref:enn {mcid-####1} {tagabspage} {-1} @@ -576,7 +578,7 @@ \seq_gput_right:Ne \l_tmpa_seq { Page##1-####1- - \__tag_property_ref:enn + \property_ref:enn {mcid-####1} {tagmcid} {-1} @@ -646,7 +648,7 @@ { \__tag_check_if_active_struct:T { - \tl_set:Ne \l__tag_tmpa_tl { \__tag_property_ref:nnn{tagpdf-#1}{tagmcabs}{} } + \tl_set:Ne \l__tag_tmpa_tl { \property_ref:nnn{tagpdf-#1}{tagmcabs}{} } \tl_if_empty:NTF\l__tag_tmpa_tl { \msg_warning:nnn {tag} {mc-label-unknown} {#1} @@ -668,12 +670,12 @@ \tag_mc_end_push: \tag_mc_begin:n {artifact=#1} \group_begin: - \tag_stop:n{artifact-group} + \tag_suspend:n{artifact-group} } \cs_set_protected:Npn \tag_mc_artifact_group_end: { - \tag_start:n{artifact-group} + \tag_resume:n{artifact-group} \group_end: \tag_mc_end: \tag_mc_begin_pop:n{} @@ -756,30 +758,6 @@ }, } %% File: tagpdf.dtx -\cs_if_free:NT \pdf_object_new_indexed:nn - { - \cs_generate_variant:Nn \pdf_object_new:n {e} - \cs_generate_variant:Nn \pdf_object_write:nnn {enn} - \cs_new_protected:Npn \pdf_object_new_indexed:nn #1 #2 - { - \pdf_object_new:e {#1/\int_eval:n{#2}} - } - \cs_new_protected:Npn \pdf_object_write_indexed:nnnn #1 #2 #3 #4 - { - \pdf_object_write:enn {#1/\int_eval:n{#2}}{#3}{#4} - } - \cs_generate_variant:Nn \pdf_object_write_indexed:nnnn {nnne} - \cs_new:Npn\pdf_object_ref_indexed:nn #1 #2 - { - \pdf_object_ref:e {#1/\int_eval:n{#2}} - } - \cs_new:Npn \__kernel_pdf_object_id_indexed:nn #1 #2 - { - \int_use:c - { c__pdf_object_ #1/\int_eval:n{#2} _int } - } - } - \bool_if:NTF \g__tag_mode_lua_bool { \RequirePackage {tagpdf-mc-code-lua} @@ -925,6 +903,7 @@ { \l__tag_tmpa_tl } + \prop_gput:cnn { g__tag_struct_1_prop } {S}{ /StructTreeRoot } } \cs_new_protected:Npn \__tag_tree_write_structelements: { @@ -960,11 +939,11 @@ { %mcid####1 \int_compare:nT - {\__tag_property_ref:enn{mcid-####1}{tagabspage}{-1}=##1} %mcid is on current page + {\property_ref:enn{mcid-####1}{tagabspage}{-1}=##1} %mcid is on current page {% yes \prop_put:Nee \l__tag_tmpa_prop - {\__tag_property_ref:enn{mcid-####1}{tagmcid}{-1}} + {\property_ref:enn{mcid-####1}{tagmcid}{-1}} {\prop_item:Nn \g__tag_mc_parenttree_prop {####1}} } } @@ -1547,19 +1526,31 @@ { \hook_gput_code:nnn {begindocument}{tagpdf} { - \cs_if_exist:NT \chapter - { - \prop_map_inline:cn{g__tag_role_NS_latex-book_prop} - { - \__tag_role_add_tag:ne {#1}{\use_i:nn #2\c_empty_tl\c_empty_tl} - } - } + \bool_lazy_and:nnT + { + \cs_if_exist_p:N \chapter + } + { + \cs_if_exist_p:N \c@chapter + } + { + \prop_map_inline:cn{g__tag_role_NS_latex-book_prop} + { + \__tag_role_add_tag:ne {#1}{\use_i:nn #2\c_empty_tl\c_empty_tl} + } + } } } { \hook_gput_code:nnn {begindocument}{tagpdf} { - \cs_if_exist:NT \chapter + \bool_lazy_and:nnT + { + \cs_if_exist_p:N \chapter + } + { + \cs_if_exist_p:N \c@chapter + } { \prop_map_inline:cn{g__tag_role_NS_latex-book_prop} { @@ -1972,7 +1963,7 @@ T, %title, value in () or <> Lang, %language Alt, % value in () or <> - E, % abreviation + E, % abbreviation ActualText, AF, %pdf 2.0, array of dict, associated files NS, %pdf 2.0, dict, namespace @@ -1983,8 +1974,12 @@ \tl_new:N \g__tag_struct_tag_NS_tl \tl_new:N \l__tag_struct_roletag_tl \tl_new:N \l__tag_struct_roletag_NS_tl -\tl_new:N \l__tag_struct_key_label_tl +\prop_new_linked:N \g__tag_struct_label_num_prop + \bool_new:N \l__tag_struct_elem_stash_bool +\tl_new:N \l__tag_struct_addkid_tl +\tl_set:Nn \l__tag_struct_addkid_tl {right} + \prop_new_linked:N \g__tag_struct_ref_by_dest_prop \cs_new:Npn \__tag_struct_output_prop_aux:nn #1 #2 %#1 num, #2 key { @@ -2008,7 +2003,7 @@ \__tag_prop_gput:cnn { g__tag_struct_#1_prop }{#2}{#3} } -\cs_generate_variant:Nn \__tag_struct_prop_gput:nnn {nne,nee,nno} +\cs_generate_variant:Nn \__tag_struct_prop_gput:nnn {onn,nne,nee,nno} \tl_gset:Nn \g__tag_struct_stack_current_tl {1} \cs_new:Npn \__tag_pdf_name_e:n #1{\pdf_name_from_unicode_e:n{#1}} @@ -2105,11 +2100,11 @@ /Type \c_space_tl /MCR \c_space_tl /Pg \c_space_tl - \pdf_pageobject_ref:n { \__tag_property_ref:enn{mcid-#1}{tagabspage}{1} } - /MCID \c_space_tl \__tag_property_ref:enn{mcid-#1}{tagmcid}{1} + \pdf_pageobject_ref:n { \property_ref:enn{mcid-#1}{tagabspage}{1} } + /MCID \c_space_tl \property_ref:enn{mcid-#1}{tagmcid}{1} >> } -\cs_new_protected:Npn \__tag_struct_kid_mc_gput_right:nn #1 #2 %#1 structure num, #2 MCID absnum% +\cs_new_protected:Npn \__tag_struct_kid_mc_gput_right:nn #1 #2 { \__tag_seq_gput_right:ce { g__tag_struct_kids_#1_seq } @@ -2123,7 +2118,8 @@ } } \cs_generate_variant:Nn \__tag_struct_kid_mc_gput_right:nn {ne} -\cs_new_protected:Npn\__tag_struct_kid_struct_gput_right:nn #1 #2 %#1 num of parent struct, #2 kid struct +\cs_new_protected:Npn\__tag_struct_kid_struct_gput_right:nn #1 #2 +%%#1 num of parent struct, #2 kid struct { \__tag_seq_gput_right:ce { g__tag_struct_kids_#1_seq } @@ -2131,11 +2127,21 @@ \pdf_object_ref_indexed:nn { __tag/struct }{ #2 } } } - \cs_generate_variant:Nn \__tag_struct_kid_struct_gput_right:nn {ee} -\cs_new_protected:Npn\__tag_struct_kid_OBJR_gput_right:nnn #1 #2 #3 %#1 num of parent struct, - %#2 obj reference - %#3 page object reference +\cs_new_protected:Npn\__tag_struct_kid_struct_gput_left:nn #1 #2 +%%#1 num of parent struct, #2 kid struct + { + \__tag_seq_gput_left:ce + { g__tag_struct_kids_#1_seq } + { + \pdf_object_ref_indexed:nn { __tag/struct }{ #2 } + } + } +\cs_generate_variant:Nn \__tag_struct_kid_struct_gput_left:nn {ee} +\cs_new_protected:Npn\__tag_struct_kid_OBJR_gput_right:nnn #1 #2 #3 + + +%%#1 num of parent struct,#2 obj reference,#3 page object reference { \pdf_object_unnamed_write:nn { dict } @@ -2239,30 +2245,43 @@ } } -\cs_new_protected:Npn \__tag_struct_get_dict_content:nN #1 #2 %#1: stucture num +\cs_new_protected:Npn \__tag_struct_get_dict_content:nN #1 #2 %#1: structure num { \tl_clear:N #2 \prop_map_inline:cn { g__tag_struct_#1_prop } { - \tl_put_right:Ne #2 + \cs_if_exist_use:cTF {__tag_struct_format_##1:nnN} + { + {##1}{##2}#2 + } { - \cs_if_exist_use:cTF {__tag_struct_format_##1:nn} - {{##1}{##2}} - {\c_space_tl/##1~##2} + \tl_put_right:Ne #2 { \c_space_tl/##1~##2 } } } } -\cs_new:Nn\__tag_struct_format_rolemap:nn{} -\cs_new:Nn\__tag_struct_format_parentrole:nn{} +\cs_new:Nn\__tag_struct_format_rolemap:nnN{} +\cs_new:Nn\__tag_struct_format_parentrole:nnN{} -\cs_new:Nn\__tag_struct_format_Ref:nn{\c_space_tl/#1~[#2]} +\cs_new_protected:Nn\__tag_struct_format_Ref:nnN + { + \tl_put_right:Nn #3 { ~/#1~[ } %] + \clist_map_inline:nn{ #2 } + { + ##1 #3 + } + \tl_put_right:Nn #3 + { %[ + \c_space_tl] + } + } \cs_new_protected:Npn \__tag_struct_write_obj:n #1 % #1 is the struct num { \prop_if_exist:cTF { g__tag_struct_#1_prop } { \prop_get:cnNF { g__tag_struct_#1_prop } {P}\l__tag_tmpb_tl { - \prop_gput:cne { g__tag_struct_#1_prop } {P}{\pdf_object_ref_indexed:nn { __tag/struct }{1}} + \prop_gput:cne { g__tag_struct_#1_prop } {P} + {\pdf_object_ref_indexed:nn { __tag/struct }{1}} \prop_gput:cne { g__tag_struct_#1_prop } {S}{/Artifact} \seq_if_empty:cF {g__tag_struct_kids_#1_seq} { @@ -2288,8 +2307,9 @@ \msg_error:nnn { tag } { struct-no-objnum } { #1} } } -\cs_new_protected:Npn \__tag_struct_insert_annot:nn #1 #2 %#1 object reference to the annotation/xform - %#2 structparent number +\cs_new_protected:Npn \__tag_struct_insert_annot:nn #1 #2 + %#1 object reference to the annotation/xform + %#2 structparent number { \bool_if:NT \g__tag_active_struct_bool { @@ -2311,7 +2331,8 @@ #1 % } { - \pdf_pageobject_ref:n { \__tag_property_ref:nnn {@tag@objr@page@#2 }{ tagabspage }{1} } + \pdf_pageobject_ref:n + { \property_ref:nnn {@tag@objr@page@#2 }{ tagabspage }{1} } } % add the parent obj number to the parent tree: \exp_args:Nne @@ -2320,7 +2341,8 @@ #2 } { - \pdf_object_ref_indexed:nn { __tag/struct }{ \l__tag_struct_stack_parent_tmpa_tl } + \pdf_object_ref_indexed:nn + { __tag/struct }{ \l__tag_struct_stack_parent_tmpa_tl } } % increase the int: \int_gincr:N \c@g__tag_parenttree_obj_int @@ -2341,7 +2363,8 @@ \socket_new:nn { tag/struct/tag }{1} \socket_new_plug:nnn { tag/struct/tag }{ latex-tags } { - \seq_set_split:Nne \l__tag_tmpa_seq { / } {#1/\prop_item:Ne\g__tag_role_tags_NS_prop{#1}} + \seq_set_split:Nne \l__tag_tmpa_seq { / } + {#1/\prop_item:Ne\g__tag_role_tags_NS_prop{#1}} \tl_gset:Ne \g__tag_struct_tag_tl { \seq_item:Nn\l__tag_tmpa_seq {1} } \tl_gset:Ne \g__tag_struct_tag_NS_tl{ \seq_item:Nn\l__tag_tmpa_seq {2} } \__tag_check_structure_tag:N \g__tag_struct_tag_tl @@ -2349,10 +2372,12 @@ \socket_new_plug:nnn { tag/struct/tag }{ pdf-tags } { - \seq_set_split:Nne \l__tag_tmpa_seq { / } {#1/\prop_item:Ne\g__tag_role_tags_NS_prop{#1}} + \seq_set_split:Nne \l__tag_tmpa_seq { / } + {#1/\prop_item:Ne\g__tag_role_tags_NS_prop{#1}} \tl_gset:Ne \g__tag_struct_tag_tl { \seq_item:Nn\l__tag_tmpa_seq {1} } \tl_gset:Ne \g__tag_struct_tag_NS_tl{ \seq_item:Nn\l__tag_tmpa_seq {2} } - \__tag_role_get:VVNN \g__tag_struct_tag_tl\g__tag_struct_tag_NS_tl\l__tag_tmpa_tl\l__tag_tmpb_tl + \__tag_role_get:VVNN + \g__tag_struct_tag_tl \g__tag_struct_tag_NS_tl \l__tag_tmpa_tl \l__tag_tmpb_tl \tl_gset:Ne \g__tag_struct_tag_tl {\l__tag_tmpa_tl} \tl_gset:Ne \g__tag_struct_tag_NS_tl{\l__tag_tmpb_tl} \__tag_check_structure_tag:N \g__tag_struct_tag_tl @@ -2361,7 +2386,14 @@ \keys_define:nn { __tag / struct } { - label .tl_set:N = \l__tag_struct_key_label_tl, + label .code:n = + { + \prop_gput:Nee\g__tag_struct_label_num_prop + {#1}{\int_use:N \c@g__tag_struct_abs_int} + \__tag_property_record:eV + {tagpdfstruct-#1} + \c__tag_property_struct_clist + }, stash .bool_set:N = \l__tag_struct_elem_stash_bool, parent .code:n = { @@ -2380,6 +2412,7 @@ } }, parent .default:n = {-1}, +firstkid .code:n = { \tl_set:Nn \l__tag_struct_addkid_tl {left} }, tag .code:n = % S property { \socket_use:nn { tag/struct/tag }{#1} @@ -2446,16 +2479,58 @@ { Lang } { (#1) } }, + } +\cs_new_protected:Npn \__tag_struct_Ref_obj:nN #1 #2 %#1 a object reference + { + \tl_put_right:Ne#2 + { + \c_space_tl#1 + } + } + +\cs_new_protected:Npn \__tag_struct_Ref_label:nN #1 #2 %#1 a label + { + \prop_get:NnNTF \g__tag_struct_label_num_prop {#1} \l__tag_tmpb_tl + { + \tl_put_right:Ne#2 + { + \c_space_tl\tag_struct_object_ref:e{ \l__tag_tmpb_tl } + } + } + { + \msg_warning:nnn {tag}{struct-Ref-unknown}{Label~'#1'} + } + } +\cs_new_protected:Npn \__tag_struct_Ref_dest:nN #1 #2 %#1 a dest name + { + \prop_get:NnNTF \g__tag_struct_dest_num_prop {#1} \l__tag_tmpb_tl + { + \tl_put_right:Ne#2 + { + \c_space_tl\tag_struct_object_ref:e{ \l__tag_tmpb_tl } + } + } + { + \msg_warning:nnn {tag}{struct-Ref-unknown}{Destination~'#1'} + } + } +\cs_new_protected:Npn \__tag_struct_Ref_num:nN #1 #2 %#1 a structure number + { + \tl_put_right:Ne#2 + { + \c_space_tl\tag_struct_object_ref:e{ #1 } + } + } + +\keys_define:nn { __tag / struct } + { ref .code:n = % ref property { - \tl_clear:N\l__tag_tmpa_tl \clist_map_inline:on {#1} { - \tl_put_right:Ne \l__tag_tmpa_tl - {~\__tag_property_ref:en{tagpdfstruct-##1}{tagstructobj} } + \tag_struct_gput:nne + {\int_use:N \c@g__tag_struct_abs_int}{ref_label}{ ##1 } } - \__tag_struct_gput_data_ref:ee - { \int_use:N \c@g__tag_struct_abs_int } {\l__tag_tmpa_tl} }, E .code:n = % E property { @@ -2499,7 +2574,7 @@ } \cs_generate_variant:Nn \__tag_struct_add_inline_AF:nn {on} -\cs_new_protected:Npn \__tag_struct_add_AF:nn #1 #2 % #1 struct num #2 object reference +\cs_new_protected:Npn \__tag_struct_add_AF:nn #1 #2 { \tl_if_exist:cTF { @@ -2525,7 +2600,8 @@ { \pdf_object_if_exist:eTF {#1} { - \__tag_struct_add_AF:ee { \int_use:N \c@g__tag_struct_abs_int }{\pdf_object_ref:e {#1}} + \__tag_struct_add_AF:ee + { \int_use:N \c@g__tag_struct_abs_int }{\pdf_object_ref:e {#1}} \__tag_struct_prop_gput:nne { \int_use:N \c@g__tag_struct_abs_int } { AF } @@ -2638,13 +2714,6 @@ \g__tag_struct_tag_tl \g__tag_struct_tag_NS_tl \__tag_check_structure_has_tag:n { \int_use:N \c@g__tag_struct_abs_int } - \tl_if_empty:NF - \l__tag_struct_key_label_tl - { - \__tag_property_record:eV - {tagpdfstruct-\l__tag_struct_key_label_tl} - \c__tag_property_struct_clist - } \int_compare:nNnT { \l__tag_struct_stack_parent_tmpa_tl } = { -1 } { \seq_get:NNF @@ -2717,6 +2786,7 @@ { g__tag_struct_ \l__tag_struct_stack_parent_tmpa_tl _prop} {S} \l__tag_tmpa_tl + \quark_if_no_value:NT\l__tag_tmpa_tl{\tl_set:Nn \l__tag_tmpa_tl{UNKNOWN}} \msg_warning:nneee { tag } {role-parent-child} @@ -2745,7 +2815,7 @@ %record this structure as kid: %\tl_show:N \g__tag_struct_stack_current_tl %\tl_show:N \l__tag_struct_stack_parent_tmpa_tl - \__tag_struct_kid_struct_gput_right:ee + \use:c { __tag_struct_kid_struct_gput_ \l__tag_struct_addkid_tl :ee } { \l__tag_struct_stack_parent_tmpa_tl } { \g__tag_struct_stack_current_tl } %\prop_show:c { g__tag_struct_\g__tag_struct_stack_current_tl _prop } @@ -2797,22 +2867,22 @@ \__tag_check_if_active_struct:T { \prop_if_exist:cTF - { g__tag_struct_\__tag_property_ref:enn{tagpdfstruct-#1}{tagstruct}{unknown}_prop } % + { g__tag_struct_\property_ref:enn{tagpdfstruct-#1}{tagstruct}{unknown}_prop } % { \__tag_check_struct_used:n {#1} %add the label structure as kid to the current structure (can be the root) \__tag_struct_kid_struct_gput_right:ee { \g__tag_struct_stack_current_tl } - { \__tag_property_ref:enn{tagpdfstruct-#1}{tagstruct}{1} } + { \property_ref:enn{tagpdfstruct-#1}{tagstruct}{1} } %add the current structure to the labeled one as parents \__tag_prop_gput:cne - { g__tag_struct_\__tag_property_ref:enn{tagpdfstruct-#1}{tagstruct}{1}_prop } + { g__tag_struct_\property_ref:enn{tagpdfstruct-#1}{tagstruct}{1}_prop } { P } { \pdf_object_ref_indexed:nn { __tag/struct } { \g__tag_struct_stack_current_tl } } \__tag_struct_get_parentrole:eNN - {\__tag_property_ref:enn{tagpdfstruct-#1}{tagstruct}{1}} + {\property_ref:enn{tagpdfstruct-#1}{tagstruct}{1}} \l__tag_tmpa_tl \l__tag_tmpb_tl \__tag_check_parent_child:VVVVN @@ -2897,7 +2967,7 @@ \pdf_object_ref_indexed:nn {__tag/struct}{ #1 } } \cs_generate_variant:Nn \tag_struct_object_ref:n {e} -\cs_new_protected:Npn \tag_struct_gput:nnn #1 #2 #3 +\cs_set_protected:Npn \tag_struct_gput:nnn #1 #2 #3 { \cs_if_exist_use:cF {__tag_struct_gput_data_#2:nn} { %warning?? @@ -2906,19 +2976,44 @@ {#1}{#3} } \cs_generate_variant:Nn \tag_struct_gput:nnn {ene,nne} -\cs_new_protected:Npn \__tag_struct_gput_data_ref:nn #1 #2 - % #1 receiving struct num, #2 list of object ref +\cs_new_protected:Npn \__tag_struct_gput_data_ref_aux:nnn #1 #2 #3 + % #1 receiving struct num, #2 key word #3 value { - \prop_get:cnN - { g__tag_struct_#1_prop } - {Ref} - \l__tag_get_tmpc_tl - \__tag_struct_prop_gput:nne - { #1 } - { Ref } - { \quark_if_no_value:NF\l__tag_get_tmpc_tl { \l__tag_get_tmpc_tl\c_space_tl }#2 } + \prop_get:cnNTF + { g__tag_struct_#1_prop } + {Ref} + \l__tag_get_tmpc_tl + { + \tl_put_right:No \l__tag_get_tmpc_tl + {\cs:w __tag_struct_Ref_#2:nN \cs_end: {#3},} + } + { + \tl_set:No \l__tag_get_tmpc_tl + {\cs:w __tag_struct_Ref_#2:nN \cs_end: {#3},} + } + \__tag_struct_prop_gput:nno + { #1 } + { Ref } + { \l__tag_get_tmpc_tl } } -\cs_generate_variant:Nn \__tag_struct_gput_data_ref:nn {ee} +\cs_new_protected:Npn \__tag_struct_gput_data_ref:nn #1 #2 + { + \__tag_struct_gput_data_ref_aux:nnn {#1}{obj}{#2} + } +\cs_new_protected:Npn \__tag_struct_gput_data_ref_label:nn #1 #2 + { + \__tag_struct_gput_data_ref_aux:nnn {#1}{label}{#2} + } +\cs_new_protected:Npn \__tag_struct_gput_data_ref_dest:nn #1 #2 + { + \__tag_struct_gput_data_ref_aux:nnn {#1}{dest}{#2} + } +\cs_new_protected:Npn \__tag_struct_gput_data_ref_num:nn #1 #2 + { + \__tag_struct_gput_data_ref_aux:nnn {#1}{num}{#2} + } + +\cs_generate_variant:Nn \__tag_struct_gput_data_ref:nn {ee,no} \cs_new_protected:Npn \tag_struct_insert_annot:nn #1 #2 %#1 should be an object reference %#2 struct parent num { @@ -3040,6 +3135,7 @@ }, } %% File: tagpdf-space.dtx +\bool_new:N\l__tag_showspaces_bool \keys_define:nn { __tag / setup } { activate/spaces .choice:, @@ -3446,9 +3542,9 @@ {\tagmcbegin{tag=Lbl}} {#1} } - \tag_stop:n{hangfrom} + \tag_suspend:n{hangfrom} \hangindent \wd\@tempboxa\noindent - \tag_start:n{hangfrom} + \tag_resume:n{hangfrom} \tagmcbegin{}\box\@tempboxa\tagmcend\tagstructend\tagmcbegin{} } } @@ -3699,11 +3795,11 @@ \bool_gset_false:N \g__tag_in_mc_bool } \tag_mc_begin:n {artifact} - \tag_stop:n{headfoot} + \tag_suspend:n{headfoot} } \cs_new_protected:Npn \__tag_exclude_headfoot_end: { - \tag_start:n{headfoot} + \tag_resume:n{headfoot} \tag_mc_end: \bool_if:NTF \g__tag_mode_lua_bool { @@ -3727,12 +3823,12 @@ } \tag_struct_begin:n{tag=Artifact,attribute-class=__tag/attr/#1} \tag_mc_begin:n {artifact=#1} - \tag_stop:n{headfoot} + \tag_suspend:n{headfoot} } \cs_new_protected:Npn \__tag_exclude_struct_headfoot_end: { - \tag_start:n{headfoot} + \tag_resume:n{headfoot} \tag_mc_end: \tag_struct_end: \bool_if:NTF \g__tag_mode_lua_bool |