diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty | 236 |
1 files changed, 214 insertions, 22 deletions
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 @@ -198,16 +400,6 @@ }, 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 { #1 } |