summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-01-13 21:05:40 +0000
committerKarl Berry <karl@freefriends.org>2022-01-13 21:05:40 +0000
commitd8a708abc1ed023e582f732ac87e906bba4d884c (patch)
tree3212c9992cf00ad728c8dceb83f414377b6fcebf /Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
parent031d7dac6f41c0c635cb8e8fa08cf794a1cc80c1 (diff)
tagpdf (13jan22)
git-svn-id: svn://tug.org/texlive/trunk@61600 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty')
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty955
1 files changed, 532 insertions, 423 deletions
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
index 83a173ba6de..822b654d92a 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
@@ -6,15 +6,15 @@
%%
%% tagpdf.dtx (with options: `package')
%% tagpdf-checks.dtx (with options: `package')
-%% tagpdf-user.dtx (with options: `package')
%% tagpdf-mc-shared.dtx (with options: `shared')
%% tagpdf.dtx (with options: `mcloading')
%% tagpdf-tree.dtx (with options: `package')
%% tagpdf-roles.dtx (with options: `package')
%% tagpdf-struct.dtx (with options: `package')
%% tagpdf-space.dtx (with options: `package')
+%% tagpdf-user.dtx (with options: `package')
%%
-%% Copyright (C) 2019-2021 Ulrike Fischer
+%% Copyright (C) 2019-2022 Ulrike Fischer
%%
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
@@ -27,7 +27,7 @@
%% and all files in that bundle must be distributed together.
%%
%% File: tagpdf.dtx
-\ProvidesExplPackage {tagpdf} {2021-08-27} {0.92}
+\ProvidesExplPackage {tagpdf} {2022-01-13} {0.93}
{ A package to experiment with pdf tagging }
\bool_if:nF
@@ -49,10 +49,7 @@
before~\string\documentclass
}
}
-\prop_if_exist:NT \g_msg_module_name_prop
- {
- \prop_gput:Nnn \g_msg_module_name_prop { tag }{ tagpdf }
- }
+\prop_gput:Nnn \g_msg_module_name_prop { tag }{ tagpdf }
\bool_new:N\g__tag_mode_lua_bool
\DeclareOption {luamode} { \sys_if_engine_luatex:T { \bool_gset_true:N \g__tag_mode_lua_bool } }
\DeclareOption {genericmode}{ \bool_gset_false:N\g__tag_mode_lua_bool }
@@ -111,6 +108,8 @@
\bool_new:N \g__tag_active_mc_bool
\bool_new:N \g__tag_active_tree_bool
\bool_new:N \g__tag_active_struct_bool
+\bool_new:N \g__tag_active_struct_dest_bool
+\bool_gset_true:N \g__tag_active_struct_dest_bool
\bool_new:N \l__tag_active_mc_bool
\bool_set_true:N \l__tag_active_mc_bool
@@ -190,7 +189,9 @@
activate-tree .bool_gset:N = \g__tag_active_tree_bool,
activate-struct .bool_gset:N = \g__tag_active_struct_bool,
activate-all .meta:n =
- {activate-mc,activate-tree,activate-struct},
+ {activate-mc={#1},activate-tree={#1},activate-struct={#1}},
+ activate-all .default:n = true,
+ no-struct-dest .bool_gset_inverse:N = \g__tag_active_struct_dest_bool,
% \end{macrocode}
log .choice:,
log / none .code:n = {\int_set:Nn \l__tag_loglevel_int { 0 }},
@@ -221,7 +222,6 @@
\file_input:n {tagpdf-luatex.def}
}
%% File: tagpdf-checks.dtx
-
\msg_new:nnn { tag } {mc-nested} { nested~marked~content~found~-~mcid~#1 }
\msg_new:nnn { tag } {mc-tag-missing} { required~tag~missing~-~mcid~#1 }
\msg_new:nnn { tag } {mc-label-unknown}
@@ -490,401 +490,6 @@
{ \prg_return_true: }
{ \prg_return_false: }
}
-%% File: tagpdf-user.dtx
-
-
-\NewDocumentCommand \tagpdfsetup { m }
- {
- \keys_set:nn { __tag / setup } { #1 }
- }
-
-\NewDocumentCommand \tagmcbegin { m }
- {
- \tag_mc_begin:n {#1}%\ignorespaces
- }
-
-\NewDocumentCommand \tagmcend { }
- {
- %\if_mode_horizontal: \unskip \fi: %
- \tag_mc_end:
- }
-
-\NewDocumentCommand \tagmcuse { m }
- {
- \tag_mc_use:n {#1}
- }
-
-
-\NewDocumentCommand \tagmcifinTF { m m }
- {
- \tag_mc_if_in:TF { #1 } { #2 }
- }
-\NewDocumentCommand \tagstructbegin { m }
- {
- \tag_struct_begin:n {#1}
- }
-
-\NewDocumentCommand \tagstructend { }
- {
- \tag_struct_end:
- }
-
-\NewDocumentCommand \tagstructuse { m }
- {
- \tag_struct_use:n {#1}
- }
-\cs_set_eq:NN\tagpdfifluatexTF \sys_if_engine_luatex:TF
-\cs_set_eq:NN\tagpdfifluatexT \sys_if_engine_luatex:T
-\cs_set_eq:NN\tagpdfifpdftexT \sys_if_engine_pdftex:T
-\NewDocumentCommand\ShowTagging { m }
- {
- \keys_set:nn { __tag / show }{ #1}
-
- }
-\keys_define:nn { __tag / show }
- {
- mc-data .code:n =
- {
- \sys_if_engine_luatex:T
- {
- \lua_now:e{ltx.__tag.trace.show_all_mc_data(#1,\__tag_get_mc_abs_cnt:,0)}
- }
- }
- ,mc-data .default:n = 1
- }
-
-\keys_define:nn { __tag / show }
- { mc-current .code:n =
- {
- \bool_if:NTF \g__tag_mode_lua_bool
- {
- \sys_if_engine_luatex:T
- {
- \int_compare:nNnTF
- { -2147483647 }
- =
- {
- \lua_now:e
- {
- tex.print
- (tex.getattribute
- (luatexbase.attributes.g__tag_mc_cnt_attr))
- }
- }
- {
- \lua_now:e
- {
- ltx.__tag.trace.log
- (
- "mc-current:~no~MC~open,~current~abscnt
- =\__tag_get_mc_abs_cnt:"
- ,0
- )
- texio.write_nl("")
- }
- }
- {
- \lua_now:e
- {
- ltx.__tag.trace.log
- (
- "mc-current:~abscnt=\__tag_get_mc_abs_cnt:=="
- ..
- tex.getattribute(luatexbase.attributes.g__tag_mc_cnt_attr)
- ..
- "~=>tag="
- ..
- tostring
- (ltx.__tag.func.get_tag_from
- (tex.getattribute
- (luatexbase.attributes.g__tag_mc_type_attr)))
- ..
- "="
- ..
- tex.getattribute
- (luatexbase.attributes.g__tag_mc_type_attr)
- ,0
- )
- texio.write_nl("")
- }
- }
- }
- }
- {
- \msg_note:nn{ tag }{ mc-current }
- }
- }
- }
-\keys_define:nn { __tag / show }
- {
- mc-marks .choice: ,
- mc-marks / show .code:n =
- {
- \__tag_mc_get_marks:
- \__tag_check_if_mc_in_galley:TF
- {
- \iow_term:n {Marks~from~this~page:~}
- }
- {
- \iow_term:n {Marks~from~a~previous~page:~}
- }
- \seq_show:N \l__tag_mc_firstmarks_seq
- \seq_show:N \l__tag_mc_botmarks_seq
- \__tag_check_if_mc_tmb_missing:T
- {
- \iow_term:n {BDC~missing~on~this~page!}
- }
- \__tag_check_if_mc_tme_missing:T
- {
- \iow_term:n {EMC~missing~on~this~page!}
- }
- },
- mc-marks / use .code:n =
- {
- \__tag_mc_get_marks:
- \__tag_check_if_mc_in_galley:TF
- { Marks~from~this~page:~}
- { Marks~from~a~previous~page:~}
- \seq_use:Nn \l__tag_mc_firstmarks_seq {,~}\quad
- \seq_use:Nn \l__tag_mc_botmarks_seq {,~}\quad
- \__tag_check_if_mc_tmb_missing:T
- {
- BDC~missing~
- }
- \__tag_check_if_mc_tme_missing:T
- {
- EMC~missing
- }
- },
- mc-marks .default:n = show
- }
-\keys_define:nn { __tag / show }
- {
- struct-stack .choice:
- ,struct-stack / log .code:n = \seq_log:N \g__tag_struct_tag_stack_seq
- ,struct-stack / show .code:n = \seq_show:N \g__tag_struct_tag_stack_seq
- ,struct-stack .default:n = show
- }
-\cs_new_protected:Npn \__tag_add_document_structure:n #1
- {
- \hook_gput_code:nnn{begindocument}{tagpdf}{\tagstructbegin{tag=#1}}
- \hook_gput_code:nnn{tagpdf/finish/before}{tagpdf}{\tagstructend}
- }
-\keys_define:nn { __tag / setup}
- {
- activate .code:n =
- {
- \keys_set:nn { __tag / setup }
- { activate-mc,activate-tree,activate-struct }
- \__tag_add_document_structure:n {#1}
- },
- activate .default:n = Document
- }
-\sys_if_engine_luatex:T
- {
- \NewDocumentCommand\pdffakespace { }
- {
- \__tag_fakespace:
- }
- }
-\bool_new:N \l__tag_para_bool
-\bool_new:N \l__tag_para_show_bool
-\int_new:N \g__tag_para_begin_int
-\int_new:N \g__tag_para_end_int
-\keys_define:nn { __tag / setup }
- {
- paratagging .bool_set:N = \l__tag_para_bool,
- paratagging-show .bool_set:N = \l__tag_para_show_bool,
- }
-
-\AddToHook{para/begin}
- {
- \bool_if:NT \l__tag_para_bool
- {
- \int_gincr:N \g__tag_para_begin_int
- \tag_struct_begin:n {tag=P}
- \bool_if:NT \l__tag_para_show_bool
- { \tag_mc_begin:n{artifact}
- \llap{\color_select:n{red}\tiny\int_use:N\g__tag_para_begin_int\ }
- \tag_mc_end:
- }
- \tag_mc_begin:n {tag=P}
- }
- }
-\AddToHook{para/end}
- {
- \bool_if:NT \l__tag_para_bool
- {
- \int_gincr:N \g__tag_para_end_int
- \tag_mc_end:
- \bool_if:NT \l__tag_para_show_bool
- { \tag_mc_begin:n{artifact}
- \rlap{\color_select:n{red}\tiny\ \int_use:N\g__tag_para_end_int}
- \tag_mc_end:
- }
- \tag_struct_end:
- }
- }
-\AddToHook{enddocument/info}
- {
- \int_compare:nNnF {\g__tag_para_begin_int}={\g__tag_para_end_int}
- {
- \msg_error:nnxx
- {tag}
- {para-hook-count-wrong}
- {\int_use:N\g__tag_para_begin_int}
- {\int_use:N\g__tag_para_end_int}
- }
- }
-\AddToHook{begindocument/before}
- {
- \bool_if:NF \g__tag_mode_lua_bool
- {
- \cs_if_exist:NT \@kernel@before@footins
- {
- \tl_put_right:Nn \@kernel@before@footins
- { \__tag_add_missing_mcs_to_stream:Nn \footins {footnote} }
- \tl_put_right:Nn \@kernel@before@cclv
- {
- \__tag_check_typeout_v:n {====>~In~\token_to_str:N \@makecol\c_space_tl\the\c@page}
- \__tag_add_missing_mcs_to_stream:Nn \@cclv {main}
- }
- \tl_put_right:Nn \@mult@ptagging@hook
- {
- \__tag_check_typeout_v:n {====>~In~\string\page@sofar}
- \process@cols\mult@gfirstbox
- {
- \__tag_add_missing_mcs_to_stream:Nn \count@ {multicol}
- }
- \__tag_add_missing_mcs_to_stream:Nn \mult@rightbox {multicol}
- }
- }
- }
- }
-\newcommand\tagpdfparaOn {\bool_set_true:N \l__tag_para_bool}
-\newcommand\tagpdfparaOff{\bool_set_false:N \l__tag_para_bool}
-\NewDocumentCommand\tagpdfsuppressmarks{m}
- {{\use:c{__tag_mc_disable_marks:} #1}}
-\cs_new_protected:Npn\__tag_hook_kernel_before_head:{}
-\cs_new_protected:Npn\__tag_hook_kernel_after_head:{}
-\cs_new_protected:Npn\__tag_hook_kernel_before_foot:{}
-\cs_new_protected:Npn\__tag_hook_kernel_after_foot:{}
-
-\AddToHook{begindocument}
- {
- \cs_if_exist:NT \@kernel@before@head
- {
- \tl_put_right:Nn \@kernel@before@head {\__tag_hook_kernel_before_head:}
- \tl_put_left:Nn \@kernel@after@head {\__tag_hook_kernel_after_head:}
- \tl_put_right:Nn \@kernel@before@foot {\__tag_hook_kernel_before_foot:}
- \tl_put_left:Nn \@kernel@after@foot {\__tag_hook_kernel_after_foot:}
- }
- }
-
-\bool_new:N \g__tag_saved_in_mc_bool
-\cs_new_protected:Npn \__tag_exclude_headfoot_begin:
- {
- \bool_set_false:N \l__tag_para_bool
- \bool_if:NTF \g__tag_mode_lua_bool
- {
- \tag_mc_end_push:
- }
- {
- \bool_gset_eq:NN \g__tag_saved_in_mc_bool \g__tag_in_mc_bool
- \bool_gset_false:N \g__tag_in_mc_bool
- }
- \tag_mc_begin:n {artifact}
- }
-\cs_new_protected:Npn \__tag_exclude_headfoot_end:
- {
- \tag_mc_end:
- \bool_if:NTF \g__tag_mode_lua_bool
- {
- \tag_mc_begin_pop:n{}
- }
- {
- \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_saved_in_mc_bool
- }
- }
-
-\keys_define:nn { __tag / setup }
- {
- exclude-header-footer .choice:,
- exclude-header-footer / true .code:n =
- {
- \cs_set_eq:NN \__tag_hook_kernel_before_head: \__tag_exclude_headfoot_begin:
- \cs_set_eq:NN \__tag_hook_kernel_before_foot: \__tag_exclude_headfoot_begin:
- \cs_set_eq:NN \__tag_hook_kernel_after_head: \__tag_exclude_headfoot_end:
- \cs_set_eq:NN \__tag_hook_kernel_after_foot: \__tag_exclude_headfoot_end:
- },
- exclude-header-footer / false .code:n =
- {
- \cs_set_eq:NN \__tag_hook_kernel_before_head: \prg_do_nothing:
- \cs_set_eq:NN \__tag_hook_kernel_before_foot: \prg_do_nothing:
- \cs_set_eq:NN \__tag_hook_kernel_after_head: \prg_do_nothing:
- \cs_set_eq:NN \__tag_hook_kernel_after_foot: \prg_do_nothing:
- },
- exclude-header-footer .default:n = true,
- exclude-header-footer .initial:n = true
- }
-
-\hook_gput_code:nnn
- {pdfannot/link/URI/before}
- {tagpdf}
- {
- \tag_mc_end_push:
- \tag_struct_begin:n { tag=Link }
- \tag_mc_begin:n { tag=Link }
- \pdfannot_dict_put:nnx
- { link/URI }
- { StructParent }
- { \tag_struct_parent_int: }
- }
-
-\hook_gput_code:nnn
- {pdfannot/link/URI/after}
- {tagpdf}
- {
- \tag_struct_insert_annot:xx {\pdfannot_link_ref_last:}{\tag_struct_parent_int:}
- \tag_mc_end:
- \tag_struct_end:
- \tag_mc_begin_pop:n{}
- }
-
-\hook_gput_code:nnn
- {pdfannot/link/GoTo/before}
- {tagpdf}
- {
- \tag_mc_end_push:
- \tag_struct_begin:n{tag=Link}
- \tag_mc_begin:n{tag=Link}
- \pdfannot_dict_put:nnx
- { link/GoTo }
- { StructParent }
- { \tag_struct_parent_int: }
- }
-
-\hook_gput_code:nnn
- {pdfannot/link/GoTo/after}
- {tagpdf}
- {
- \tag_struct_insert_annot:xx {\pdfannot_link_ref_last:}{\tag_struct_parent_int:}
- \tag_mc_end:
- \tag_struct_end:
- \tag_mc_begin_pop:n{}
-
- }
-
-\pdfannot_dict_put:nnn
- { link/URI }
- { Contents }
- { (url) }
-
-\pdfannot_dict_put:nnn
- { link/GoTo }
- { Contents }
- { (ref) }
-
%% File: tagpdf-mc.dtx
\newcounter { g__tag_MCID_abs_int }
@@ -1775,7 +1380,8 @@
ParentTreeNextKey, % optional
RoleMap,
ClassMap,
- Namespaces
+ Namespaces,
+ AF %pdf 2.0
}
\seq_const_from_clist:Nn \c__tag_struct_StructElem_entries_seq
@@ -2144,16 +1750,42 @@
{ <\l__tag_tmpa_str> }
},
}
+\cs_new_protected:Npn \__tag_struct_add_AF:nn #1 #2 % #1 struct num #2 object name
+ {
+ \tl_if_exist:cTF
+ {
+ g__tag_struct_#1_AF_tl
+ }
+ {
+ \tl_gput_right:cx
+ { g__tag_struct_#1_AF_tl }
+ { ~ \pdf_object_ref:n {#2} }
+ }
+ {
+ \tl_new:c
+ { g__tag_struct_#1_AF_tl }
+ \tl_gset:cx
+ { g__tag_struct_#1_AF_tl }
+ { \pdf_object_ref:n {#2} }
+ }
+ }
+\cs_generate_variant:Nn \__tag_struct_add_AF:nn {en,ee}
\keys_define:nn { __tag / struct }
{
AF .code:n = % AF property
{
\pdf_object_if_exist:nTF {#1}
{
+ \__tag_struct_add_AF:en { \int_eval:n {\c@g__tag_struct_abs_int} }{#1}
\__tag_prop_gput:cnx
{ g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_prop }
{ AF }
- { \pdf_object_ref:n {#1} }
+ {
+ [
+ \tl_use:c
+ { g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_AF_tl }
+ ]
+ }
}
{
@@ -2163,16 +1795,24 @@
{
\group_begin:
\pdf_object_if_exist:eF {__tag/fileobj\int_use:N\c@g__tag_struct_abs_int}
- {
- \pdffile_embed_stream:nxx
- {#1}
- {tag-AFfile\int_use:N\c@g__tag_struct_abs_int.txt}
- {__tag/fileobj\int_use:N\c@g__tag_struct_abs_int}
- }
- \__tag_prop_gput:cnx
- { g__tag_struct_\int_use:N\c@g__tag_struct_abs_int _prop }
- { AF }
- { \pdf_object_ref:e {__tag/fileobj\int_use:N\c@g__tag_struct_abs_int } }
+ {
+ \pdffile_embed_stream:nxx
+ {#1}
+ {tag-AFfile\int_use:N\c@g__tag_struct_abs_int.txt}
+ {__tag/fileobj\int_use:N\c@g__tag_struct_abs_int}
+ \__tag_struct_add_AF:ee
+ { \int_eval:n {\c@g__tag_struct_abs_int} }
+ { __tag/fileobj\int_use:N\c@g__tag_struct_abs_int }
+ \__tag_prop_gput:cnx
+ { g__tag_struct_\int_use:N\c@g__tag_struct_abs_int _prop }
+ { AF }
+ {
+ [
+ \tl_use:c
+ { g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_AF_tl }
+ ]
+ }
+ }
\group_end:
}
,AFinline-o .code:n =
@@ -2184,17 +1824,47 @@
{#1}
{tag-AFfile\int_use:N\c@g__tag_struct_abs_int.txt}
{__tag/fileobj\int_use:N\c@g__tag_struct_abs_int}
+ \__tag_struct_add_AF:ee
+ { \int_eval:n {\c@g__tag_struct_abs_int} }
+ { __tag/fileobj\int_use:N\c@g__tag_struct_abs_int }
+ \__tag_prop_gput:cnx
+ { g__tag_struct_\int_use:N\c@g__tag_struct_abs_int _prop }
+ { AF }
+ {
+ [
+ \tl_use:c
+ { g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_AF_tl }
+ ]
+ }
}
- \__tag_prop_gput:cnx
- { g__tag_struct_\int_use:N\c@g__tag_struct_abs_int _prop }
- { AF }
- { \pdf_object_ref:e {__tag/fileobj\int_use:N\c@g__tag_struct_abs_int } }
\group_end:
}
}
+\keys_define:nn { __tag / setup }
+ {
+ root-AF .code:n =
+ {
+ \pdf_object_if_exist:nTF {#1}
+ {
+ \__tag_struct_add_AF:en { 0 }{#1}
+ \__tag_prop_gput:cnx
+ { g__tag_struct_0_prop }
+ { AF }
+ {
+ [
+ \tl_use:c
+ { g__tag_struct_0_AF_tl }
+ ]
+ }
+ }
+ {
+
+ }
+ },
+ }
\cs_new_protected:Npn \tag_struct_begin:n #1 %#1 key-val
{
- \__tag_check_if_active_struct:T
+\__tag_check_if_active_struct:T
{
\group_begin:
\int_gincr:N \c@g__tag_struct_abs_int
@@ -2250,12 +1920,11 @@
\group_end:
}
}
-
\cs_new_protected:Nn \tag_struct_end:
{ %take the current structure num from the stack:
%the objects are written later, lua mode hasn't all needed info yet
%\seq_show:N \g__tag_struct_stack_seq
- \__tag_check_if_active_struct:T
+\__tag_check_if_active_struct:T
{
\seq_gpop:NN \g__tag_struct_tag_stack_seq \l__tag_tmpa_tl
\seq_gpop:NNTF \g__tag_struct_stack_seq \l__tag_tmpa_tl
@@ -2482,6 +2151,446 @@
\group_end:
}
}
+%% File: tagpdf-user.dtx
+
+
+\NewDocumentCommand \tagpdfsetup { m }
+ {
+ \keys_set:nn { __tag / setup } { #1 }
+ }
+
+\NewDocumentCommand \tagmcbegin { m }
+ {
+ \tag_mc_begin:n {#1}%\ignorespaces
+ }
+
+\NewDocumentCommand \tagmcend { }
+ {
+ %\if_mode_horizontal: \unskip \fi: %
+ \tag_mc_end:
+ }
+
+\NewDocumentCommand \tagmcuse { m }
+ {
+ \tag_mc_use:n {#1}
+ }
+
+
+\NewDocumentCommand \tagmcifinTF { m m }
+ {
+ \tag_mc_if_in:TF { #1 } { #2 }
+ }
+\NewDocumentCommand \tagstructbegin { m }
+ {
+ \tag_struct_begin:n {#1}
+ }
+
+\NewDocumentCommand \tagstructend { }
+ {
+ \tag_struct_end:
+ }
+
+\NewDocumentCommand \tagstructuse { m }
+ {
+ \tag_struct_use:n {#1}
+ }
+\NewDocumentCommand\ShowTagging { m }
+ {
+ \keys_set:nn { __tag / show }{ #1}
+
+ }
+\keys_define:nn { __tag / show }
+ {
+ mc-data .code:n =
+ {
+ \sys_if_engine_luatex:T
+ {
+ \lua_now:e{ltx.__tag.trace.show_all_mc_data(#1,\__tag_get_mc_abs_cnt:,0)}
+ }
+ }
+ ,mc-data .default:n = 1
+ }
+
+\keys_define:nn { __tag / show }
+ { mc-current .code:n =
+ {
+ \bool_if:NTF \g__tag_mode_lua_bool
+ {
+ \sys_if_engine_luatex:T
+ {
+ \int_compare:nNnTF
+ { -2147483647 }
+ =
+ {
+ \lua_now:e
+ {
+ tex.print
+ (tex.getattribute
+ (luatexbase.attributes.g__tag_mc_cnt_attr))
+ }
+ }
+ {
+ \lua_now:e
+ {
+ ltx.__tag.trace.log
+ (
+ "mc-current:~no~MC~open,~current~abscnt
+ =\__tag_get_mc_abs_cnt:"
+ ,0
+ )
+ texio.write_nl("")
+ }
+ }
+ {
+ \lua_now:e
+ {
+ ltx.__tag.trace.log
+ (
+ "mc-current:~abscnt=\__tag_get_mc_abs_cnt:=="
+ ..
+ tex.getattribute(luatexbase.attributes.g__tag_mc_cnt_attr)
+ ..
+ "~=>tag="
+ ..
+ tostring
+ (ltx.__tag.func.get_tag_from
+ (tex.getattribute
+ (luatexbase.attributes.g__tag_mc_type_attr)))
+ ..
+ "="
+ ..
+ tex.getattribute
+ (luatexbase.attributes.g__tag_mc_type_attr)
+ ,0
+ )
+ texio.write_nl("")
+ }
+ }
+ }
+ }
+ {
+ \msg_note:nn{ tag }{ mc-current }
+ }
+ }
+ }
+\keys_define:nn { __tag / show }
+ {
+ mc-marks .choice: ,
+ mc-marks / show .code:n =
+ {
+ \__tag_mc_get_marks:
+ \__tag_check_if_mc_in_galley:TF
+ {
+ \iow_term:n {Marks~from~this~page:~}
+ }
+ {
+ \iow_term:n {Marks~from~a~previous~page:~}
+ }
+ \seq_show:N \l__tag_mc_firstmarks_seq
+ \seq_show:N \l__tag_mc_botmarks_seq
+ \__tag_check_if_mc_tmb_missing:T
+ {
+ \iow_term:n {BDC~missing~on~this~page!}
+ }
+ \__tag_check_if_mc_tme_missing:T
+ {
+ \iow_term:n {EMC~missing~on~this~page!}
+ }
+ },
+ mc-marks / use .code:n =
+ {
+ \__tag_mc_get_marks:
+ \__tag_check_if_mc_in_galley:TF
+ { Marks~from~this~page:~}
+ { Marks~from~a~previous~page:~}
+ \seq_use:Nn \l__tag_mc_firstmarks_seq {,~}\quad
+ \seq_use:Nn \l__tag_mc_botmarks_seq {,~}\quad
+ \__tag_check_if_mc_tmb_missing:T
+ {
+ BDC~missing~
+ }
+ \__tag_check_if_mc_tme_missing:T
+ {
+ EMC~missing
+ }
+ },
+ mc-marks .default:n = show
+ }
+\keys_define:nn { __tag / show }
+ {
+ struct-stack .choice:
+ ,struct-stack / log .code:n = \seq_log:N \g__tag_struct_tag_stack_seq
+ ,struct-stack / show .code:n = \seq_show:N \g__tag_struct_tag_stack_seq
+ ,struct-stack .default:n = show
+ }
+\cs_new_protected:Npn \__tag_add_document_structure:n #1
+ {
+ \hook_gput_code:nnn{begindocument}{tagpdf}{\tagstructbegin{tag=#1}}
+ \hook_gput_code:nnn{tagpdf/finish/before}{tagpdf}{\tagstructend}
+ }
+\keys_define:nn { __tag / setup}
+ {
+ activate .code:n =
+ {
+ \keys_set:nn { __tag / setup }
+ { activate-mc,activate-tree,activate-struct }
+ \__tag_add_document_structure:n {#1}
+ },
+ activate .default:n = Document
+ }
+\AddToHook{begindocument/before}
+ {
+ \bool_lazy_all:nT
+ {
+ { \g__tag_active_struct_dest_bool }
+ { \g__tag_active_struct_bool }
+ { \cs_if_exist_p:N \pdf_activate_structure_destination: }
+ { ! \pdf_version_compare_p:Nn < {2.0} }
+ }
+ {
+ \tl_set:Nn \l_pdf_current_structure_destination_tl { __tag/struct/\g__tag_struct_stack_current_tl }
+ \pdf_activate_structure_destination:
+ }
+ }
+
+\sys_if_engine_luatex:T
+ {
+ \NewDocumentCommand\pdffakespace { }
+ {
+ \__tag_fakespace:
+ }
+ }
+\bool_new:N \l__tag_para_bool
+\bool_new:N \l__tag_para_show_bool
+\int_new:N \g__tag_para_begin_int
+\int_new:N \g__tag_para_end_int
+\keys_define:nn { __tag / setup }
+ {
+ paratagging .bool_set:N = \l__tag_para_bool,
+ paratagging-show .bool_set:N = \l__tag_para_show_bool,
+ }
+
+\AddToHook{para/begin}
+ {
+ \bool_if:NT \l__tag_para_bool
+ {
+ \int_gincr:N \g__tag_para_begin_int
+ \tag_struct_begin:n {tag=P}
+ \bool_if:NT \l__tag_para_show_bool
+ { \tag_mc_begin:n{artifact}
+ \llap{\color_select:n{red}\tiny\int_use:N\g__tag_para_begin_int\ }
+ \tag_mc_end:
+ }
+ \tag_mc_begin:n {tag=P}
+ }
+ }
+\AddToHook{para/end}
+ {
+ \bool_if:NT \l__tag_para_bool
+ {
+ \int_gincr:N \g__tag_para_end_int
+ \tag_mc_end:
+ \bool_if:NT \l__tag_para_show_bool
+ { \tag_mc_begin:n{artifact}
+ \rlap{\color_select:n{red}\tiny\ \int_use:N\g__tag_para_end_int}
+ \tag_mc_end:
+ }
+ \tag_struct_end:
+ }
+ }
+\AddToHook{enddocument/info}
+ {
+ \int_compare:nNnF {\g__tag_para_begin_int}={\g__tag_para_end_int}
+ {
+ \msg_error:nnxx
+ {tag}
+ {para-hook-count-wrong}
+ {\int_use:N\g__tag_para_begin_int}
+ {\int_use:N\g__tag_para_end_int}
+ }
+ }
+\AddToHook{begindocument/before}
+ {
+ \bool_if:NF \g__tag_mode_lua_bool
+ {
+ \cs_if_exist:NT \@kernel@before@footins
+ {
+ \tl_put_right:Nn \@kernel@before@footins
+ { \__tag_add_missing_mcs_to_stream:Nn \footins {footnote} }
+ \tl_put_right:Nn \@kernel@before@cclv
+ {
+ \__tag_check_typeout_v:n {====>~In~\token_to_str:N \@makecol\c_space_tl\the\c@page}
+ \__tag_add_missing_mcs_to_stream:Nn \@cclv {main}
+ }
+ \tl_put_right:Nn \@mult@ptagging@hook
+ {
+ \__tag_check_typeout_v:n {====>~In~\string\page@sofar}
+ \process@cols\mult@firstbox
+ {
+ \__tag_add_missing_mcs_to_stream:Nn \count@ {multicol}
+ }
+ \__tag_add_missing_mcs_to_stream:Nn \mult@rightbox {multicol}
+ }
+ }
+ }
+ }
+\newcommand\tagpdfparaOn {\bool_set_true:N \l__tag_para_bool}
+\newcommand\tagpdfparaOff{\bool_set_false:N \l__tag_para_bool}
+\NewDocumentCommand\tagpdfsuppressmarks{m}
+ {{\use:c{__tag_mc_disable_marks:} #1}}
+\cs_new_protected:Npn\__tag_hook_kernel_before_head:{}
+\cs_new_protected:Npn\__tag_hook_kernel_after_head:{}
+\cs_new_protected:Npn\__tag_hook_kernel_before_foot:{}
+\cs_new_protected:Npn\__tag_hook_kernel_after_foot:{}
+
+\AddToHook{begindocument}
+ {
+ \cs_if_exist:NT \@kernel@before@head
+ {
+ \tl_put_right:Nn \@kernel@before@head {\__tag_hook_kernel_before_head:}
+ \tl_put_left:Nn \@kernel@after@head {\__tag_hook_kernel_after_head:}
+ \tl_put_right:Nn \@kernel@before@foot {\__tag_hook_kernel_before_foot:}
+ \tl_put_left:Nn \@kernel@after@foot {\__tag_hook_kernel_after_foot:}
+ }
+ }
+
+\bool_new:N \g__tag_saved_in_mc_bool
+\cs_new_protected:Npn \__tag_exclude_headfoot_begin:
+ {
+ \bool_set_false:N \l__tag_para_bool
+ \bool_if:NTF \g__tag_mode_lua_bool
+ {
+ \tag_mc_end_push:
+ }
+ {
+ \bool_gset_eq:NN \g__tag_saved_in_mc_bool \g__tag_in_mc_bool
+ \bool_gset_false:N \g__tag_in_mc_bool
+ }
+ \tag_mc_begin:n {artifact}
+ }
+\cs_new_protected:Npn \__tag_exclude_headfoot_end:
+ {
+ \tag_mc_end:
+ \bool_if:NTF \g__tag_mode_lua_bool
+ {
+ \tag_mc_begin_pop:n{}
+ }
+ {
+ \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_saved_in_mc_bool
+ }
+ }
+\__tag_attr_new_entry:nn {__tag/attr/pagination}{/O/Artifact/Type/Pagination}
+\cs_new_protected:Npn \__tag_exclude_struct_headfoot_begin:n #1
+ {
+ \bool_set_false:N \l__tag_para_bool
+ \bool_if:NTF \g__tag_mode_lua_bool
+ {
+ \tag_mc_end_push:
+ }
+ {
+ \bool_gset_eq:NN \g__tag_saved_in_mc_bool \g__tag_in_mc_bool
+ \bool_gset_false:N \g__tag_in_mc_bool
+ }
+ \tag_struct_begin:n{tag=Artifact,attribute-class=__tag/attr/#1}
+ \tag_mc_begin:n {artifact=#1}
+ }
+
+\cs_new_protected:Npn \__tag_exclude_struct_headfoot_end:
+ {
+ \tag_mc_end:
+ \tag_struct_end:
+ \bool_if:NTF \g__tag_mode_lua_bool
+ {
+ \tag_mc_begin_pop:n{}
+ }
+ {
+ \bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_saved_in_mc_bool
+ }
+ }
+\keys_define:nn { __tag / setup }
+ {
+ exclude-header-footer .choice:,
+ exclude-header-footer / true .code:n =
+ {
+ \cs_set_eq:NN \__tag_hook_kernel_before_head: \__tag_exclude_headfoot_begin:
+ \cs_set_eq:NN \__tag_hook_kernel_before_foot: \__tag_exclude_headfoot_begin:
+ \cs_set_eq:NN \__tag_hook_kernel_after_head: \__tag_exclude_headfoot_end:
+ \cs_set_eq:NN \__tag_hook_kernel_after_foot: \__tag_exclude_headfoot_end:
+ },
+ exclude-header-footer / pagination .code:n =
+ {
+ \cs_set:Nn \__tag_hook_kernel_before_head: { \__tag_exclude_struct_headfoot_begin:n {pagination} }
+ \cs_set:Nn \__tag_hook_kernel_before_foot: { \__tag_exclude_struct_headfoot_begin:n {pagination} }
+ \cs_set_eq:NN \__tag_hook_kernel_after_head: \__tag_exclude_struct_headfoot_end:
+ \cs_set_eq:NN \__tag_hook_kernel_after_foot: \__tag_exclude_struct_headfoot_end:
+ },
+ exclude-header-footer / false .code:n =
+ {
+ \cs_set_eq:NN \__tag_hook_kernel_before_head: \prg_do_nothing:
+ \cs_set_eq:NN \__tag_hook_kernel_before_foot: \prg_do_nothing:
+ \cs_set_eq:NN \__tag_hook_kernel_after_head: \prg_do_nothing:
+ \cs_set_eq:NN \__tag_hook_kernel_after_foot: \prg_do_nothing:
+ },
+ exclude-header-footer .default:n = true,
+ exclude-header-footer .initial:n = true
+ }
+\hook_gput_code:nnn
+ {pdfannot/link/URI/before}
+ {tagpdf}
+ {
+ \tag_mc_end_push:
+ \tag_struct_begin:n { tag=Link }
+ \tag_mc_begin:n { tag=Link }
+ \pdfannot_dict_put:nnx
+ { link/URI }
+ { StructParent }
+ { \tag_struct_parent_int: }
+ }
+
+\hook_gput_code:nnn
+ {pdfannot/link/URI/after}
+ {tagpdf}
+ {
+ \tag_struct_insert_annot:xx {\pdfannot_link_ref_last:}{\tag_struct_parent_int:}
+ \tag_mc_end:
+ \tag_struct_end:
+ \tag_mc_begin_pop:n{}
+ }
+
+\hook_gput_code:nnn
+ {pdfannot/link/GoTo/before}
+ {tagpdf}
+ {
+ \tag_mc_end_push:
+ \tag_struct_begin:n{tag=Link}
+ \tag_mc_begin:n{tag=Link}
+ \pdfannot_dict_put:nnx
+ { link/GoTo }
+ { StructParent }
+ { \tag_struct_parent_int: }
+ }
+
+\hook_gput_code:nnn
+ {pdfannot/link/GoTo/after}
+ {tagpdf}
+ {
+ \tag_struct_insert_annot:xx {\pdfannot_link_ref_last:}{\tag_struct_parent_int:}
+ \tag_mc_end:
+ \tag_struct_end:
+ \tag_mc_begin_pop:n{}
+
+ }
+
+\pdfannot_dict_put:nnn
+ { link/URI }
+ { Contents }
+ { (url) }
+
+\pdfannot_dict_put:nnn
+ { link/GoTo }
+ { Contents }
+ { (ref) }
+
%%
%%
%% End of file `tagpdf.sty'.