From 706448acbd096e1a59cb987e8352abdd43624ebe Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 7 Aug 2018 22:06:23 +0000 Subject: tagpdf (7aug18) git-svn-id: svn://tug.org/texlive/trunk@48366 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/latex/tagpdf/tagpdf-checks-code.sty | 80 ++++----- .../texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def | 8 +- .../tex/latex/tagpdf/tagpdf-mc-code-generic.sty | 112 +++++++++---- .../tex/latex/tagpdf/tagpdf-mc-code-lua.sty | 182 ++++++++++++++------- .../tex/latex/tagpdf/tagpdf-mc-code-shared.sty | 18 +- .../texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def | 7 +- .../tex/latex/tagpdf/tagpdf-roles-code.sty | 4 +- .../tex/latex/tagpdf/tagpdf-struct-code.sty | 95 ++++++++--- .../tex/latex/tagpdf/tagpdf-tree-code.sty | 92 ++++++----- Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty | 47 +++--- Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua | 21 ++- Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty | 43 ++++- 12 files changed, 462 insertions(+), 247 deletions(-) (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty index 107dcb3ab80..cd0ee0d70ab 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty @@ -1,37 +1,37 @@ -\ProvidesExplPackage {tagpdf-checks-code} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-checks-code} {2018/08/06} {0.3} {part of tagpdf - code related to checks and messages} %messages % mc -\msg_new:nnn { tagpdf } { mc-nested } { nested~marked~content~found~-~mcid~#1 } -\msg_new:nnn { tagpdf } { mc-tag-missing } { required~tag~missing~-~mcid~#1 } -\msg_new:nnn { tagpdf } { mc-label-unknown }{ label~#1~unknown~-~rerun } -\msg_new:nnn { tagpdf } { mc-used-twice } { mc~#1~has~been~already~used } -\msg_new:nnn { tagpdf } { mc-not-open } { there~is~no~mc~to~end~at~#1 } +\msg_new:nnn {uftag} {mc-nested} { nested~marked~content~found~-~mcid~#1 } +\msg_new:nnn {uftag} {mc-tag-missing} { required~tag~missing~-~mcid~#1 } +\msg_new:nnn {uftag} {mc-label-unknown} { label~#1~unknown~-~rerun } +\msg_new:nnn {uftag} {mc-used-twice} { mc~#1~has~been~already~used } +\msg_new:nnn {uftag} {mc-not-open} { there~is~no~mc~to~end~at~#1 } % structures -\msg_new:nnn { tagpdf } { struct-no-objnum } { objnum~missing~for~structure~#1 } -\msg_new:nnn { tagpdf } { struct-faulty-nesting } { there~is~no~open~structure~on~the~stack } -\msg_new:nnn { tagpdf } { struct-missing-tag } { a~structure~must~have~a~tag! } -\msg_new:nnn { tagpdf } { struct-show-closing } { closing~structure~#1~tagged~\prop_item:cn{g__uftag_struct_#1_prop}{S} } -\msg_new:nnn { tagpdf } { struct-used-twice} { structure~with~label~#1~has~already~been~used} -\msg_new:nnn { tagpdf } { struct-label-unknown} { structure~with~label~#1~is~unknown~rerun} +\msg_new:nnn {uftag} {struct-no-objnum} { objnum~missing~for~structure~#1 } +\msg_new:nnn {uftag} {struct-faulty-nesting} { there~is~no~open~structure~on~the~stack } +\msg_new:nnn {uftag} {struct-missing-tag} { a~structure~must~have~a~tag! } +\msg_new:nnn {uftag} {struct-show-closing} { closing~structure~#1~tagged~\prop_item:cn{g__uftag_struct_#1_prop}{S} } +\msg_new:nnn {uftag} {struct-used-twice} { structure~with~label~#1~has~already~been~used} +\msg_new:nnn {uftag} {struct-label-unknown} { structure~with~label~#1~is~unknown~rerun} %Roles -\msg_new:nnn { tagpdf } { role-missing } { tag~#1~has~no~role~assigned } -\msg_new:nnn { tagpdf } { role-unknown } { role~#1~is~not~known } -\msg_new:nnn { tagpdf } { role-unknown-tag } { tag~#1~is~not~known } -\msg_new:nnn { tagpdf } { role-new-tag } { adding~new~tag~#1~mapped~to~role~#2 } +\msg_new:nnn {uftag} {role-missing} { tag~#1~has~no~role~assigned } +\msg_new:nnn {uftag} {role-unknown} { role~#1~is~not~known } +\msg_new:nnn {uftag} {role-unknown-tag} { tag~#1~is~not~known } +\msg_new:nnn {uftag} {role-new-tag} { adding~new~tag~#1~mapped~to~role~#2 } % trees -\msg_new:nnn { tagpdf } {tree-mcid-index-wrong } {something~is~wrong~with~the~mcid} +\msg_new:nnn {uftag} {tree-mcid-index-wrong} {something~is~wrong~with~the~mcid} % obj -\msg_new:nnn { tagpdf } {obj-write-num } {write~obj~#1~to~pdf} +\msg_new:nnn {uftag} {obj-write-num} {write~obj~#1~to~pdf} %checks @@ -42,28 +42,28 @@ \prop_if_in:cnF { g__uftag_struct_#1_prop } {S} { - \msg_error:nn { tagpdf }{ struct-missing-tag } + \msg_error:nn {uftag} {struct-missing-tag} } } \cs_new:Nn \__uftag_check_structure_tag:N { - \prop_if_in:NoF \g__uftag_role_tags_prop { #1 } + \prop_if_in:NoF \g__uftag_role_tags_prop {#1} { - \msg_warning:nnx {tagpdf}{role-unknown-tag} { #1 } + \msg_warning:nnx {uftag} {role-unknown-tag} {#1} } } \cs_new:Nn \__uftag_check_info_closing_struct:n %#1 struct num { - \msg_info:nnn {tagpdf}{struct-show-closing}{#1} + \msg_info:nnn {uftag} {struct-show-closing} {#1} } \cs_generate_variant:Nn \__uftag_check_info_closing_struct:n {o,x} \cs_new:Nn \__uftag_check_no_open_struck: { - \msg_error:nn {tagpdf}{ struct-faulty-nesting } + \msg_error:nn {uftag} {struct-faulty-nesting} } \cs_new:Nn \__uftag_check_struct_used:n %#1 label @@ -72,24 +72,24 @@ {g__uftag_struct_\zref@extractdefault{tagpdfstruct-#1}{tagstruct}{unknown}_prop} {P} \l_tmpa_tl - {\msg_warning:nnn {tagpdf}{struct-used-twice}{#1}} + { \msg_warning:nnn {uftag} {struct-used-twice} {#1} } } %roles \cs_new:Nn \__uftag_check_add_tag_role:nn %#1 tag, #2 role { - \tl_if_empty:nTF { #2 } + \tl_if_empty:nTF {#2} { - \msg_warning:nnn { tagpdf }{ role-missing } { #1 } + \msg_warning:nnn {uftag} {role-missing} {#1} } { - \prop_get:NnNF \g__uftag_role_tags_prop { #2 } \l_tmpa_tl + \prop_get:NnNF \g__uftag_role_tags_prop {#2} \l_tmpa_tl { - \msg_warning:nnn { tagpdf }{ role-unknown } { #2 } + \msg_warning:nnn {uftag} {role-unknown} {#2} } { - \msg_info:nnnn { tagpdf }{ role-new-tag } { #1 }{ #2 } + \msg_info:nnnn {uftag} {role-new-tag} {#1} {#2} } } } @@ -99,7 +99,7 @@ { \_uftag_mc_if_in:T { - \msg_warning:nnx {tagpdf}{mc-nested}{ \__uftag_get_mc_abs_cnt: } + \msg_warning:nnx {uftag} {mc-nested} { \__uftag_get_mc_abs_cnt: } } } @@ -107,7 +107,7 @@ { \_uftag_mc_if_in:F { - \msg_warning:nnx {tagpdf}{mc-not-open}{ \__uftag_get_mc_abs_cnt: } + \msg_warning:nnx {uftag} {mc-not-open} { \__uftag_get_mc_abs_cnt: } } } @@ -115,23 +115,23 @@ { \tl_if_empty:NT #1 { - \msg_error:nnx {tagpdf}{mc-tag-missing}{ \__uftag_get_mc_abs_cnt: } + \msg_error:nnx {uftag} {mc-tag-missing} { \__uftag_get_mc_abs_cnt: } } - \prop_if_in:NoF \g__uftag_role_tags_prop { #1 } + \prop_if_in:NoF \g__uftag_role_tags_prop {#1} { - \msg_warning:nnx {tagpdf}{role-unknown-tag} { #1 } + \msg_warning:nnx {uftag} {role-unknown-tag} {#1} } } \seq_new:N \g__uftag_check_mc_used_seq \cs_new:Nn \__uftag_check_mc_used:n { - \seq_if_in:NnTF \g__uftag_check_mc_used_seq { #1 } + \seq_if_in:NnTF \g__uftag_check_mc_used_seq {#1} { - \msg_warning:nnn {tagpdf}{mc-used-twice}{ #1 } + \msg_warning:nnn {uftag} {mc-used-twice} {#1} } { - \seq_gput_right:Nx\g__uftag_check_mc_used_seq { #1 } + \seq_gput_right:Nx \g__uftag_check_mc_used_seq {#1} } } @@ -174,11 +174,11 @@ } } -\cs_new:Nn\__uftag_check_record_pdfobj_num:n +\cs_new:Nn \__uftag_check_record_pdfobj_num:n { - \int_compare:nT {\l__uftag_loglevel_int >= 3 } + \int_compare:nT { \l__uftag_loglevel_int >= 3 } { - \msg_info:nnx { tagpdf }{obj-write-num}{#1} + \msg_info:nnx {uftag} {obj-write-num} {#1} } } diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def index 4590d0cc21f..cee2e931e9a 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def @@ -1,4 +1,4 @@ -\ProvidesExplFile {tagpdf-luatex.def} {2018/07/09} {0.2} +\ProvidesExplFile {tagpdf-luatex.def} {2018/08/06} {0.3} {tagpdf driver for luatex} \newattribute \g__uftag_mc_type_attr %the value represent the type @@ -10,6 +10,12 @@ %%%% driver (lualatex) commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% needed for \str_set_convert:Nnon +\tl_new:N \g__uftag_inputencoding_tl +\tl_gset:Nn \g__uftag_inputencoding_tl {} + + +% literals \cs_new:Nn \__uftag_pdfliteral_page:n {\__uftag_tex_pdfextension:D literal~page {#1}} \cs_new:Nn \__uftag_pdfcatalog:n {\__uftag_tex_pdfextension:D catalog {#1}} 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 29309cfba33..b8839782ca1 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 @@ -1,4 +1,4 @@ -\ProvidesExplPackage {tagpdf-mc-code-generic} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-mc-code-generic} {2018/08/06} {0.3} {part of tagpdf - code related to marking chunks - generic mode} % for the label system @@ -7,7 +7,7 @@ \int_new:N \g__uftag_MCID_tmp_bypage_int \zref@newprop {tagmcid} [0] { \int_use:N \g__uftag_MCID_tmp_bypage_int } -\zref@addprop {tagpdf} {tagmcid} +\zref@addprop {uftagzrl} {tagmcid} % will hold the current maximum on a page % it will contain key-value of type "abspagenum=max mcid on this page" @@ -18,12 +18,13 @@ % they insert literals and so a are specific to generic mode % checking if the type is defined will done somewhere else % #1 is the type/tag +% change 04.08.2018: I don't try to escape the name, but assume that it is valid. +% Checks/conversions should perhaps be done on a higher level \cs_new:Nn \__uftag_mc_bmc:n { - \__uftag_pdf_escape_name:Nn\l_uttag_tmpa_tl { #1 } \__uftag_pdfliteral_page:n { - /\l_uttag_tmpa_tl\c_space_tl BMC + /#1\c_space_tl BMC } } @@ -36,14 +37,13 @@ } % #1 tag, #2 properties -% I escape the name. But the dictionary content +% change 04.08.2018: I don't escape the name. Also the dictionary content % must imho be done at a higher level \cs_new:Nn \__uftag_mc_bdc:nn { - \__uftag_pdf_escape_name:Nn\l_uttag_tmpa_tl { #1 } \__uftag_pdfliteral_page:n { - /\l_uttag_tmpa_tl\c_space_tl<<#2>>~BDC + /#1\c_space_tl<<#2>>~BDC } } @@ -92,16 +92,16 @@ { mcid-\int_use:N \c@g__uftag_MCID_abs_int } - {tagpdf} + {uftagzrl} \__uftag_mc_bdc:nn - { #1 } + {#1} { /MCID~\int_eval:n { \g__uftag_MCID_tmp_bypage_int }~#2 } } % only /MCID \cs_new:Nn \__uftag_mc_bdc_mcid:n { - \__uftag_mc_bdc_mcid:nn { #1 } {} + \__uftag_mc_bdc_mcid:nn {#1} {} } %artifact without type @@ -122,42 +122,88 @@ % keyval definitions for the user commands: \tl_new:N \l__uftag_mc_key_tag_tl - +\tl_new:N \l__uftag_mc_key_properties_tl %Attention! definitions are different in luamode. -\keys_define:nn { tagpdf / mc } -{ - tag .code:n = % the name (H,P,Span etc - { - \__uftag_pdf_escape_name:Nn \l__uftag_mc_key_tag_tl { #1 } - }, - raw .tl_set:N = \l__uftag_mc_key_properties_tl, - label .tl_set:N = \l__uftag_mc_key_label_tl, - artifact .meta:n = { artifact-bool, artifact-type=#1 }, - artifact .default:n = {notype} -} +% tag and raw are expanded as \directlua in lua does it too. +\keys_define:nn { uftag / mc } + { + tag .code:n = % the name (H,P,Span etc + { + %%????????? \pdfescapename?? + \tl_set:Nx \l__uftag_mc_key_tag_tl { #1 } + }, + raw .code:n = + { + \tl_put_right:Nx \l__uftag_mc_key_properties_tl { #1 } + } + , + alttext .code:n = % Alt property + { + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + }, + alttext-o .code:n = % Alt property + { + \str_set_convert:Noon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + }, + actualtext .code:n = % ActualText property + { + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /ActualText~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + }, + actualtext-o .code:n = % ActualText property + { + \str_set_convert:Noon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /ActualText~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + }, + label .tl_set:N = \l__uftag_mc_key_label_tl, + artifact .code:n = { \exp_args:Nnx \keys_set:nn { uftag / mc } { artifact-bool, artifact-type=#1 } }, + artifact .default:n = {notype} + } \cs_new:Nn \__uftag_mc_handle_artifact:N %#1 contains the artifact type { \tl_if_empty:NTF #1 { \__uftag_mc_bmc_artifact: } - { \exp_args:No\__uftag_mc_bmc_artifact:n { #1 } } + { \exp_args:No\__uftag_mc_bmc_artifact:n {#1} } } \cs_new:Nn \__uftag_mc_handle_mcid:nn %#1 tag, #2 properties { - \__uftag_mc_bdc_mcid:nn { #1 }{ #2 } + \__uftag_mc_bdc_mcid:nn {#1} {#2} } % puts the absolute number of an mcid in the current structure \cs_new:Nn \__uftag_mc_handle_stash:n %1 mcidnum { - \__uftag_check_mc_used:n { #1 } + \__uftag_check_mc_used:n {#1} \__uftag_struct_kid_mc_gput_right:nn { \g__uftag_struct_stack_current_tl } - { #1 } + {#1} \prop_gput:Nxx \g__uftag_mc_parenttree_prop - { #1 } + {#1} { \g__uftag_struct_stack_current_tl } } @@ -166,7 +212,7 @@ \group_begin: \__uftag_check_mc_if_nested: \bool_gset_true:N \g__uftag_in_mc_bool - \keys_set:nn { tagpdf / mc }{ #1 } + \keys_set:nn { uftag / mc } {#1} \bool_if:NTF \l__uftag_mc_artifact_bool { %handle artifact \__uftag_mc_handle_artifact:N \l__uftag_mc_artifact_type_tl @@ -186,25 +232,25 @@ \group_end: } -\cs_new:Nn\uftag_mc_end: +\cs_new:Nn \uftag_mc_end: { \__uftag_check_mc_if_open: \bool_gset_false:N \g__uftag_in_mc_bool \__uftag_mc_emc: } -\cs_new:Nn\uftag_mc_use:n %#1: label name +\cs_new:Nn \uftag_mc_use:n %#1: label name { \tl_set:Nx \l_tmpa_tl { \zref@extractdefault{tagpdf-#1}{tagmcabs}{} } \tl_if_empty:NTF\l_tmpa_tl { - \msg_warning:nnn {tagpdf} {mc-label-unknown} { #1 } + \msg_warning:nnn {uftag} {mc-label-unknown} {#1} } { \prop_gput:Nxx \g__uftag_mc_parenttree_prop { - \zref@extractdefault{tagpdf-#1}{tagmcabs}{} + \zref@extractdefault {tagpdf-#1} {tagmcabs} {} } { \g__uftag_struct_stack_current_tl @@ -214,7 +260,7 @@ \g__uftag_struct_stack_current_tl } { - \zref@extractdefault{tagpdf-#1}{tagmcabs}{} + \zref@extractdefault {tagpdf-#1} {tagmcabs} {} } } } 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 3b252c59739..eeee1bd80a8 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 @@ -1,14 +1,14 @@ -\ProvidesExplPackage {tagpdf-mc-code-lua} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-mc-code-lua} {2018/08/06} {0.3} {tagpdf - mc code only for the luamode } -%the two attibutes are defined in the driver file. -%it also load the lua (as it can also contain functions needed by generic mode. -%\newattribute \g__uftag_mc_type_attr %the value represent the type -%\newattribute \g__uftag_mc_cnt_attr %will hold the \c@g__uftag_MCID_abs_int value +% the two attibutes are defined in the driver file. +% it also load the lua (as it can also contain functions needed by generic mode. +% \newattribute \g__uftag_mc_type_attr %the value represent the type +% \newattribute \g__uftag_mc_cnt_attr %will hold the \c@g__uftag_MCID_abs_int value -%An attribute for the current structure probably doesn't make sense as mc chunks can be used later. -%\newattribute \g__uftag_struct_type_attr %represent the current structure type. Not sure if needed -%\newattribute \g__uftag_struct_cnt_attr %will hold \c@g__uftag_struct_abs_int a cnt +% An attribute for the current structure probably doesn't make sense as mc chunks can be used later. +% \newattribute \g__uftag_struct_type_attr %represent the current structure type. Not sure if needed +% \newattribute \g__uftag_struct_cnt_attr %will hold \c@g__uftag_struct_abs_int a cnt % handling attribute needs a different system to number the page wise mcid's: % a tagmcbegin ... tagmcend pair no longer surrounds exactly one mc chunk: it can be split @@ -30,82 +30,152 @@ % The main function which wanders through the shipout box to inject the literals. \AtBeginDocument -{ - \bool_if:NT\g_uftag_active_mc_bool { - \AtBeginShipout - { - \directlua{uftag.func.mark_shipout ()} - } + \bool_if:NT\g_uftag_active_mc_bool + { + \AtBeginShipout + { + \directlua{uftag.func.mark_shipout ()} + } + } } -} % the keys \tl_new:N \l__uftag_mc_key_tag_tl \tl_new:N \l__uftag_mc_key_label_tl \tl_new:N \l__uftag_mc_key_properties_tl -\keys_define:nn { tagpdf / mc } -{ - tag .code:n = % - { - \__uftag_pdf_escape_name:Nn \l__uftag_mc_key_tag_tl { #1 } - \directlua - { - uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"tag","#1") - } - }, - raw .code:n = - { - \tl_set:Nn\l__uftag_mc_key_properties_tl { #1 } - \directlua +\keys_define:nn { uftag / mc } + { + tag .code:n = % + {%%????????? \pdfescapename?? + \tl_set:Nx \l__uftag_mc_key_tag_tl { #1 } + \directlua + { + uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"tag","#1") + } + }, + raw .code:n = + { + \tl_put_right:Nx \l__uftag_mc_key_properties_tl { #1 } + \directlua + { + uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"raw","#1") + } + }, + alttext .code:n = % Alt property + { + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + \directlua + { + uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l__uftag_tmpa_str>") + } + }, + alttext-o .code:n = % Alt property + { + \str_set_convert:Noon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + \directlua + { + uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l__uftag_tmpa_str>") + } + }, + actualtext .code:n = % Alt property + { + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + \directlua + { + uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"actualtext","/ActualText~<\str_use:N \l__uftag_tmpa_str>") + } + }, + actualtext-o .code:n = % Alt property + { + \str_set_convert:Noon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + \directlua + { + uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"actualtext","/ActualText~<\str_use:N \l__uftag_tmpa_str>") + } + }, + label .code:n = + { + \tl_set:Nn\l__uftag_mc_key_label_tl { #1 } + \directlua {uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"label","#1")} + }, + __artifact-store .code:n = + { + \directlua {uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"artifact","#1")} + }, + artifact .code:n = { - uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"raw","#1") - } - }, - label .code:n = - { - \tl_set:Nn\l__uftag_mc_key_label_tl { #1 } - \directlua {uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"label","#1")} - }, - __artifact-store .code:n = - { - \directlua {uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"artifact","#1")} - }, - artifact .meta:n = { artifact-bool, artifact-type=#1,__artifact-store=#1, tag=Artifact }, - artifact .default:n = { notype } -} + \exp_args:Nnx \keys_set:nn {uftag / mc} { artifact-bool, artifact-type=#1, tag=Artifact } + \exp_args:Nnx \keys_set:nn {uftag / mc }{ __artifact-store=\l__uftag_mc_artifact_type_tl } + }, + artifact .default:n = { notype } + } % attributes % set the mc from a tag name +\cs_set_protected:Npn \__uftag_attribute_gset:Nn #1 #2 + { + \tex_global:D \setattribute #1 #2 + } + +\cs_set_protected:Npn \__uftag_attribute_gunset:N #1 + { + \tex_global:D \unsetattribute #1 + } + \cs_new:Nn \__uftag_mc_lua_gset_mc_type_attr:n % #1 is a tag name { - \global\setattribute \g__uftag_mc_type_attr { \directlua {uftag.func.output_num_from ("#1") } } - \global\setattribute \g__uftag_mc_cnt_attr { \__uftag_get_mc_abs_cnt: } + \__uftag_attribute_gset:Nn \g__uftag_mc_type_attr { \directlua {uftag.func.output_num_from ("#1") } } + \__uftag_attribute_gset:Nn \g__uftag_mc_cnt_attr { \__uftag_get_mc_abs_cnt: } } \cs_generate_variant:Nn\__uftag_mc_lua_gset_mc_type_attr:n { o } \cs_new:Nn \__uftag_mc_lua_gunset_mc_type_attr: { - \global\unsetattribute \g__uftag_mc_type_attr - \global\unsetattribute \g__uftag_mc_cnt_attr + \__uftag_attribute_gunset:N \g__uftag_mc_type_attr + \__uftag_attribute_gunset:N \g__uftag_mc_cnt_attr } %This command will in the finish code replace the dummy for a mc by the real mcid kids \cs_new:Nn \__uftag_mc_insert_mcid_kids:n - { - \directlua {uftag.func.mc_insert_kids (#1) } - } + { + \directlua {uftag.func.mc_insert_kids (#1) } + } % puts an mcid absolute number in the current structure \cs_new:Nn \__uftag_mc_handle_stash:n %1 mcidnum { \__uftag_check_mc_used:n { #1 } - \seq_gput_right:cn % Don't fill a lua table due to the command in the item, so the kernel command + \seq_gput_right:cn % Don't fill a lua table due to the command in the item, so the kernel command { g__uftag_struct_kids_\g__uftag_struct_stack_current_tl _seq } { \__uftag_mc_insert_mcid_kids:n {#1} @@ -128,7 +198,7 @@ \__uftag_check_mc_if_nested: \bool_gset_true:N \g__uftag_in_mc_bool \int_gincr:N \c@g__uftag_MCID_abs_int - \keys_set:nn { tagpdf / mc }{ label={}, #1 } + \keys_set:nn { uftag / mc }{ label={}, #1 } %check that a tag or artifact has been used \__uftag_check_mc_tag:N \l__uftag_mc_key_tag_tl %set the attributes (is done globally!): @@ -148,19 +218,19 @@ \group_end: } -\cs_new:Nn\uftag_mc_end: +\cs_new:Nn \uftag_mc_end: { \__uftag_check_mc_if_open: \bool_gset_false:N \g__uftag_in_mc_bool \__uftag_mc_lua_gunset_mc_type_attr: } -\cs_new:Nn\uftag_mc_use:n %#1: label name +\cs_new:Nn \uftag_mc_use:n %#1: label name { \tl_set:Nx \l_tmpa_tl { \zref@extractdefault{tagpdf-#1}{tagmcabs}{} } \tl_if_empty:NTF\l_tmpa_tl { - \msg_warning:nnn {tagpdf} {mc-label-unknown} { #1 } + \msg_warning:nnn {uftag} {mc-label-unknown} { #1 } } { \__uftag_mc_handle_stash:o { \l_tmpa_tl } diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty index 8c5013ec0a3..173967b945d 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty @@ -1,4 +1,4 @@ -\ProvidesExplPackage {tagpdf-mc-code-shared} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-mc-code-shared} {2018/08/06} {0.3} {part of tagpdf - code related to marking chunks - code shared by generic and luamode } % I use a latex counter for the absolute count, so that it is added to @@ -9,18 +9,18 @@ % the absolute counter can be used to label and to check if the page % counter needs a reset. -\newcounter { g__uftag_MCID_abs_int } -\cs_new:Nn \__uftag_get_mc_abs_cnt: { \int_use:N \c@g__uftag_MCID_abs_int } +\newcounter { g__uftag_MCID_abs_int } +\cs_new:Nn \__uftag_get_mc_abs_cnt: { \int_use:N \c@g__uftag_MCID_abs_int } % tagmcabs is the label name of the absolute count which is used to identify the chunk \zref@newprop {tagmcabs} [0] { \int_use:N \c@g__uftag_MCID_abs_int } -\zref@addprop {tagpdf} {tagmcabs} +\zref@addprop {uftagzrl} {tagmcabs} \zref@addprop {LastPage} {tagmcabs} %stores labels of mcid. \cs_new:Nn \__uftag_mc_handle_mc_label:n { - \zref@labelbylist{tagpdf-#1}{tagpdf} + \zref@labelbylist{tagpdf-#1}{uftagzrl} } % will hold the structure numbers for the parenttree @@ -31,7 +31,7 @@ %to test nesting mc: \bool_new:N \g__uftag_in_mc_bool -\prg_new_conditional:Nnn \_uftag_mc_if_in: {p,T,F,TF} +\prg_new_conditional:Nnn \_uftag_mc_if_in: {p,T,F,TF} { \bool_if:NTF \g__uftag_in_mc_bool { \prg_return_true: } @@ -39,10 +39,10 @@ } %shared keys -%the rest are in the splitted code -\tl_new:N \l__uftag_mc_artifact_type_tl +%the rest are in the splitted code +\tl_new:N \l__uftag_mc_artifact_type_tl -\keys_define:nn { tagpdf / mc } +\keys_define:nn { uftag / mc } { stash .bool_set:N = \l__uftag_mc_key_stash_bool, artifact-bool .bool_set:N = \l__uftag_mc_artifact_bool, diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def index 61dc45b2a6b..af9382748e6 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def @@ -1,10 +1,15 @@ -\ProvidesExplFile {tagpdf-pdftex.def} {2018/07/09} {0.2} +\ProvidesExplFile {tagpdf-pdftex.def} {2018/08/06} {0.3} {tagpdf driver for pdftex} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% driver (pdflatex) commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% needed for \str_set_convert:Nnon +\tl_new:N \g__uftag_inputencoding_tl +\tl_gset:Nn \g__uftag_inputencoding_tl {utf8} + + %literal \cs_new:Nn \__uftag_pdfliteral_page:n { \__uftag_tex_pdfliteral:D page { #1} } \cs_new:Nn \__uftag_pdfcatalog:n { \__uftag_tex_pdfcatalog:D { #1 } } diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty index 93180cc8576..bd8c680f963 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty @@ -1,4 +1,4 @@ -\ProvidesExplPackage {tagpdf-roles-code} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-roles-code} {2018/08/06} {0.3} {part of tagpdf - code related to roles and structure names} \__uftag_seq_new:N \g__uftag_role_tags_seq %to get names from numbers @@ -107,7 +107,7 @@ \cs_generate_variant:Nn \__uftag_role_add_tag:nn {xx} -\keys_define:nn { tagpdf-setup } +\keys_define:nn { uftag / setup } { add-new-tag .code:n = { diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty index 3c92767a107..898f33a7115 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty @@ -1,4 +1,4 @@ -\ProvidesExplPackage {tagpdf-struct-code} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-struct-code} {2018/08/06} {0.3} {part of tagpdf - code related to storing structure} % I will use a latex counter for the structure count @@ -9,8 +9,8 @@ \zref@newprop {tagstruct} [0] { \int_use:N \c@g__uftag_struct_abs_int } -\zref@newlist {tagpdfstruct} -\zref@addprop {tagpdfstruct}{tagstruct} +\zref@newlist {uftagzrlstruct} +\zref@addprop {uftagzrlstruct}{tagstruct} % a sequence stores structnum -> the obj numbers % to allow easy mapping over the structures @@ -243,19 +243,19 @@ } } { - \msg_error:nnn { tagpdf } { struct-no-objnum } { #1} + \msg_error:nnn {uftag} { struct-no-objnum } { #1} } } % keys for the user commands -% why did I call the submodule elem instead of struct? -\keys_define:nn { tagpdf / elem } +% should I pass the values (e.g. the tag) through an escape command? +\keys_define:nn { uftag / struct } { label .tl_set:N = \l__uftag_struct_key_label_tl, stash .bool_set:N = \l__uftag_struct_elem_stash_bool, tag .code:n = % S property - { - \__uftag_pdf_escape_name:Nn \l__uftag_tmpa_tl { #1 } + {%%????????? \pdfescapename?? + \tl_set:Nx \l__uftag_tmpa_tl { #1 } \bool_if:NT \g__uftag_check_tags_bool { \__uftag_check_structure_tag:N \l__uftag_tmpa_tl @@ -267,30 +267,75 @@ }, title .code:n = % T property { - \__uftag_pdf_escape_string:Nn \l__uftag_tmpa_tl { #1 } - \tl_put_left:Nn \l__uftag_tmpa_tl {(^^fe^^ff} - \__uftag_prop_gput:cno + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \__uftag_prop_gput:cnx + { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop } + { T } + { <\l__uftag_tmpa_str> } + }, + title-o .code:n = % T property + { + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \__uftag_prop_gput:cnx { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop } { T } - { \l__uftag_tmpa_tl) } + { <\l__uftag_tmpa_str> } }, alttext .code:n = % Alt property { - \__uftag_pdf_escape_string:Nn \l__uftag_tmpa_tl { #1 } - \tl_put_left:Nn \l__uftag_tmpa_tl {(^^fe^^ff} - \__uftag_prop_gput:cno + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \__uftag_prop_gput:cnx { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop } { Alt } - { \l__uftag_tmpa_tl) } + { <\l__uftag_tmpa_str> } + }, + alttext-o .code:n = % Alt property + { + \str_set_convert:Noon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \__uftag_prop_gput:cnx + { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop } + { Alt } + { <\l__uftag_tmpa_str> } }, actualtext .code:n = % ActualText property { - \__uftag_pdf_escape_hex:Nn \l__uftag_tmpa_tl {#1 } - \tl_put_left:Nn \l__uftag_tmpa_tl {} + }, + actualtext-o .code:n = % ActualText property + { + \str_set_convert:Noon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \__uftag_prop_gput:cnx { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop } { ActualText } - { \l__uftag_tmpa_tl>} + { <\l__uftag_tmpa_str>} }, } @@ -319,19 +364,19 @@ { g__uftag_struct_\int_eval:n { \c@g__uftag_struct_abs_int }_prop } { entries } { StructElem } - \keys_set:nn {tagpdf / elem} { #1 } + \keys_set:nn {uftag / struct} { #1 } \__uftag_check_structure_has_tag:n { \int_eval:n {\c@g__uftag_struct_abs_int} } \tl_if_empty:NF {\l__uftag_struct_key_label_tl} { - \zref@labelbylist{tagpdfstruct-\l__uftag_struct_key_label_tl}{tagpdfstruct} + \zref@labelbylist{tagpdfstruct-\l__uftag_struct_key_label_tl}{uftagzrlstruct} } %get the potential parent from the stack: \seq_get:NNF \g__uftag_struct_stack_seq \l__uftag_struct_stack_parent_tmp_tl { - \msg_error:nn { tagpdf } { struct-faulty-nesting } + \msg_error:nn { uftag } { struct-faulty-nesting } } \seq_gpush:NV \g__uftag_struct_stack_seq \c@g__uftag_struct_abs_int \tl_gset:NV \g__uftag_struct_stack_current_tl \c@g__uftag_struct_abs_int @@ -381,7 +426,7 @@ \cs_new:Nn \uftag_struct_use:n %#1 is the label { \prop_if_exist:cTF - { g__uftag_struct_\zref@extractdefault{tagpdfstruct-#1}{tagstruct}{unknown}_prop } + { g__uftag_struct_\zref@extractdefault{tagpdfstruct-#1}{tagstruct}{unknown}_prop } %?????????? { \__uftag_check_struct_used:n {#1} %add the label structure as kid to the current structure (can be the root) @@ -396,7 +441,7 @@ \prop_item:cn { g__uftag_struct_\g__uftag_struct_stack_current_tl _prop} { objnum }~0~R } } - {\msg_warning:nnn{tagpdf}{struct-label-unknown}{#1}} + {\msg_warning:nnn{uftag}{struct-label-unknown}{#1}} } \endinput diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty index 2fd82d27f66..d30b82a004e 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty @@ -1,14 +1,14 @@ -\ProvidesExplPackage {tagpdf-tree-code} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-tree-code} {2018/08/06} {0.3} {part of tagpdf - code related to writing trees and dictionaries to the pdf} %this does the actual finishing: \AtBeginDocument -{ - \bool_if:NT \g_uftag_active_tree_bool - { - \AfterEndDocument { \uftag_finish_structure: } - } -} + { + \bool_if:NT \g_uftag_active_tree_bool + { + \AfterEndDocument { \uftag_finish_structure: } + } + } % the StructTreeRoot @@ -18,10 +18,10 @@ \cs_new:Nn \__uftag_tree_write_structtreeroot: -{ - \__uftag_pdfcatalog:n { /StructTreeRoot~\c_uftag_tree_obj_structtreeroot_tl\c_space_tl0~R } - \__uftag_struct_write_obj:n { 0 } -} + { + \__uftag_pdfcatalog:n { /StructTreeRoot~\c_uftag_tree_obj_structtreeroot_tl\c_space_tl0~R } + \__uftag_struct_write_obj:n { 0 } + } \cs_new:Nn \__uftag_tree_write_structelements: { @@ -39,43 +39,43 @@ \tl_new:N \l__uftag_parenttree_content_tl \cs_new:Nn \__uftag_tree_fill_parenttree: -{ - \int_step_inline:nnnn{1}{1}{\zref@extractdefault{LastPage}{abspage}{-1}} %not quite clear if labels are needed. See lua code - { %page ##1\par - \prop_clear:N \l_tmpa_prop - \int_step_inline:nnnn{1}{1}{\zref@extractdefault{LastPage}{tagmcabs}{-1}} - { - %mcid####1 - \int_compare:nT%F - {\zref@extractdefault{mcid-####1}{tagabspage}{-1}=##1} %mcid is on current page - {% yes\par - \prop_put:Nxx \l_tmpa_prop - {\zref@extractdefault{mcid-####1}{tagmcid}{-1}} - {\prop_item:Nn \g__uftag_mc_parenttree_prop {####1}} - } - } - %\prop_show:N \l_tmpa_prop - \tl_put_right:Nx\l__uftag_parenttree_content_tl - {\int_eval:n {##1-1}\c_space_tl[\c_space_tl} %%brackt - \int_step_inline:nnnn {0}{1}{ \prop_map_function:NN \l_tmpa_prop\__uftag_prop_count:nn -1 } + { + \int_step_inline:nnnn{1}{1}{\zref@extractdefault{LastPage}{abspage}{-1}} %not quite clear if labels are needed. See lua code + { %page ##1\par + \prop_clear:N \l_tmpa_prop + \int_step_inline:nnnn{1}{1}{\zref@extractdefault{LastPage}{tagmcabs}{-1}} { - \prop_get:NnNTF \l_tmpa_prop {####1} \l_tmpb_tl - {% page#1:mcid##1:\l_tmpb_tl :content - \tl_put_right:Nx \l__uftag_parenttree_content_tl - { - \prop_item:cn { g__uftag_struct_\l_tmpb_tl _prop } {objnum}~0~R~ - } - } - {\msg_warning:nn {tagpdf} {tree-mcid-index-wrong} } + %mcid####1 + \int_compare:nT%F + {\zref@extractdefault{mcid-####1}{tagabspage}{-1}=##1} %mcid is on current page + {% yes\par + \prop_put:Nxx \l_tmpa_prop + {\zref@extractdefault{mcid-####1}{tagmcid}{-1}} + {\prop_item:Nn \g__uftag_mc_parenttree_prop {####1}} + } } - \tl_put_right:Nn\l__uftag_parenttree_content_tl{]^^J} % + %\prop_show:N \l_tmpa_prop + \tl_put_right:Nx\l__uftag_parenttree_content_tl + {\int_eval:n {##1-1}\c_space_tl[\c_space_tl} %%brackt + \int_step_inline:nnnn {0}{1}{ \prop_map_function:NN \l_tmpa_prop\__uftag_prop_count:nn -1 } + { + \prop_get:NnNTF \l_tmpa_prop {####1} \l_tmpb_tl + {% page#1:mcid##1:\l_tmpb_tl :content + \tl_put_right:Nx \l__uftag_parenttree_content_tl + { + \prop_item:cn { g__uftag_struct_\l_tmpb_tl _prop } {objnum}~0~R~ + } + } + {\msg_warning:nn {uftag} {tree-mcid-index-wrong} } + } + \tl_put_right:Nn \l__uftag_parenttree_content_tl {]^^J} % + } } -} %lua mode must/can do it differently \cs_new:Nn \__uftag_tree_lua_fill_parenttree: { - \tl_set:Nn\l__uftag_parenttree_content_tl + \tl_set:Nn \l__uftag_parenttree_content_tl { \directlua{uftag.func.output_parenttree(\int_use:N\g__uftag_abspage_int)} } @@ -136,12 +136,16 @@ %StructParents + tabs order. Tabs order should be probably be changeable by page. \cs_new:Nn \__uftag_tree_write_pageattr: -{ + { \__uftag_get_pdfpageattr:N \l_tmpa_tl \regex_replace_once:nnN {/StructParents\s*\d+} {}\l_tmpa_tl \regex_replace_once:nnN {/Tabs\s*/[SCR]} {}\l_tmpa_tl \__uftag_gset_pdfpageattr:x - {\l_tmpa_tl/StructParents\c_space_tl \int_eval:n{\g__uftag_abspage_int }\l__uftag_tree_tabs_order_tl} -} + { + \l_tmpa_tl / StructParents \c_space_tl + \int_eval:n { \g__uftag_abspage_int } + \l__uftag_tree_tabs_order_tl + } + } \endinput diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty index 137d636cc64..1b01e1521b6 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty @@ -1,9 +1,9 @@ -\ProvidesExplPackage {tagpdf-user} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-user} {2018/08/06} {0.3} {tagpdf - user commands} \NewDocumentCommand \tagpdfsetup { m } { - \keys_set:nn { tagpdf-setup } { #1 } + \keys_set:nn { uftag / setup } { #1 } } \cs_set_eq:NN\tagpdfifluatexTF \sys_if_engine_luatex:TF @@ -24,7 +24,8 @@ \NewDocumentCommand \tagmcend { } { - \unskip\uftag_mc_end: + \unskip % this unskip appears to mess up some spacing; can we do this in another way? + \uftag_mc_end: } \NewDocumentCommand \tagmcuse { m } @@ -54,34 +55,34 @@ %%%% debug/show commands \NewDocumentCommand\showtagpdfmcdata { O {\__uftag_get_mc_abs_cnt:} } -{ - \bool_if:NT \g__uftag_mode_lua_bool { - \sys_if_engine_luatex:T - { - \directlua{uftag.trace.show_all_mc_data(#1)} - } + \bool_if:NT \g__uftag_mode_lua_bool + { + \sys_if_engine_luatex:T + { + \directlua{uftag.trace.show_all_mc_data(#1)} + } + } } -} \NewDocumentCommand\showtagpdfattributes { } -{ - \bool_if:NT \g__uftag_mode_lua_bool { - \sys_if_engine_luatex:T - { - \directlua + \bool_if:NT \g__uftag_mode_lua_bool { - uftag.trace.log( - "showtagpdfattributes: MC=>abscnt=\__uftag_get_mc_abs_cnt:=>attr=\the\g__uftag_mc_cnt_attr=>tag=" .. - tostring(uftag.func.get_tag_from (\the\g__uftag_mc_type_attr)) .. - "=\the\g__uftag_mc_type_attr",0 - ) + \sys_if_engine_luatex:T + { + \directlua + { + uftag.trace.log( + "showtagpdfattributes: MC=>abscnt=\__uftag_get_mc_abs_cnt:=>attr=\the\g__uftag_mc_cnt_attr=>tag=" .. + tostring(uftag.func.get_tag_from (\the\g__uftag_mc_type_attr)) .. + "=\the\g__uftag_mc_type_attr",0 + ) + } + \ignorespaces + } } - \ignorespaces - } } -} diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua index ca49eb887be..0bd8c1441ca 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua @@ -1,5 +1,5 @@ --- Packageversion: 0.2 --- Packagedate: 2018/07/09 +-- Packageversion: 0.3 +-- Packagedate: 2018/08/06 -- tagpdf.lua -- Ulrike Fischer @@ -213,7 +213,7 @@ function uftag.func.mark_page_elements (box,mcpagecnt,mccntprev,mcopen,name,mcty if uftag.mc[mccnt] then if uftag.mc[mccnt]["artifact"] then uftag.trace.log("THIS IS AN ARTIFACT of type "..tostring(uftag.mc[mccnt]["artifact"]),3) - if uftag.mc[mccnt]["artifact"] == "notype" then + if uftag.mc[mccnt]["artifact"] == "" then box.list = __uftag_insert_bmc_node (box.list,n,"Artifact") else box.list = __uftag_insert_bdc_node (box.list,n,"Artifact", "/Type /"..uftag.mc[mccnt]["artifact"]) @@ -222,7 +222,20 @@ function uftag.func.mark_page_elements (box,mcpagecnt,mccntprev,mcopen,name,mcty uftag.trace.log("THIS IS A TAG "..tostring(tag),3) mcpagecnt = mcpagecnt +1 uftag.trace.log ("INSERT BDC "..mcpagecnt,2) - box.list = __uftag_insert_bdc_node (box.list,n,tag, "/MCID "..mcpagecnt) + local dict= "/MCID "..mcpagecnt + if uftag.mc[mccnt]["raw"] then + uftag.trace.log("RAW CONTENT"..tostring(uftag.mc[mccnt]["raw"]),3) + dict= dict .. " " .. uftag.mc[mccnt]["raw"] + end + if uftag.mc[mccnt]["alt"] then + uftag.trace.log("RAW CONTENT"..tostring(uftag.mc[mccnt]["alt"]),3) + dict= dict .. " " .. uftag.mc[mccnt]["alt"] + end + if uftag.mc[mccnt]["actualtext"] then + uftag.trace.log("RAW CONTENT"..tostring(uftag.mc[mccnt]["actualtext"]),3) + dict= dict .. " " .. uftag.mc[mccnt]["actualtext"] + end + box.list = __uftag_insert_bdc_node (box.list,n,tag, dict) uftag.func.store_mc_kid (mccnt,mcpagecnt,abspage) uftag.func.store_mc_in_page(mccnt,mcpagecnt,abspage) uftag.trace.show_mc_data (mccnt) diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty index 15c87eb3fed..cc91ad5cee1 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty @@ -1,6 +1,6 @@ \RequirePackage{expl3}[2018/06/14] -\ProvidesExplPackage {tagpdf} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf} {2018/08/06} {0.3} {A package to experiment with pdf tagging} % storing internal names to my name space: @@ -34,13 +34,18 @@ \RequirePackage{zref-base,zref-lastpage} \RequirePackage{etoolbox} \RequirePackage{pdfescape} +\RequirePackage{pdftexcmds} + +\RequirePackage{l3str-convert} +\cs_generate_variant:Nn \str_set_convert:Nnnn {Nonn, Noon, Nnon } + %%% absolute page numbers \int_new:N \g__uftag_abspage_int \int_gset:Nn \g__uftag_abspage_int { 0 } -\zref@newlist {tagpdf} +\zref@newlist {uftagzrl} %zrl=zreflist \zref@newprop*{tagabspage} [0] { \int_use:N \g__uftag_abspage_int } -\zref@addprop {tagpdf} {tagabspage} +\zref@addprop {uftagzrl} {tagabspage} %%% tagpdfsetup, @@ -48,7 +53,7 @@ \int_new:N \l__uftag_loglevel_int \tl_new:N \l__uftag_tree_tabs_order_tl -\keys_define:nn { tagpdf-setup } +\keys_define:nn { uftag / setup } { activate-mc .bool_gset:N = \g_uftag_active_mc_bool, activate-tree .bool_gset:N = \g_uftag_active_tree_bool, @@ -69,6 +74,7 @@ tabsorder / column .code:n = {\tl_set:Nn \l__uftag_tree_tabs_order_tl {/Tabs/C}}, tabsorder / structure .code:n = {\tl_set:Nn \l__uftag_tree_tabs_order_tl {/Tabs/S}}, tabsorder / none .code:n = {\tl_set:Nn \l__uftag_tree_tabs_order_tl {}}, + tabsorder .initial:n = structure, compresslevel .choices:nn = {0,1,2,3,4,5,6,7,8,9} { \__uftag_pdfcompresslevel:n {#1} @@ -76,16 +82,31 @@ }, compresslevel .value_required:n = true, uncompress .meta:n = { compresslevel = 0 }, + inputencoding .code:n = + { + \sys_if_engine_pdftex:T + { \tl_gset:Nn \g__uftag_inputencoding_tl { #1 } } + }, } - +% escape commands are a bit engine specific so have been moved to the driver files. % commands to escape strings so that they can be safely used in pdf % currently not much used. But will be needed later, when alt and actualtext are added. % we probably need the equivalent \pdfescapestring, \pdfescapename \pdfescapehex % the commands of pdfescape adds an additional layout to allow for babel shorthands -\cs_set_eq:NN \__uftag_pdf_escape_string:Nn \EdefEscapeString -\cs_set_eq:NN \__uftag_pdf_escape_name:Nn \EdefEscapeName -\cs_set_eq:NN \__uftag_pdf_escape_hex:Nn \EdefEscapeHex +%\cs_set_eq:NN \__uftag_pdf_escape_string:Nn \EdefEscapeString +%\cs_set_eq:NN \__uftag_pdf_escape_name:Nn \EdefEscapeName +%\cs_set_eq:NN \__uftag_pdf_escape_hex:Nn \EdefEscapeHex + +%\cs_set_eq:NN \__uftag_pdf_escape_string:n \EdefEscapeString +%\cs_set_eq:NN \__uftag_pdf_escape_name:Nn \EdefEscapeName + +%escape command. They are driver specific as \pdf@escapehex would ignore most chars +%outside the "pdflatex" range + + + + % a hook for later code and an absolute page counter % should be executed before counters are resetted. @@ -95,7 +116,10 @@ \AtBeginShipout { \__uftag_finish_page_hook: - \__uftag_tree_write_pageattr: + \bool_if:NT\g_uftag_active_tree_bool + { + \__uftag_tree_write_pageattr: + } \int_gincr:N \g__uftag_abspage_int } @@ -141,6 +165,7 @@ \tl_new:N \l__uftag_tmpc_tl \tl_new:N \l__uftag_tmpd_tl \tl_new:N \l__uftag_tmpe_tl +\str_new:N \l__uftag_tmpa_str % helper function to get the propcount. % use as \prop_map_function:NN PROP { \__uftag_prop_count:nn -1 } -- cgit v1.2.3