diff options
author | Karl Berry <karl@freefriends.org> | 2018-08-07 22:06:23 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-08-07 22:06:23 +0000 |
commit | 706448acbd096e1a59cb987e8352abdd43624ebe (patch) | |
tree | b15d896ae27ff72a04f6ffcdc9ed0fc2ccdc689b /Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty | |
parent | 23fec857e8f705b5595264d42d1265077d09654d (diff) |
tagpdf (7aug18)
git-svn-id: svn://tug.org/texlive/trunk@48366 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty | 182 |
1 files changed, 126 insertions, 56 deletions
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 } |