summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-06-30 21:14:14 +0000
committerKarl Berry <karl@freefriends.org>2021-06-30 21:14:14 +0000
commitc604c653358384d71cfbdad75147fe6b3ef448d3 (patch)
treeaaa2eb4dac429b5bb9bdde1d867e88d75612e65d /Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty
parentf52cb629a5dd055df1ae60054f89cc718a5ce58e (diff)
tagpdf (30jun21)
git-svn-id: svn://tug.org/texlive/trunk@59769 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.sty325
1 files changed, 174 insertions, 151 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 21eef042047..e2216c5b0e2 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
@@ -4,9 +4,9 @@
%%
%% The original source files were:
%%
-%% tagpdf-mc.dtx (with options: `luamode')
+%% tagpdf-mc-luacode.dtx (with options: `luamode')
%%
-%% Copyright (C) 2019 Ulrike Fischer
+%% Copyright (C) 2019-2021 Ulrike Fischer
%%
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
@@ -19,18 +19,38 @@
%% and all files in that bundle must be distributed together.
%%
%% File: tagpdf-mc.dtx
-\ProvidesExplPackage {tagpdf-mc-code-lua} {2021-06-14} {0.82}
- {tagpdf - mc code only for the luamode }
-
-
-
-
+\ProvidesExplPackage {tagpdf-mc-code-lua} {2021-06-29} {0.9}
+ {tagpdf - mc code only for the luamode }
\hook_gput_code:nnn{begindocument}{tagpdf/mc}
{
+ \bool_if:NT\g__tag_active_space_bool
+ {
+ \lua_now:e
+ {
+ if~luatexbase.callbacktypes.pre_shipout_filter~then~
+ luatexbase.add_to_callback("pre_shipout_filter", function(TAGBOX)~
+ ltx.__tag.func.space_chars_shipout(TAGBOX)~return~true~
+ end, "tagpdf")~
+ end
+ }
+ \lua_now:e
+ {
+ if~luatexbase.callbacktypes.pre_shipout_filter~then~
+ token.get_next()~
+ end
+ }\@secondoftwo\@gobble
+ {
+ \hook_gput_code:nnn{shipout/before}{tagpdf/lua}
+ {
+ \lua_now:e
+ { ltx.__tag.func.space_chars_shipout (tex.box["ShipoutBox"]) }
+ }
+ }
+ }
\bool_if:NT\g__tag_active_mc_bool
{
- \directlua
+ \lua_now:e
{
if~luatexbase.callbacktypes.pre_shipout_filter~then~
luatexbase.add_to_callback("pre_shipout_filter", function(TAGBOX)~
@@ -38,7 +58,7 @@
end, "tagpdf")~
end
}
- \directlua
+ \lua_now:e
{
if~luatexbase.callbacktypes.pre_shipout_filter~then~
token.get_next()~
@@ -47,32 +67,159 @@
{
\hook_gput_code:nnn{shipout/before}{tagpdf/lua}
{
- \directlua
+ \lua_now:e
{ ltx.__tag.func.mark_shipout (tex.box["ShipoutBox"]) }
}
}
}
}
-
\prg_new_conditional:Nnn \__tag_mc_if_in: {p,T,F,TF}
{
- \int_compare:nNnTF { -2147483647 }={ \l__tag_mc_type_attr }
+ \int_compare:nNnTF
+ { -2147483647 }
+ =
+ {\lua_now:e
+ {
+ tex.print(tex.getattribute(luatexbase.attributes.g__tag_mc_type_attr))
+ }
+ }
{ \prg_return_false: }
{ \prg_return_true: }
}
\prg_new_eq_conditional:NNn \tag_mc_if_in: \__tag_mc_if_in: {p,T,F,TF}
+\cs_new:Nn \__tag_mc_lua_set_mc_type_attr:n % #1 is a tag name
+ {
+ %TODO ltx.__tag.func.get_num_from("#1") seems not to return a suitable number??
+ \tl_set:Nx\l__tag_tmpa_tl{\lua_now:e{ltx.__tag.func.output_num_from ("#1")} }
+ \lua_now:e
+ {
+ tex.setattribute
+ (
+ "global",
+ luatexbase.attributes.g__tag_mc_type_attr,
+ \l__tag_tmpa_tl
+ )
+ }
+ \lua_now:e
+ {
+ tex.setattribute
+ (
+ "global",
+ luatexbase.attributes.g__tag_mc_cnt_attr,
+ \__tag_get_mc_abs_cnt:
+ )
+ }
+ }
+
+\cs_generate_variant:Nn\__tag_mc_lua_set_mc_type_attr:n { o }
+
+\cs_new:Nn \__tag_mc_lua_unset_mc_type_attr:
+ {
+ \lua_now:e
+ {
+ tex.setattribute
+ (
+ "global",
+ luatexbase.attributes.g__tag_mc_type_attr,
+ -2147483647
+ )
+ }
+ \lua_now:e
+ {
+ tex.setattribute
+ (
+ "global",
+ luatexbase.attributes.g__tag_mc_cnt_attr,
+ -2147483647
+ )
+ }
+ }
-\tl_new:N \l__tag_mc_key_tag_tl
-\tl_new:N \l__tag_mc_key_label_tl
-\tl_new:N \l__tag_mc_key_properties_tl
+\cs_new:Nn \__tag_mc_insert_mcid_kids:n
+ {
+ \lua_now:e { ltx.__tag.func.mc_insert_kids (#1,0) }
+ }
+
+\cs_new:Nn \__tag_mc_insert_mcid_single_kids:n
+ {
+ \lua_now:e {ltx.__tag.func.mc_insert_kids (#1,1) }
+ }
+\cs_new:Nn \__tag_mc_handle_stash:n %1 mcidnum
+ {
+ \__tag_check_mc_used:n { #1 }
+ \seq_gput_right:cn % Don't fill a lua table due to the command in the item,
+ % so use the kernel command
+ { g__tag_struct_kids_\g__tag_struct_stack_current_tl _seq }
+ {
+ \__tag_mc_insert_mcid_kids:n {#1}%
+ }
+ \lua_now:e
+ {
+ ltx.__tag.func.store_struct_mcabs
+ (
+ \g__tag_struct_stack_current_tl,#1
+ )
+ }
+ \prop_gput:Nxx
+ \g__tag_mc_parenttree_prop
+ { #1 }
+ { \g__tag_struct_stack_current_tl }
+ }
+
+\cs_generate_variant:Nn \__tag_mc_handle_stash:n { x }
+\cs_new_protected:Nn \tag_mc_begin:n
+ {
+ \__tag_check_if_active_mc:T
+ {
+ \group_begin:
+ %\__tag_check_mc_if_nested:
+ \bool_gset_true:N \g__tag_in_mc_bool
+ \bool_set_false:N\l__tag_mc_artifact_bool
+ \tl_clear:N \l__tag_mc_key_properties_tl
+ \int_gincr:N \c@g__tag_MCID_abs_int
+ \keys_set:nn { __tag / mc }{ label={}, #1 }
+ %check that a tag or artifact has been used
+ \__tag_check_mc_tag:N \l__tag_mc_key_tag_tl
+ %set the attributes:
+ \__tag_mc_lua_set_mc_type_attr:o { \l__tag_mc_key_tag_tl }
+ \bool_if:NF \l__tag_mc_artifact_bool
+ { % store the absolute num name in a label:
+ \tl_if_empty:NF {\l__tag_mc_key_label_tl}
+ {
+ \exp_args:NV
+ \__tag_mc_handle_mc_label:n \l__tag_mc_key_label_tl
+ }
+ % if not stashed record the absolute number
+ \bool_if:NF \l__tag_mc_key_stash_bool
+ {
+ \__tag_mc_handle_stash:x { \__tag_get_mc_abs_cnt: }
+ }
+ }
+ \group_end:
+ }
+ }
+\cs_new_protected:Nn \tag_mc_end:
+ {
+ \__tag_check_if_active_mc:T
+ {
+ %\__tag_check_mc_if_open:
+ \bool_gset_false:N \g__tag_in_mc_bool
+ \bool_set_false:N\l__tag_mc_artifact_bool
+ \__tag_mc_lua_unset_mc_type_attr:
+ \tl_set:Nn \l__tag_mc_key_tag_tl { }
+ \tl_gset:Nn \g__tag_mc_key_tag_tl { }
+ }
+ }
+\cs_new:Npn \__tag_get_data_mc_tag: { \g__tag_mc_key_tag_tl }
\keys_define:nn { __tag / mc }
{
tag .code:n = %
- {%%????????? \pdfescapename??
- \tl_set:Nx \l__tag_mc_key_tag_tl { #1 }
- \directlua
+ {
+ \tl_set:Nx \l__tag_mc_key_tag_tl { #1 }
+ \tl_gset:Nx \g__tag_mc_key_tag_tl { #1 }
+ \lua_now:e
{
ltx.__tag.func.store_mc_data(\__tag_get_mc_abs_cnt:,"tag","#1")
}
@@ -80,7 +227,7 @@
raw .code:n =
{
\tl_put_right:Nx \l__tag_mc_key_properties_tl { #1 }
- \directlua
+ \lua_now:e
{
ltx.__tag.func.store_mc_data(\__tag_get_mc_abs_cnt:,"raw","#1")
}
@@ -94,7 +241,7 @@
{ 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>~ }
- \directlua
+ \lua_now:e
{
ltx.__tag.func.store_mc_data
(
@@ -111,7 +258,7 @@
{ 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>~ }
- \directlua
+ \lua_now:e
{
ltx.__tag.func.store_mc_data
(
@@ -128,7 +275,7 @@
{ 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>~ }
- \directlua
+ \lua_now:e
{
ltx.__tag.func.store_mc_data
(
@@ -145,7 +292,7 @@
{ 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>~ }
- \directlua
+ \lua_now:e
{
ltx.__tag.func.store_mc_data
(
@@ -158,7 +305,7 @@
label .code:n =
{
\tl_set:Nn\l__tag_mc_key_label_tl { #1 }
- \directlua
+ \lua_now:e
{
ltx.__tag.func.store_mc_data
(
@@ -168,7 +315,7 @@
},
__artifact-store .code:n =
{
- \directlua
+ \lua_now:e
{
ltx.__tag.func.store_mc_data
(
@@ -181,7 +328,7 @@
\exp_args:Nnx
\keys_set:nn
{ __tag / mc}
- { artifact-bool, artifact-type=#1, tag=Artifact }
+ { __artifact-bool, __artifact-type=#1, tag=Artifact }
\exp_args:Nnx
\keys_set:nn
{ __tag / mc }
@@ -190,130 +337,6 @@
artifact .default:n = { notype }
}
-
-\cs_set_protected:Npn \__tag_attribute_gset:Nn #1 #2
- {
- \tex_global:D \setattribute #1 #2
- }
-
-\cs_set_protected:Npn \__tag_attribute_set:Nn #1 #2
- {
- \setattribute #1 #2
- }
-
-\cs_set_protected:Npn \__tag_attribute_gunset:N #1
- {
- \tex_global:D \unsetattribute #1
- }
-
-\cs_set_protected:Npn \__tag_attribute_unset:N #1
- {
- \unsetattribute #1
- }
-
-\cs_new:Nn \__tag_mc_lua_set_mc_type_attr:n % #1 is a tag name
- {
- \__tag_attribute_set:Nn \l__tag_mc_type_attr
- {
- \directlua { ltx.__tag.func.output_num_from ("#1") }
- }
- \__tag_attribute_set:Nn \l__tag_mc_cnt_attr { \__tag_get_mc_abs_cnt: }
- }
-
-\cs_generate_variant:Nn\__tag_mc_lua_set_mc_type_attr:n { o }
-
-\cs_new:Nn \__tag_mc_lua_unset_mc_type_attr:
- {
- \__tag_attribute_unset:N \l__tag_mc_type_attr
- \__tag_attribute_unset:N \l__tag_mc_cnt_attr
- }
-
-\cs_new:Nn \__tag_mc_insert_mcid_kids:n
- {
- \directlua { ltx.__tag.func.mc_insert_kids (#1,0) }
- }
-
-\cs_new:Nn \__tag_mc_insert_mcid_single_kids:n
- {
- \directlua {ltx.__tag.func.mc_insert_kids (#1,1) }
- }
-
-
-\cs_new:Nn \__tag_mc_handle_stash:n %1 mcidnum
- {
- \__tag_check_mc_used:n { #1 }
- \seq_gput_right:cn % Don't fill a lua table due to the command in the item,
- % so use the kernel command
- { g__tag_struct_kids_\g__tag_struct_stack_current_tl _seq }
- {
- \__tag_mc_insert_mcid_kids:n {#1}%
- }
- \directlua
- {
- ltx.__tag.func.store_struct_mcabs
- (
- \g__tag_struct_stack_current_tl,#1
- )
- }
- \prop_gput:Nxx
- \g__tag_mc_parenttree_prop
- { #1 }
- { \g__tag_struct_stack_current_tl }
- }
-
-\cs_generate_variant:Nn \__tag_mc_handle_stash:n { o }
-
-\cs_new_protected:Nn \tag_mc_begin:n
- {
- %\group_begin:
- %\__tag_check_mc_if_nested:
- %\bool_gset_true:N \g__tag_in_mc_bool
- \bool_set_false:N\l__tag_mc_artifact_bool
- \int_gincr:N \c@g__tag_MCID_abs_int
- \tl_clear:N \l__tag_mc_key_properties_tl
- \keys_set:nn { __tag / mc }{ label={}, #1 }
- %check that a tag or artifact has been used
- \__tag_check_mc_tag:N \l__tag_mc_key_tag_tl
- %set the attributes:
- \__tag_mc_lua_set_mc_type_attr:o { \l__tag_mc_key_tag_tl }
- \bool_if:NF \l__tag_mc_artifact_bool
- { % store the absolute num name in a label:
- \tl_if_empty:NF {\l__tag_mc_key_label_tl}
- {
- \__tag_mc_handle_mc_label:n { \l__tag_mc_key_label_tl }
- }
- % if not stashed record the absolute number
- \bool_if:NF \l__tag_mc_key_stash_bool
- {
- \exp_args:Nx \__tag_mc_handle_stash:n { \__tag_get_mc_abs_cnt: }
- }
- }
- %\bool_set_false:N\l__tag_mc_artifact_bool
- %\group_end:
- }
-
-\cs_new_protected:Nn \tag_mc_end:
- {
- %\__tag_check_mc_if_open:
- %\bool_gset_false:N \g__tag_in_mc_bool
- \bool_set_false:N\l__tag_mc_artifact_bool
- \__tag_mc_lua_unset_mc_type_attr:
- \tl_set:Nn \l__tag_mc_key_tag_tl { }
- }
-
-\cs_new_protected:Nn \tag_mc_use:n %#1: label name
- {
- \tl_set:Nx \l_tmpa_tl { \__tag_ref_value:enn{tagpdf-#1}{tagmcabs}{} }
- \tl_if_empty:NTF\l_tmpa_tl
- {
- \msg_warning:nnn {tag} {mc-label-unknown} { #1 }
- }
- {
- \__tag_mc_handle_stash:o { \l_tmpa_tl }
- }
- }
-
-\cs_new:Nn \__tag_get_data_mc_tag: { \l__tag_mc_key_tag_tl }
%%
%%
%% End of file `tagpdf-mc-code-lua.sty'.