From e83c955532d6bf7a44ee1702489dbf3cd74cf7c1 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 29 Aug 2021 20:26:17 +0000 Subject: tagpdf (29aug21) git-svn-id: svn://tug.org/texlive/trunk@60366 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def | 2 +- .../tex/latex/tagpdf/tagpdf-mc-code-generic.sty | 236 ++++++++++++++++-- .../tex/latex/tagpdf/tagpdf-mc-code-lua.sty | 37 +-- Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua | 4 +- Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty | 265 ++++++++++++++++++--- .../tex/latex/tagpdf/tagpdfdocu-patches.sty | 25 +- 6 files changed, 467 insertions(+), 102 deletions(-) (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def index 08f1bd92433..16d7b48e6cd 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def @@ -19,7 +19,7 @@ %% and all files in that bundle must be distributed together. %% %% File: tagpdf-backend.dtx -\ProvidesExplFile {tagpdf-luatex.def} {2021-07-03} {0.91} +\ProvidesExplFile {tagpdf-luatex.def} {2021-08-27} {0.92} {tagpdf~driver~for~luatex} { \fontencoding{TU}\fontfamily{lmr}\fontseries{m}\fontshape{n}\fontsize{10pt}{10pt}\selectfont diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty index 5b4426d8c48..ac7f56afc80 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty @@ -19,7 +19,7 @@ %% and all files in that bundle must be distributed together. %% %% File: tagpdf-mc.dtx -\ProvidesExplPackage {tagpdf-mc-code-generic} {2021-07-03} {0.91} +\ProvidesExplPackage {tagpdf-mc-code-generic} {2021-08-27} {0.92} {part of tagpdf - code related to marking chunks - generic mode} \__tag_prop_new:N \g__tag_MCID_byabspage_prop @@ -27,7 +27,214 @@ \tl_new:N \l__tag_mc_tmpa_tl +\newmarks \g__tag_mc_marks +\seq_new:N \g__tag_mc_main_marks_seq +\seq_new:N \g__tag_mc_footnote_marks_seq +\seq_new:N \g__tag_mc_multicol_marks_seq +\seq_new:N \l__tag_mc_firstmarks_seq +\seq_new:N \l__tag_mc_botmarks_seq +\cs_new_protected:Npn \__tag_mc_begin_marks:nn #1 #2 %#1 tag, #2 label + { + \tex_marks:D \g__tag_mc_marks + { + b-, %first of begin pair + \int_use:N\c@g__tag_MCID_abs_int, %mc-num + \g__tag_struct_stack_current_tl, %structure num + #1, %tag + \bool_if:NT \l__tag_mc_key_stash_bool{stash}, % stash info + #2, %label + } + \tex_marks:D \g__tag_mc_marks + { + b+, % second of begin pair + \int_use:N\c@g__tag_MCID_abs_int, %mc-num + \g__tag_struct_stack_current_tl, %structure num + #1, %tag + \bool_if:NT \l__tag_mc_key_stash_bool{stash}, % stash info + #2, %label + } + } +\cs_generate_variant:Nn \__tag_mc_begin_marks:nn {oo} +\cs_new_protected:Npn \__tag_mc_artifact_begin_marks:n #1 %#1 type + { + \tex_marks:D \g__tag_mc_marks + { + b-, %first of begin pair + \int_use:N\c@g__tag_MCID_abs_int, %mc-num + -1, %structure num + #1 %type + } + \tex_marks:D \g__tag_mc_marks + { + b+, %first of begin pair + \int_use:N\c@g__tag_MCID_abs_int, %mc-num + -1, %structure num + #1 %Type + } + } + +\cs_new_protected:Npn \__tag_mc_end_marks: + { + \tex_marks:D \g__tag_mc_marks + { + e-, %first of end pair + \int_use:N\c@g__tag_MCID_abs_int, %mc-num + \g__tag_struct_stack_current_tl, %structure num + } + \tex_marks:D \g__tag_mc_marks + { + e+, %second of end pair + \int_use:N\c@g__tag_MCID_abs_int, %mc-num + \g__tag_struct_stack_current_tl, %structure num + } + } +\cs_new_protected:Npn \__tag_mc_disable_marks: + { + \cs_set_eq:NN \__tag_mc_begin_marks:nn \use_none:nn + \cs_set_eq:NN \__tag_mc_artifact_begin_marks:n \use_none:n + \cs_set_eq:NN \__tag_mc_end_marks: \prg_do_nothing: + } +\cs_new_protected:Npn \__tag_mc_get_marks: + { + \exp_args:NNx + \seq_set_from_clist:Nn \l__tag_mc_firstmarks_seq + { \tex_firstmarks:D \g__tag_mc_marks } + \exp_args:NNx + \seq_set_from_clist:Nn \l__tag_mc_botmarks_seq + { \tex_botmarks:D \g__tag_mc_marks } + } +\cs_new_protected:Npn \__tag_mc_store:nnn #1 #2 #3 %#1 mc-prev, #2 mc-num #3 structure-num + { + %\prop_show:N \g__tag_struct_cont_mc_prop + \prop_get:NnNTF \g__tag_struct_cont_mc_prop {#1} \l__tag_tmpa_tl + { + \prop_gput:Nnx \g__tag_struct_cont_mc_prop {#1}{ \l__tag_tmpa_tl \__tag_struct_mcid_dict:n {#2}} + } + { + \prop_gput:Nnx \g__tag_struct_cont_mc_prop {#1}{ \__tag_struct_mcid_dict:n {#2}} + } + \prop_gput:Nxx \g__tag_mc_parenttree_prop + {#2} + {#3} + } +\cs_generate_variant:Nn \__tag_mc_store:nnn {xxx} +\cs_new_protected:Npn \__tag_mc_insert_extra_tmb:n #1 % #1 stream: e.g. main or footnote + { + \__tag_check_typeout_v:n {=>~ first~ \seq_use:Nn \l__tag_mc_firstmarks_seq {,~}} + \__tag_check_typeout_v:n {=>~ bot~ \seq_use:Nn \l__tag_mc_botmarks_seq {,~}} + \__tag_check_if_mc_tmb_missing:TF + { + \__tag_check_typeout_v:n {=>~ TMB~ ~ missing~ --~ inserted} + %test if artifact + \int_compare:nNnTF { \seq_item:cn { g__tag_mc_#1_marks_seq } {3} } = {-1} + { + \tl_set:Nx \l__tag_tmpa_tl { \seq_item:cn { g__tag_mc_#1_marks_seq } {4} } + \__tag_mc_handle_artifact:N \l__tag_tmpa_tl + } + { + \exp_args:Nx + \__tag_mc_bdc_mcid:n + { + \seq_item:cn { g__tag_mc_#1_marks_seq } {4} + } + \str_if_eq:eeTF + { + \seq_item:cn { g__tag_mc_#1_marks_seq } {5} + } + {} + { + %store + \__tag_mc_store:xxx + { + \seq_item:cn { g__tag_mc_#1_marks_seq } {2} + } + { \int_eval:n{\c@g__tag_MCID_abs_int} } + { + \seq_item:cn { g__tag_mc_#1_marks_seq } {3} + } + } + { + %stashed -> warning!! + } + } + } + { + \__tag_check_typeout_v:n {=>~ TMB~ not~ missing} + } + } + +\cs_new_protected:Npn \__tag_mc_insert_extra_tme:n #1 % #1 stream, eg. main or footnote + { + \__tag_check_if_mc_tme_missing:TF + { + \__tag_check_typeout_v:n {=>~ TME~ ~ missing~ --~ inserted} + \__tag_mc_emc: + \seq_gset_eq:cN + { g__tag_mc_#1_marks_seq } + \l__tag_mc_botmarks_seq + } + { + \__tag_check_typeout_v:n {=>~ TME~ not~ missing} + } + } +\cs_new:Npn\__tag_add_missing_mcs:Nn #1 #2 { + \vbadness \@M + \vfuzz \c_max_dim + \vbox_set_to_ht:Nnn #1 { \box_ht:N #1 } { + \hbox_set:Nn \l__tag_tmpa_box { \__tag_mc_insert_extra_tmb:n {#2} } + \hbox_set:Nn \l__tag_tmpb_box { \__tag_mc_insert_extra_tme:n {#2} } + \int_compare:nNnT {\l__tag_loglevel_int} > { 0 } + { + \seq_log:c { g__tag_mc_#2_marks_seq} + } + \box_set_ht:Nn \l__tag_tmpa_box \c_zero_dim + \box_set_dp:Nn \l__tag_tmpa_box \c_zero_dim + \box_set_ht:Nn \l__tag_tmpb_box \c_zero_dim + \box_set_dp:Nn \l__tag_tmpb_box { \box_dp:N #1 } + \boxmaxdepth \@maxdepth + \box_use_drop:N \l__tag_tmpa_box + \vbox_unpack_drop:N #1 + \tex_kern:D -\box_dp:N \l__tag_tmpb_box + \nointerlineskip + \box_use_drop:N \l__tag_tmpb_box + } +} + +\cs_new_protected:Npn \__tag_add_missing_mcs_to_stream:Nn #1#2 + { + \__tag_check_if_active_mc:T { + \vbadness\maxdimen + \box_set_eq:NN \l__tag_tmpa_box #1 + \vbox_set_split_to_ht:NNn \l__tag_tmpa_box \l__tag_tmpa_box \c_max_dim + \exp_args:NNx + \seq_set_from_clist:Nn \l__tag_mc_firstmarks_seq + { \tex_splitfirstmarks:D \g__tag_mc_marks } + \seq_if_empty:NTF \l__tag_mc_firstmarks_seq + { + \__tag_check_typeout_v:n + { + No~ marks~ so~ use~ saved~ bot~ mark:~ + \seq_use:cn {g__tag_mc_#2_marks_seq} {,~} \iow_newline: + } + \seq_set_eq:Nc \l__tag_mc_firstmarks_seq {g__tag_mc_#2_marks_seq} + \seq_set_eq:NN \l__tag_mc_botmarks_seq \l__tag_mc_firstmarks_seq + } + { + \__tag_check_typeout_v:n + { + Pick~ up~ new~ bot~ mark! + } + \exp_args:NNx + \seq_set_from_clist:Nn \l__tag_mc_botmarks_seq + { \tex_splitbotmarks:D \g__tag_mc_marks } + } + \__tag_add_missing_mcs:Nn #1 {#2} +%% + \seq_gset_eq:cN {g__tag_mc_#2_marks_seq} \l__tag_mc_botmarks_seq +%% + } +} \prg_new_conditional:Nnn \__tag_mc_if_in: {p,T,F,TF} { \bool_if:NTF \g__tag_in_mc_bool @@ -118,6 +325,7 @@ \cs_new_protected:Npn \__tag_mc_handle_artifact:N #1 % #1 is a var containing the artifact type { + \int_gincr:N \c@g__tag_MCID_abs_int \tl_if_empty:NTF #1 { \__tag_mc_bmc_artifact: } { \exp_args:NV\__tag_mc_bmc_artifact:n #1 } @@ -135,12 +343,15 @@ \bool_if:NTF \l__tag_mc_artifact_bool { %handle artifact \__tag_mc_handle_artifact:N \l__tag_mc_artifact_type_tl + \exp_args:NV + \__tag_mc_artifact_begin_marks:n \l__tag_mc_artifact_type_tl } { %handle mcid type \__tag_check_mc_tag:N \l__tag_mc_key_tag_tl \__tag_mc_handle_mcid:VV \l__tag_mc_key_tag_tl \l__tag_mc_key_properties_tl + \__tag_mc_begin_marks:oo{\l__tag_mc_key_tag_tl}{\l__tag_mc_key_label_tl} \tl_if_empty:NF {\l__tag_mc_key_label_tl} { \exp_args:NV @@ -162,6 +373,7 @@ \bool_gset_false:N \g__tag_in_mc_bool \tl_gset:Nn \g__tag_mc_key_tag_tl { } \__tag_mc_emc: + \__tag_mc_end_marks: } } @@ -176,17 +388,7 @@ { \tl_put_right:Nx \l__tag_mc_key_properties_tl { #1 } }, - alttext .code:n = % Alt property - { - \str_set_convert:Nnon - \l__tag_tmpa_str - { #1 } - { default } - { utf16/hex } - \tl_put_right:Nn \l__tag_mc_key_properties_tl { /Alt~< } - \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ } - }, - alttext-o .code:n = % Alt property + alttext .code:n = % Alt property { \str_set_convert:Noon \l__tag_tmpa_str @@ -197,16 +399,6 @@ \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ } }, actualtext .code:n = % ActualText property - { - \str_set_convert:Nnon - \l__tag_tmpa_str - { #1 } - { default } - { utf16/hex } - \tl_put_right:Nn \l__tag_mc_key_properties_tl { /ActualText~< } - \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ } - }, - actualtext-o .code:n = % ActualText property { \str_set_convert:Noon \l__tag_tmpa_str diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty index 540653c264f..e307ec22bba 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty @@ -20,7 +20,7 @@ %% %% File: tagpdf-mc.dtx -\ProvidesExplPackage {tagpdf-mc-code-lua} {2021-07-03} {0.91} +\ProvidesExplPackage {tagpdf-mc-code-lua} {2021-08-27} {0.92} {tagpdf - mc code only for the luamode } \hook_gput_code:nnn{begindocument}{tagpdf/mc} { @@ -73,6 +73,7 @@ } } } +\cs_new_protected:Npn \__tag_add_missing_mcs_to_stream:Nn #1#2 {} \prg_new_conditional:Nnn \__tag_mc_if_in: {p,T,F,TF} { \int_compare:nNnTF @@ -233,23 +234,6 @@ } }, alttext .code:n = % Alt property - { - \str_set_convert:Nnon - \l__tag_tmpa_str - { #1 } - { default } - { utf16/hex } - \tl_put_right:Nn \l__tag_mc_key_properties_tl { /Alt~< } - \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ } - \lua_now:e - { - ltx.__tag.func.store_mc_data - ( - \__tag_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l__tag_tmpa_str>" - ) - } - }, - alttext-o .code:n = % Alt property { \str_set_convert:Noon \l__tag_tmpa_str @@ -267,23 +251,6 @@ } }, actualtext .code:n = % Alt property - { - \str_set_convert:Nnon - \l__tag_tmpa_str - { #1 } - { default } - { utf16/hex } - \tl_put_right:Nn \l__tag_mc_key_properties_tl { /Alt~< } - \tl_put_right:No \l__tag_mc_key_properties_tl { \l__tag_tmpa_str>~ } - \lua_now:e - { - ltx.__tag.func.store_mc_data - ( - \__tag_get_mc_abs_cnt:,"actualtext","/ActualText~<\str_use:N \l__tag_tmpa_str>" - ) - } - }, - actualtext-o .code:n = % Alt property { \str_set_convert:Noon \l__tag_tmpa_str diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua index 92feda29abf..05d9c04eb78 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua @@ -24,8 +24,8 @@ local ProvidesLuaModule = { name = "tagpdf", - version = "0.91", --TAGVERSION - date = "2021-07-03", --TAGDATE + version = "0.92", --TAGVERSION + date = "2021-08-27", --TAGDATE description = "tagpdf lua code", license = "The LATEX Project Public License 1.3c" } diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty index a16f4ebacf8..83a173ba6de 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty @@ -27,7 +27,7 @@ %% and all files in that bundle must be distributed together. %% %% File: tagpdf.dtx -\ProvidesExplPackage {tagpdf} {2021-07-03} {0.91} +\ProvidesExplPackage {tagpdf} {2021-08-27} {0.92} { A package to experiment with pdf tagging } \bool_if:nF @@ -102,6 +102,8 @@ \seq_new:N \l__tag_tmpb_seq \clist_new:N \l__tag_tmpa_clist \int_new:N \l__tag_tmpa_int +\box_new:N \l__tag_tmpa_box +\box_new:N \l__tag_tmpb_box \clist_const:Nn \c__tag_refmc_clist {tagabspage,tagmcabs,tagmcid} \clist_const:Nn \c__tag_refstruct_clist {tagstruct,tagstructobj} \int_new:N \l__tag_loglevel_int @@ -192,7 +194,11 @@ % \end{macrocode} log .choice:, log / none .code:n = {\int_set:Nn \l__tag_loglevel_int { 0 }}, - log / v .code:n = {\int_set:Nn \l__tag_loglevel_int { 1 }}, + log / v .code:n = + { + \int_set:Nn \l__tag_loglevel_int { 1 } + \cs_set_protected:Nn \__tag_check_typeout_v:n { \iow_term:x {##1} } + }, log / vv .code:n = {\int_set:Nn \l__tag_loglevel_int { 2 }}, log / vvv .code:n = {\int_set:Nn \l__tag_loglevel_int { 3 }}, log / all .code:n = {\int_set:Nn \l__tag_loglevel_int { 10 }}, @@ -252,6 +258,10 @@ {something~is~wrong~with~the~mcid--rerun} \msg_new:nnn { tag } {sys-no-interwordspace} {engine/output~mode~#1~doesn't~support~the~interword~spaces} +\cs_set_eq:NN \__tag_check_typeout_v:n \use_none:n +\msg_new:nnnn { tag } {para-hook-count-wrong} + {The~number~of~automatic~begin~(#1)~and~end~(#2)~para~hooks~differ!} + {This~quite~probably~a~coding~error~and~the~structure~will~be~wrong!} \cs_new:Npn \tag_get:n #1 { \use:c {__tag_get_data_#1: } } \prg_new_conditional:Npnn \tag_if_active: { p , T , TF, F } { @@ -455,8 +465,34 @@ \seq_show:N \l_tmpa_seq } } +\prg_new_conditional:Npnn \__tag_check_if_mc_in_galley: { T,F,TF } + { + \tl_if_eq:NNTF \l__tag_mc_firstmarks_seq \l__tag_mc_botmarks_seq + { \prg_return_false: } + { \prg_return_true: } + } + +\prg_new_conditional:Npnn \__tag_check_if_mc_tmb_missing: { T,F,TF } + { + \bool_if:nTF + { + \str_if_eq_p:ee {\seq_item:Nn \l__tag_mc_firstmarks_seq {1}}{e-} + || + \str_if_eq_p:ee {\seq_item:Nn \l__tag_mc_firstmarks_seq {1}}{b+} + } + { \prg_return_true: } + { \prg_return_false: } + } + +\prg_new_conditional:Npnn \__tag_check_if_mc_tme_missing: { T,F,TF } + { + \str_if_eq:eeTF {\seq_item:Nn \l__tag_mc_botmarks_seq {1}}{b+} + { \prg_return_true: } + { \prg_return_false: } + } %% File: tagpdf-user.dtx + \NewDocumentCommand \tagpdfsetup { m } { \keys_set:nn { __tag / setup } { #1 } @@ -579,6 +615,49 @@ } } } +\keys_define:nn { __tag / show } + { + mc-marks .choice: , + mc-marks / show .code:n = + { + \__tag_mc_get_marks: + \__tag_check_if_mc_in_galley:TF + { + \iow_term:n {Marks~from~this~page:~} + } + { + \iow_term:n {Marks~from~a~previous~page:~} + } + \seq_show:N \l__tag_mc_firstmarks_seq + \seq_show:N \l__tag_mc_botmarks_seq + \__tag_check_if_mc_tmb_missing:T + { + \iow_term:n {BDC~missing~on~this~page!} + } + \__tag_check_if_mc_tme_missing:T + { + \iow_term:n {EMC~missing~on~this~page!} + } + }, + mc-marks / use .code:n = + { + \__tag_mc_get_marks: + \__tag_check_if_mc_in_galley:TF + { Marks~from~this~page:~} + { Marks~from~a~previous~page:~} + \seq_use:Nn \l__tag_mc_firstmarks_seq {,~}\quad + \seq_use:Nn \l__tag_mc_botmarks_seq {,~}\quad + \__tag_check_if_mc_tmb_missing:T + { + BDC~missing~ + } + \__tag_check_if_mc_tme_missing:T + { + EMC~missing + } + }, + mc-marks .default:n = show + } \keys_define:nn { __tag / show } { struct-stack .choice: @@ -610,7 +689,8 @@ } \bool_new:N \l__tag_para_bool \bool_new:N \l__tag_para_show_bool -\int_new:N \g__tag_para_int +\int_new:N \g__tag_para_begin_int +\int_new:N \g__tag_para_end_int \keys_define:nn { __tag / setup } { paratagging .bool_set:N = \l__tag_para_bool, @@ -619,13 +699,13 @@ \AddToHook{para/begin} { - \int_gincr:N \g__tag_para_int \bool_if:NT \l__tag_para_bool { + \int_gincr:N \g__tag_para_begin_int \tag_struct_begin:n {tag=P} \bool_if:NT \l__tag_para_show_bool { \tag_mc_begin:n{artifact} - \llap{\color_select:n{red}\tiny\int_use:N\g__tag_para_int\ } + \llap{\color_select:n{red}\tiny\int_use:N\g__tag_para_begin_int\ } \tag_mc_end: } \tag_mc_begin:n {tag=P} @@ -635,17 +715,119 @@ { \bool_if:NT \l__tag_para_bool { + \int_gincr:N \g__tag_para_end_int \tag_mc_end: \bool_if:NT \l__tag_para_show_bool { \tag_mc_begin:n{artifact} - \rlap{\color_select:n{red}\tiny\ \int_use:N\g__tag_para_int} + \rlap{\color_select:n{red}\tiny\ \int_use:N\g__tag_para_end_int} \tag_mc_end: } \tag_struct_end: } } +\AddToHook{enddocument/info} + { + \int_compare:nNnF {\g__tag_para_begin_int}={\g__tag_para_end_int} + { + \msg_error:nnxx + {tag} + {para-hook-count-wrong} + {\int_use:N\g__tag_para_begin_int} + {\int_use:N\g__tag_para_end_int} + } + } +\AddToHook{begindocument/before} + { + \bool_if:NF \g__tag_mode_lua_bool + { + \cs_if_exist:NT \@kernel@before@footins + { + \tl_put_right:Nn \@kernel@before@footins + { \__tag_add_missing_mcs_to_stream:Nn \footins {footnote} } + \tl_put_right:Nn \@kernel@before@cclv + { + \__tag_check_typeout_v:n {====>~In~\token_to_str:N \@makecol\c_space_tl\the\c@page} + \__tag_add_missing_mcs_to_stream:Nn \@cclv {main} + } + \tl_put_right:Nn \@mult@ptagging@hook + { + \__tag_check_typeout_v:n {====>~In~\string\page@sofar} + \process@cols\mult@gfirstbox + { + \__tag_add_missing_mcs_to_stream:Nn \count@ {multicol} + } + \__tag_add_missing_mcs_to_stream:Nn \mult@rightbox {multicol} + } + } + } + } \newcommand\tagpdfparaOn {\bool_set_true:N \l__tag_para_bool} \newcommand\tagpdfparaOff{\bool_set_false:N \l__tag_para_bool} +\NewDocumentCommand\tagpdfsuppressmarks{m} + {{\use:c{__tag_mc_disable_marks:} #1}} +\cs_new_protected:Npn\__tag_hook_kernel_before_head:{} +\cs_new_protected:Npn\__tag_hook_kernel_after_head:{} +\cs_new_protected:Npn\__tag_hook_kernel_before_foot:{} +\cs_new_protected:Npn\__tag_hook_kernel_after_foot:{} + +\AddToHook{begindocument} + { + \cs_if_exist:NT \@kernel@before@head + { + \tl_put_right:Nn \@kernel@before@head {\__tag_hook_kernel_before_head:} + \tl_put_left:Nn \@kernel@after@head {\__tag_hook_kernel_after_head:} + \tl_put_right:Nn \@kernel@before@foot {\__tag_hook_kernel_before_foot:} + \tl_put_left:Nn \@kernel@after@foot {\__tag_hook_kernel_after_foot:} + } + } + +\bool_new:N \g__tag_saved_in_mc_bool +\cs_new_protected:Npn \__tag_exclude_headfoot_begin: + { + \bool_set_false:N \l__tag_para_bool + \bool_if:NTF \g__tag_mode_lua_bool + { + \tag_mc_end_push: + } + { + \bool_gset_eq:NN \g__tag_saved_in_mc_bool \g__tag_in_mc_bool + \bool_gset_false:N \g__tag_in_mc_bool + } + \tag_mc_begin:n {artifact} + } +\cs_new_protected:Npn \__tag_exclude_headfoot_end: + { + \tag_mc_end: + \bool_if:NTF \g__tag_mode_lua_bool + { + \tag_mc_begin_pop:n{} + } + { + \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_saved_in_mc_bool + } + } + +\keys_define:nn { __tag / setup } + { + exclude-header-footer .choice:, + exclude-header-footer / true .code:n = + { + \cs_set_eq:NN \__tag_hook_kernel_before_head: \__tag_exclude_headfoot_begin: + \cs_set_eq:NN \__tag_hook_kernel_before_foot: \__tag_exclude_headfoot_begin: + \cs_set_eq:NN \__tag_hook_kernel_after_head: \__tag_exclude_headfoot_end: + \cs_set_eq:NN \__tag_hook_kernel_after_foot: \__tag_exclude_headfoot_end: + }, + exclude-header-footer / false .code:n = + { + \cs_set_eq:NN \__tag_hook_kernel_before_head: \prg_do_nothing: + \cs_set_eq:NN \__tag_hook_kernel_before_foot: \prg_do_nothing: + \cs_set_eq:NN \__tag_hook_kernel_after_head: \prg_do_nothing: + \cs_set_eq:NN \__tag_hook_kernel_after_foot: \prg_do_nothing: + }, + exclude-header-footer .default:n = true, + exclude-header-footer .initial:n = true + } + \hook_gput_code:nnn {pdfannot/link/URI/before} {tagpdf} @@ -808,6 +990,14 @@ { \tl_set:Nn \l__tag_mc_artifact_type_tl { Pagination } }, + __artifact-type / pagination/header .code:n = + { + \tl_set:Nn \l__tag_mc_artifact_type_tl { Pagination/Subtype/Header } + }, + __artifact-type / pagination/footer .code:n = + { + \tl_set:Nn \l__tag_mc_artifact_type_tl { Pagination/Subtype/Footer } + }, __artifact-type / layout .code:n = { \tl_set:Nn \l__tag_mc_artifact_type_tl { Layout } @@ -1567,6 +1757,8 @@ \newcounter { g__tag_struct_abs_int } \int_gzero:N \c@g__tag_struct_abs_int \__tag_seq_new:N \g__tag_struct_objR_seq + +\__tag_prop_new:N \g__tag_struct_cont_mc_prop \seq_new:N \g__tag_struct_stack_seq \seq_gpush:Nn \g__tag_struct_stack_seq {0} \seq_new:N \g__tag_struct_tag_stack_seq @@ -1646,20 +1838,31 @@ { g__tag_struct_0_prop } { Namespaces } { \pdf_object_ref:n { __tag/tree/namespaces } } +\cs_new:Npn \__tag_struct_mcid_dict:n #1 %#1 MCID absnum + { + << + /Type \c_space_tl /MCR \c_space_tl + /Pg + \c_space_tl + \pdf_pageobject_ref:n { \__tag_ref_value:enn{mcid-#1}{tagabspage}{1} } + /MCID \c_space_tl \__tag_ref_value:enn{mcid-#1}{tagmcid}{1} + >> + } \cs_new_protected:Npn \__tag_struct_kid_mc_gput_right:nn #1 #2 %#1 structure num, #2 MCID absnum% { \__tag_seq_gput_right:cx { g__tag_struct_kids_#1_seq } { - << - /Type \c_space_tl /MCR \c_space_tl - /Pg - \c_space_tl - \pdf_pageobject_ref:n { \__tag_ref_value:enn{mcid-#2}{tagabspage}{1} } - /MCID \c_space_tl \__tag_ref_value:enn{mcid-#2}{tagmcid}{1} - >> + \__tag_struct_mcid_dict:n {#2} + } + \__tag_seq_gput_right:cn + { g__tag_struct_kids_#1_seq } + { + \prop_item:Nn \g__tag_struct_cont_mc_prop {#2} } } +\cs_generate_variant:Nn \__tag_struct_kid_mc_gput_right:nn {nx} + \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:cx @@ -1700,6 +1903,18 @@ \cs_generate_variant:Nn\__tag_struct_exchange_kid_command:N { c } \cs_new_protected:Npn \__tag_struct_fill_kid_key:n #1 %#1 is the struct num { + \bool_if:NF\g__tag_mode_lua_bool + { + \seq_clear:N \l__tag_tmpa_seq + \seq_map_inline:cn { g__tag_struct_kids_#1_seq } + { \seq_put_right:Nx \l__tag_tmpa_seq { ##1 } } + %\seq_show:c { g__tag_struct_kids_#1_seq } + %\seq_show:N \l__tag_tmpa_seq + \seq_remove_all:Nn \l__tag_tmpa_seq {} + %\seq_show:N \l__tag_tmpa_seq + \seq_gset_eq:cN { g__tag_struct_kids_#1_seq } \l__tag_tmpa_seq + } + \int_case:nnF { \seq_count:c @@ -1873,18 +2088,6 @@ { <\l__tag_tmpa_str> } }, alttext .code:n = % Alt property - { - \str_set_convert:Nnon - \l__tag_tmpa_str - { #1 } - { default } - { utf16/hex } - \__tag_prop_gput:cnx - { g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_prop } - { Alt } - { <\l__tag_tmpa_str> } - }, - alttext-o .code:n = % Alt property { \str_set_convert:Noon \l__tag_tmpa_str @@ -1897,18 +2100,6 @@ { <\l__tag_tmpa_str> } }, actualtext .code:n = % ActualText property - { - \str_set_convert:Nnon - \l__tag_tmpa_str - { #1 } - { default } - { utf16/hex } - \__tag_prop_gput:cnx - { g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_prop } - { ActualText } - { <\l__tag_tmpa_str>} - }, - actualtext-o .code:n = % ActualText property { \str_set_convert:Noon \l__tag_tmpa_str diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty index da42672f443..6ba1ee8d3f3 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdfdocu-patches.sty @@ -1,5 +1,5 @@ %\RequirePackage[enable-debug]{expl3}[2018/06/14] -\ProvidesExplPackage {tagpdfdocu-patches} {2021-07-03} {0.91} +\ProvidesExplPackage {tagpdfdocu-patches} {2021-08-27} {0.92} {patches/commands for the tagpdf documentation} \RequirePackage{etoolbox} %%%% @@ -11,15 +11,23 @@ %% so let's test it here and patch \@outputpage %% we also disable paratagging, not for the tagging but to avoid that the small %% numbers gives overfull vbox messages ... +\bool_new:N \g__tag_docu_saved_in_mc_bool \patchcmd\@outputpage {\hb@xt@\textwidth{\@thehead}} { \hb@xt@\textwidth { \bool_set_false:N \l__tag_para_bool - \tag_mc_artifact_group_begin:n{pagination} + \bool_gset_eq:NN \g__tag_docu_saved_in_mc_bool \g__tag_in_mc_bool + \bool_gset_false:N \g__tag_in_mc_bool + \hfil + \tag_mc_begin:n {artifact=pagination} + \tag_stop_group_begin: \@thehead - \tag_mc_artifact_group_end: + \tag_stop_group_end: + \tag_mc_end: + \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_docu_saved_in_mc_bool + \hfil } } {}{\fail} @@ -29,9 +37,16 @@ \hb@xt@\textwidth { \bool_set_false:N \l__tag_para_bool - \tag_mc_artifact_group_begin:n{pagination} + \bool_gset_eq:NN \g__tag_docu_saved_in_mc_bool \g__tag_in_mc_bool + \bool_gset_false:N \g__tag_in_mc_bool + \hfil + \tag_mc_begin:n {artifact=pagination} + \tag_stop_group_begin: \@thefoot - \tag_mc_artifact_group_end: + \tag_stop_group_end: + \tag_mc_end: + \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_docu_saved_in_mc_bool + \hfil } } {}{\fail} -- cgit v1.2.3