diff options
author | Karl Berry <karl@freefriends.org> | 2019-03-21 20:54:17 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-03-21 20:54:17 +0000 |
commit | 5dac6ccc074f72d03d874ffcf70ddc2a9b0db096 (patch) | |
tree | 734fb9bc1b5b369899803efdb7886a7563f3677c /Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty | |
parent | fd57fc78450f5089af3e89bdb28023e17ea181fd (diff) |
tagpdf (21mar19)
git-svn-id: svn://tug.org/texlive/trunk@50509 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 | 85 |
1 files changed, 61 insertions, 24 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 5ae1c51f6ec..a59df867b9d 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,10 +1,12 @@ -\ProvidesExplPackage {tagpdf-mc-code-lua} {2019/01/04} {0.50} +\ProvidesExplPackage {tagpdf-mc-code-lua} {2019/03/20} {0.60} {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 +% (new) attributes for mc are local: +% \newattribute \l__uftag_mc_type_attr %the value represent the type +% \newattribute \l__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 @@ -40,6 +42,15 @@ } } +\prg_new_conditional:Nnn \__uftag_mc_if_in: {p,T,F,TF} + { + \int_compare:nNnTF {-2147483647}={\l__uftag_mc_type_attr} + { \prg_return_true: } + { \prg_return_false: } + } + +\prg_new_eq_conditional:NNn \uftag_mc_if_in: \__uftag_mc_if_in: {p,T,F,TF} + % the keys \tl_new:N \l__uftag_mc_key_tag_tl \tl_new:N \l__uftag_mc_key_label_tl @@ -145,31 +156,54 @@ \tex_global:D \setattribute #1 #2 } +\cs_set_protected:Npn \__uftag_attribute_set:Nn #1 #2 + { + \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 +\cs_set_protected:Npn \__uftag_attribute_unset:N #1 { - \__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: } + \unsetattribute #1 } -\cs_generate_variant:Nn\__uftag_mc_lua_gset_mc_type_attr:n { o } -\cs_new:Nn \__uftag_mc_lua_gunset_mc_type_attr: +\cs_new:Nn \__uftag_mc_lua_set_mc_type_attr:n % #1 is a tag name { - \__uftag_attribute_gunset:N \g__uftag_mc_type_attr - \__uftag_attribute_gunset:N \g__uftag_mc_cnt_attr + \__uftag_attribute_set:Nn \l__uftag_mc_type_attr { \directlua {uftag.func.output_num_from ("#1") } } + \__uftag_attribute_set:Nn \l__uftag_mc_cnt_attr { \__uftag_get_mc_abs_cnt: } } +\cs_generate_variant:Nn\__uftag_mc_lua_set_mc_type_attr:n { o } + +\cs_new:Nn \__uftag_mc_lua_unset_mc_type_attr: + { + \__uftag_attribute_unset:N \l__uftag_mc_type_attr + \__uftag_attribute_unset:N \l__uftag_mc_cnt_attr + } + + + %This command will in the finish code replace the dummy for a mc by the real mcid kids +%we need a variant for the case that it is the only kid, to get the array right \cs_new:Nn \__uftag_mc_insert_mcid_kids:n { - \directlua {uftag.func.mc_insert_kids (#1) } + \directlua {uftag.func.mc_insert_kids (#1,0) } } +\cs_new:Nn \__uftag_mc_insert_mcid_single_kids:n + { + \directlua {uftag.func.mc_insert_kids (#1,1) } + } + + +% we need to pass the info if the kids are alone or already in an array +% so we add a second argument, which should == 1 if the kids are single + % puts an mcid absolute number in the current structure \cs_new:Nn \__uftag_mc_handle_stash:n %1 mcidnum @@ -178,7 +212,7 @@ \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} + \__uftag_mc_insert_mcid_kids:n {#1}% } \directlua { @@ -192,17 +226,18 @@ \cs_generate_variant:Nn \__uftag_mc_handle_stash:n { o } -\cs_new:Nn \uftag_mc_begin:n +\cs_new_protected:Nn \uftag_mc_begin:n { - \group_begin: - \__uftag_check_mc_if_nested: - \bool_gset_true:N \g__uftag_in_mc_bool + %\group_begin: + %\__uftag_check_mc_if_nested: + %\bool_gset_true:N \g__uftag_in_mc_bool \int_gincr:N \c@g__uftag_MCID_abs_int + \tl_clear:N\l__uftag_mc_key_properties_tl \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!): - \__uftag_mc_lua_gset_mc_type_attr:o { \l__uftag_mc_key_tag_tl } + %set the attributes: + \__uftag_mc_lua_set_mc_type_attr:o { \l__uftag_mc_key_tag_tl } \bool_if:NF \l__uftag_mc_artifact_bool { % store the absolute num name in a label: \tl_if_empty:NF {\l__uftag_mc_key_label_tl} @@ -215,17 +250,18 @@ \exp_args:Nx \__uftag_mc_handle_stash:n { \__uftag_get_mc_abs_cnt: } } } - \group_end: + %\group_end: } -\cs_new:Nn \uftag_mc_end: +\cs_new_protected: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: + %\__uftag_check_mc_if_open: + %\bool_gset_false:N \g__uftag_in_mc_bool + \__uftag_mc_lua_unset_mc_type_attr: + \tl_set:Nn \l__uftag_mc_key_tag_tl { } } -\cs_new:Nn \uftag_mc_use:n %#1: label name +\cs_new_protected: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 @@ -237,6 +273,7 @@ } } +\cs_new:Nn \__uftag_get_data_mc_tag: { \l__uftag_mc_key_tag_tl } \endinput |