| 1 |
%% |
| 2 |
%% This is file `tagpdf.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% tagpdf.dtx (with options: `package') |
| 8 |
%% tagpdf-checks.dtx (with options: `package') |
| 9 |
%% tagpdf-mc-shared.dtx (with options: `shared') |
| 10 |
%% tagpdf.dtx (with options: `mcloading') |
| 11 |
%% tagpdf-tree.dtx (with options: `package') |
| 12 |
%% tagpdf-data.dtx (with options: `package') |
| 13 |
%% tagpdf-roles.dtx (with options: `package') |
| 14 |
%% tagpdf-struct.dtx (with options: `package') |
| 15 |
%% tagpdf-space.dtx (with options: `package') |
| 16 |
%% tagpdf-user.dtx (with options: `package') |
| 17 |
%% |
| 18 |
%% Copyright (C) 2019-2025 Ulrike Fischer |
| 19 |
%% |
| 20 |
%% It may be distributed and/or modified under the conditions of |
| 21 |
%% the LaTeX Project Public License (LPPL), either version 1.3c of |
| 22 |
%% this license or (at your option) any later version. The latest |
| 23 |
%% version of this license is in the file: |
| 24 |
%% |
| 25 |
%% https://www.latex-project.org/lppl.txt |
| 26 |
%% |
| 27 |
%% This file is part of the "tagpdf bundle" (The Work in LPPL) |
| 28 |
%% and all files in that bundle must be distributed together. |
| 29 |
%% |
| 30 |
%% File: tagpdf.dtx |
| 31 |
\ProvidesExplPackage {tagpdf} {2026-05-17} {1.0c} |
| 32 |
{ LaTeX kernel code for PDF tagging } |
| 33 |
|
| 34 |
\IfPDFManagementActiveF |
| 35 |
{ |
| 36 |
\PackageError{tagpdf} |
| 37 |
{ |
| 38 |
PDF~resource~management~is~no~active!\MessageBreak |
| 39 |
tagpdf~will~no~work. |
| 40 |
} |
| 41 |
{ |
| 42 |
Activate~it~with \MessageBreak |
| 43 |
\string\DocumentMetadata{<options>}\MessageBreak |
| 44 |
before~\string\documentclass |
| 45 |
} |
| 46 |
} |
| 47 |
\prop_gput:Nnn \g_msg_module_name_prop { tag }{ tagpdf } |
| 48 |
\bool_new:N\g__tag_mode_lua_bool |
| 49 |
\sys_if_engine_luatex:T {\bool_gset_true:N \g__tag_mode_lua_bool} |
| 50 |
\DeclareOption {luamode} { } |
| 51 |
\DeclareOption {genericmode}{ } |
| 52 |
\ProcessOptions |
| 53 |
\RequirePackage{tagpdf-base} |
| 54 |
\AddToHook{begindocument/before}{\cs_undefine:N\r@@tag@LastPage} |
| 55 |
\AddToHook{enddocument/afterlastpage} |
| 56 |
{\property_record:nn{@tag@LastPage}{abspage,tagmcabs,tagstruct}} |
| 57 |
\tl_new:N \l__tag_tmpa_tl |
| 58 |
\tl_new:N \l__tag_tmpb_tl |
| 59 |
\tl_new:N \l__tag_tmpc_tl |
| 60 |
\tl_new:N \l__tag_tmp_unused_tl |
| 61 |
\tl_new:N \l__tag_Ref_tmpa_tl |
| 62 |
\tl_new:N \l__tag_get_tmpc_tl |
| 63 |
\tl_new:N \l__tag_get_parent_tmpa_tl |
| 64 |
\tl_new:N \l__tag_get_parent_tmpb_tl |
| 65 |
\tl_new:N \l__tag_get_parent_tmpc_tl |
| 66 |
\tl_new:N \l__tag_get_child_tmpa_tl |
| 67 |
\tl_new:N \l__tag_get_child_tmpb_tl |
| 68 |
\tl_new:N \l__tag_get_child_tmpc_tl |
| 69 |
\str_new:N \l__tag_tmpa_str |
| 70 |
\prop_new:N \l__tag_tmpa_prop |
| 71 |
\seq_new:N \l__tag_tmpa_seq |
| 72 |
\seq_new:N \l__tag_tmpb_seq |
| 73 |
\clist_new:N \l__tag_tmpa_clist |
| 74 |
\int_new:N \l__tag_tmpa_int |
| 75 |
\box_new:N \l__tag_tmpa_box |
| 76 |
\box_new:N \l__tag_tmpb_box |
| 77 |
\clist_const:Nn \c__tag_property_mc_clist {tagabspage,tagmcabs,tagmcid} |
| 78 |
\clist_const:Nn \c__tag_property_struct_clist {tagstruct,tagstructobj} |
| 79 |
\int_new:N \l__tag_loglevel_int |
| 80 |
\bool_new:N \g__tag_active_space_bool |
| 81 |
\bool_new:N \g__tag_active_mc_bool |
| 82 |
\bool_new:N \g__tag_active_tree_bool |
| 83 |
\bool_new:N \g__tag_active_struct_bool |
| 84 |
\bool_new:N \g__tag_active_struct_dest_bool |
| 85 |
\bool_gset_true:N \g__tag_active_struct_dest_bool |
| 86 |
|
| 87 |
\bool_new:N \l__tag_active_mc_bool |
| 88 |
\bool_set_true:N \l__tag_active_mc_bool |
| 89 |
\bool_new:N \l__tag_active_struct_bool |
| 90 |
\bool_set_true:N \l__tag_active_struct_bool |
| 91 |
\bool_new:N \l__tag_active_socket_bool |
| 92 |
\bool_new:N \g__tag_tagunmarked_bool |
| 93 |
\bool_new:N \g__tag_softhyphen_bool |
| 94 |
\bool_gset_true:N \g__tag_softhyphen_bool |
| 95 |
\int_new:N \g__tag_unique_cnt_int |
| 96 |
|
| 97 |
\prg_generate_conditional_variant:Nnn \pdf_object_if_exist:n {e}{T,F,TF} |
| 98 |
\cs_generate_variant:Nn \pdf_object_ref:n {e} |
| 99 |
\cs_generate_variant:Nn \pdfannot_dict_put:nnn {nne} |
| 100 |
\cs_generate_variant:Nn \pdffile_embed_stream:nnn {nee,oee} |
| 101 |
\cs_generate_variant:Nn \prop_gput:Nnn {Nee,Nen} %** unneeded |
| 102 |
\cs_generate_variant:Nn \prop_put:Nnn {Nee} %** unneeded |
| 103 |
\cs_generate_variant:Nn \prop_item:Nn {No,Ne} %** unneeded |
| 104 |
\cs_generate_variant:Nn \seq_set_split:Nnn{Nno} |
| 105 |
\cs_generate_variant:Nn \str_set_convert:Nnnn {Nonn, Noon, Nnon } |
| 106 |
\cs_generate_variant:Nn \clist_map_inline:nn {on} |
| 107 |
\cs_generate_variant:Nn \pdffile_embed_file:nnn {eee} |
| 108 |
\cs_new_protected:Npn \__tag_property_record:nn #1#2 |
| 109 |
{ |
| 110 |
\@bsphack |
| 111 |
\property_record:nn{#1}{#2} |
| 112 |
\@esphack |
| 113 |
} |
| 114 |
|
| 115 |
\cs_generate_variant:Nn \property_ref:nnn {enn} |
| 116 |
\cs_generate_variant:Nn \property_ref:nn {en} |
| 117 |
\cs_generate_variant:Nn \__tag_property_record:nn {en,eo} |
| 118 |
\cs_new:Npn \__tag_property_ref_lastpage:nn #1 #2 |
| 119 |
{ |
| 120 |
\property_ref:nnn {@tag@LastPage}{#1}{#2} |
| 121 |
} |
| 122 |
|
| 123 |
\property_new:nnnn |
| 124 |
{ tagstruct } { now } |
| 125 |
{1} { \int_use:N \c@g__tag_struct_abs_int } |
| 126 |
\property_new:nnnn { tagstructobj } { now } {} |
| 127 |
{ |
| 128 |
\pdf_object_ref_indexed:nn { __tag/struct } { \c@g__tag_struct_abs_int } |
| 129 |
} |
| 130 |
\property_new:nnnn |
| 131 |
{ tagabspage } { shipout } |
| 132 |
{0} { \int_use:N \g_shipout_readonly_int } |
| 133 |
\property_new:nnnn { tagmcabs } { now } |
| 134 |
{0} { \int_use:N \c@g__tag_MCID_abs_int } |
| 135 |
|
| 136 |
\flag_new:n { __tag/mcid } |
| 137 |
\property_new:nnnn {tagmcid } { shipout } |
| 138 |
{0} { \flag_height:n { __tag/mcid } } |
| 139 |
|
| 140 |
|
| 141 |
\cs_set_eq:NN \__tag_prop_new:N \prop_new:N |
| 142 |
\cs_set_eq:NN \__tag_prop_new_linked:N \prop_new_linked:N |
| 143 |
\cs_set_eq:NN \__tag_seq_new:N \seq_new:N |
| 144 |
\cs_set_eq:NN \__tag_prop_gput:Nnn \prop_gput:Nnn |
| 145 |
\cs_set_eq:NN \__tag_seq_gput_right:Nn \seq_gput_right:Nn |
| 146 |
\cs_set_eq:NN \__tag_seq_gput_left:Nn \seq_gput_left:Nn |
| 147 |
\cs_set_eq:NN \__tag_seq_item:cn \seq_item:cn |
| 148 |
\cs_set_eq:NN \__tag_prop_item:cn \prop_item:cn |
| 149 |
\cs_set_eq:NN \__tag_seq_show:N \seq_show:N |
| 150 |
\cs_set_eq:NN \__tag_prop_show:N \prop_show:N |
| 151 |
\cs_generate_variant:Nn \__tag_prop_gput:Nnn { Nen, Nee, Nne, Nno, cnn, cen, cne, cno, cnx} |
| 152 |
\cs_generate_variant:Nn \__tag_seq_gput_right:Nn { Ne , No, cn, ce } |
| 153 |
\cs_generate_variant:Nn \__tag_seq_gput_left:Nn { ce } |
| 154 |
\cs_generate_variant:Nn \__tag_prop_new:N { c } |
| 155 |
\cs_generate_variant:Nn \__tag_seq_new:N { c } |
| 156 |
\cs_generate_variant:Nn \__tag_seq_show:N { c } |
| 157 |
\cs_generate_variant:Nn \__tag_prop_show:N { c } |
| 158 |
\int_new:N \l__tag_tag_stop_int |
| 159 |
\cs_set_protected:Npn \tag_stop: |
| 160 |
{ |
| 161 |
\int_incr:N \l__tag_tag_stop_int |
| 162 |
\bool_set_false:N \l__tag_active_struct_bool |
| 163 |
\bool_set_false:N \l__tag_active_mc_bool |
| 164 |
\bool_set_false:N \l__tag_active_socket_bool |
| 165 |
\__tag_stop_para_ints: |
| 166 |
} |
| 167 |
\cs_set_protected:Npn \tag_start: |
| 168 |
{ |
| 169 |
\int_if_zero:nF { \l__tag_tag_stop_int } { \int_decr:N \l__tag_tag_stop_int } |
| 170 |
\int_if_zero:nT { \l__tag_tag_stop_int } |
| 171 |
{ |
| 172 |
\bool_set_true:N \l__tag_active_struct_bool |
| 173 |
\bool_set_true:N \l__tag_active_mc_bool |
| 174 |
\bool_set_true:N \l__tag_active_socket_bool |
| 175 |
\__tag_start_para_ints: |
| 176 |
} |
| 177 |
} |
| 178 |
\cs_set_eq:NN\tagstop\tag_stop: |
| 179 |
\cs_set_eq:NN\tagstart\tag_start: |
| 180 |
\cs_set_protected:Npn \tag_suspend:n #1 |
| 181 |
{ |
| 182 |
\int_incr:N \l__tag_tag_stop_int |
| 183 |
\bool_set_false:N \l__tag_active_struct_bool |
| 184 |
\bool_set_false:N \l__tag_active_mc_bool |
| 185 |
\bool_set_false:N \l__tag_active_socket_bool |
| 186 |
\__tag_stop_para_ints: |
| 187 |
} |
| 188 |
\cs_set_eq:NN \tag_stop:n \tag_suspend:n |
| 189 |
\cs_set_protected:Npn \tag_resume:n #1 |
| 190 |
{ |
| 191 |
\int_if_zero:nF { \l__tag_tag_stop_int } { \int_decr:N \l__tag_tag_stop_int } |
| 192 |
\int_if_zero:nT { \l__tag_tag_stop_int } |
| 193 |
{ |
| 194 |
\bool_set_true:N \l__tag_active_struct_bool |
| 195 |
\bool_set_true:N \l__tag_active_mc_bool |
| 196 |
\bool_set_true:N \l__tag_active_socket_bool |
| 197 |
\__tag_start_para_ints: |
| 198 |
} |
| 199 |
} |
| 200 |
\cs_set_eq:NN \tag_start:n \tag_resume:n |
| 201 |
\cs_new_protected:Npn \__tag_activate_linkbin: |
| 202 |
{ |
| 203 |
\sys_if_engine_luatex:T |
| 204 |
{ |
| 205 |
\tagstructbegin{tag=\UseStructureName{link},stash} |
| 206 |
\tl_const:Ne \c__tag_struct_link_bin_tl {\int_use:N\c@g__tag_struct_abs_int}% |
| 207 |
\tagstructend |
| 208 |
\AddToHook{tagpdf/finish/before}[tagpdf/linkbin] |
| 209 |
{ |
| 210 |
\par |
| 211 |
\int_compare:nNnT {\directlua{tex.sprint(ltx.__tag.func.linkbin())}}>{0} |
| 212 |
{ |
| 213 |
\tagstructbegin{tag=Artifact,title=Ignored~link~annotations} |
| 214 |
\tag_struct_use_num:o{\c__tag_struct_link_bin_tl} |
| 215 |
\tagstructend |
| 216 |
} |
| 217 |
} |
| 218 |
} |
| 219 |
} |
| 220 |
\AddToHook{begindocument/end}[tagpdf/linkbin]{\__tag_activate_linkbin:} |
| 221 |
\keys_define:nn { __tag / setup } |
| 222 |
{ |
| 223 |
activate/mc .bool_gset:N = \g__tag_active_mc_bool, |
| 224 |
activate/tree .bool_gset:N = \g__tag_active_tree_bool, |
| 225 |
activate/struct .bool_gset:N = \g__tag_active_struct_bool, |
| 226 |
activate/all .meta:n = |
| 227 |
{activate/mc={#1},activate/tree={#1},activate/struct={#1}}, |
| 228 |
activate/all .default:n = true, |
| 229 |
activate/struct-dest .bool_gset:N = \g__tag_active_struct_dest_bool, |
| 230 |
activate-mc .bool_gset:N = \g__tag_active_mc_bool, |
| 231 |
activate-tree .bool_gset:N = \g__tag_active_tree_bool, |
| 232 |
activate-struct .bool_gset:N = \g__tag_active_struct_bool, |
| 233 |
activate-all .meta:n = |
| 234 |
{activate/mc={#1},activate/tree={#1},activate/struct={#1}}, |
| 235 |
activate-all .default:n = true, |
| 236 |
no-struct-dest .bool_gset_inverse:N = \g__tag_active_struct_dest_bool, |
| 237 |
debug/show .choice:, |
| 238 |
debug/log .choice:, |
| 239 |
debug/log / none .code:n = {\int_set:Nn \l__tag_loglevel_int { 0 }}, |
| 240 |
debug/log / v .code:n = |
| 241 |
{ |
| 242 |
\int_set:Nn \l__tag_loglevel_int { 1 } |
| 243 |
\cs_set_protected:Nn \__tag_check_typeout_v:n { \iow_term:e {##1} } |
| 244 |
}, |
| 245 |
debug/log / vv .code:n = {\int_set:Nn \l__tag_loglevel_int { 2 }}, |
| 246 |
debug/log / vvv .code:n = {\int_set:Nn \l__tag_loglevel_int { 3 }}, |
| 247 |
debug/log / all .code:n = {\int_set:Nn \l__tag_loglevel_int { 10 }}, |
| 248 |
debug/uncompress .code:n = { \pdf_uncompress: }, |
| 249 |
log .meta:n = {debug/log={#1}}, |
| 250 |
uncompress .code:n = { \pdf_uncompress: }, |
| 251 |
activate/tagunmarked .bool_gset:N = \g__tag_tagunmarked_bool, |
| 252 |
activate/tagunmarked .initial:n = true, |
| 253 |
tagunmarked .bool_gset:N = \g__tag_tagunmarked_bool, |
| 254 |
activate/softhyphen .choice:, |
| 255 |
activate/softhyphen/false .code:n = {\bool_gset_false:N \g__tag_softhyphen_bool}, |
| 256 |
activate/softhyphen/off .code:n = {\bool_gset_false:N \g__tag_softhyphen_bool}, |
| 257 |
activate/softhyphen/char .code:n = |
| 258 |
{ |
| 259 |
\bool_gset_true:N \g__tag_softhyphen_bool |
| 260 |
\sys_if_engine_luatex:T |
| 261 |
{ |
| 262 |
\lua_now:e |
| 263 |
{ |
| 264 |
tex.setattribute |
| 265 |
( |
| 266 |
luatexbase.attributes.l__tag_softhyphen_attr, |
| 267 |
1 |
| 268 |
) |
| 269 |
} |
| 270 |
} |
| 271 |
}, |
| 272 |
activate/softhyphen/artifact .code:n = |
| 273 |
{ |
| 274 |
\bool_gset_true:N \g__tag_softhyphen_bool |
| 275 |
\sys_if_engine_luatex:T |
| 276 |
{ |
| 277 |
\lua_now:e |
| 278 |
{ |
| 279 |
tex.setattribute |
| 280 |
( |
| 281 |
luatexbase.attributes.l__tag_softhyphen_attr, |
| 282 |
-2147483647 |
| 283 |
) |
| 284 |
} |
| 285 |
} |
| 286 |
}, |
| 287 |
activate/softhyphen/true .code:n = |
| 288 |
{ |
| 289 |
\bool_gset_true:N \g__tag_softhyphen_bool |
| 290 |
\sys_if_engine_luatex:T |
| 291 |
{ |
| 292 |
\lua_now:e |
| 293 |
{ |
| 294 |
tex.setattribute |
| 295 |
( |
| 296 |
luatexbase.attributes.l__tag_softhyphen_attr, |
| 297 |
-2147483647 |
| 298 |
) |
| 299 |
} |
| 300 |
} |
| 301 |
}, |
| 302 |
activate/softhyphen/on .code:n = |
| 303 |
{ |
| 304 |
\bool_gset_true:N \g__tag_softhyphen_bool |
| 305 |
\sys_if_engine_luatex:T |
| 306 |
{ |
| 307 |
\lua_now:e |
| 308 |
{ |
| 309 |
tex.setattribute |
| 310 |
( |
| 311 |
luatexbase.attributes.l__tag_softhyphen_attr, |
| 312 |
-2147483647 |
| 313 |
) |
| 314 |
} |
| 315 |
} |
| 316 |
}, |
| 317 |
activate/softhyphen .default:n = artifact, |
| 318 |
activate/collect-link-artifacts/off .code:n = |
| 319 |
{\RemoveFromHook{begindocument/end}[tagpdf/linkbin]}, |
| 320 |
page/tabsorder .choice:, |
| 321 |
page/tabsorder / row .code:n = |
| 322 |
\pdfmanagement_add:nnn { Page } {Tabs}{/R}, |
| 323 |
page/tabsorder / column .code:n = |
| 324 |
\pdfmanagement_add:nnn { Page } {Tabs}{/C}, |
| 325 |
page/tabsorder / structure .code:n = |
| 326 |
\pdfmanagement_add:nnn { Page } {Tabs}{/S}, |
| 327 |
page/tabsorder / none .code:n = |
| 328 |
\pdfmanagement_remove:nn {Page} {Tabs}, |
| 329 |
page/tabsorder .initial:n = structure, |
| 330 |
tabsorder .meta:n = {page/tabsorder={#1}}, |
| 331 |
} |
| 332 |
\sys_if_engine_luatex:T |
| 333 |
{ |
| 334 |
\file_input:n {tagpdf-luatex.def} |
| 335 |
} |
| 336 |
%% File: tagpdf-checks.dtx |
| 337 |
|
| 338 |
|
| 339 |
\msg_new:nnn { tag } {mc-nested} { nested~marked~content~found~-~mcid~#1 } |
| 340 |
\msg_new:nnn { tag } {mc-tag-missing} { MC-tag~missing;~#1~used~instead~-~mcid~#2 } |
| 341 |
\msg_new:nnn { tag } {mc-label-unknown} |
| 342 |
{ label~#1~unknown~or~has~been~already~used.\\ |
| 343 |
Either~rerun~or~remove~one~of~the~uses. } |
| 344 |
\msg_new:nnn { tag } {mc-used-twice} { mc~#1~has~been~already~used } |
| 345 |
\msg_new:nnn { tag } {mc-not-open} { there~is~no~mc~to~end~at~#1 } |
| 346 |
\msg_new:nnn { tag } {mc-pushed} { #1~has~been~pushed~to~the~mc~stack} |
| 347 |
\msg_new:nnn { tag } {mc-popped} { #1~has~been~removed~from~the~mc~stack } |
| 348 |
\msg_new:nnn { tag } {mc-current} |
| 349 |
{ current~MC:~ |
| 350 |
\bool_if:NTF\g__tag_in_mc_bool |
| 351 |
{abscnt=\__tag_get_mc_abs_cnt:,~tag=\g__tag_mc_key_tag_tl} |
| 352 |
{no~MC~open,~current~abscnt=\__tag_get_mc_abs_cnt:"} |
| 353 |
} |
| 354 |
\msg_new:nnn { tag } {struct-unknown} |
| 355 |
{ structure~with~number~#1~doesn't~exist\\ #2 } |
| 356 |
\msg_new:nnn { tag } {struct-no-objnum} { objnum~missing~for~structure~#1 } |
| 357 |
\msg_new:nnn { tag } {struct-orphan} |
| 358 |
{ |
| 359 |
Structure~#1~has~#2~kids~but~no~parent.\\ |
| 360 |
It~is~turned~into~an~artifact.\\ |
| 361 |
Did~you~stashed~a~structure~and~then~didn't~use~it? |
| 362 |
} |
| 363 |
|
| 364 |
\msg_new:nnn { tag } |
| 365 |
{struct-faulty-nesting} |
| 366 |
{ there~is~no~open~structure~on~the~stack } |
| 367 |
\msg_new:nnn { tag } {struct-missing-tag} { a~structure~must~have~a~tag! } |
| 368 |
\msg_new:nnn { tag } {struct-used-twice} |
| 369 |
{ structure~with~label~#1~has~already~been~used} |
| 370 |
\msg_new:nnn { tag } {struct-label-unknown} |
| 371 |
{ structure~with~label~#1~is~unknown~rerun} |
| 372 |
\msg_new:nnn { tag } {struct-show-closing} |
| 373 |
{ closing~structure~#1~tagged~\use:e{\prop_item:cn{g__tag_struct_#1_prop}{S}} } |
| 374 |
\msg_new:nnn { tag } {struct-Ref-unknown} |
| 375 |
{ |
| 376 |
#1~has~no~related~structure.\\ |
| 377 |
/Ref~not~updated. |
| 378 |
} |
| 379 |
\msg_new:nnn { tag } {tree-struct-still-open} |
| 380 |
{ |
| 381 |
There~are~still~open~structures~on~the~stack!\\ |
| 382 |
The~stack~contains~\seq_use:Nn\g__tag_struct_tag_stack_seq{,}.\\ |
| 383 |
The~structures~are~automatically~closed,\\ |
| 384 |
but~their~nesting~can~be~wrong. |
| 385 |
} |
| 386 |
\msg_new:nnn { tag } {tree-statistic} |
| 387 |
{ |
| 388 |
Finalizing~the~tagging~structure:\\ |
| 389 |
Writing~out~\c_tilde_str |
| 390 |
\int_use:N\c@g__tag_struct_abs_int\c_space_tl~structure~objects\\ |
| 391 |
with~\c_tilde_str |
| 392 |
\int_use:N\c@g__tag_MCID_abs_int\c_space_tl'MC'~leaf~nodes.\\ |
| 393 |
Be~patient~if~there~are~lots~of~objects! |
| 394 |
} |
| 395 |
\msg_new:nnn { tag } {attr-unknown} { attribute~#1~is~unknown} |
| 396 |
\msg_new:nnn { tag } {role-missing} { tag~#1~has~no~role~assigned } |
| 397 |
\msg_new:nnn { tag } {role-unknown} { role~#1~is~not~known } |
| 398 |
\msg_new:nnn { tag } {role-unknown-tag} { tag~#1~is~not~known } |
| 399 |
\msg_new:nnn { tag } {role-unknown-NS} { \tl_if_empty:nTF{#1}{Empty~NS}{NS~#1~is~not~known} } |
| 400 |
\msg_new:nnn { tag } {role-parent-child-check} |
| 401 |
{ Checking~Parent-Child~'#1'~-->~'#2' } |
| 402 |
\msg_new:nnn { tag } {role-parent-child-result} |
| 403 |
{ Parent-Child~'#1'~-->~'#2'.\\Relation~is~#3~\msg_line_context:} |
| 404 |
\msg_new:nnn { tag } {role-struct-parent-child-forbidden} |
| 405 |
{ |
| 406 |
Parent-Child~'#3'~-->~'#4'.\\ |
| 407 |
Relation~is~not~allowed! ~\msg_line_context:\\ |
| 408 |
struct~#1,~ |
| 409 |
\exp_last_unbraced:Ne\use_i:nn { \prop_item:cn{ g__tag_struct_#1_prop}{tag} } |
| 410 |
\c_space_tl-->\c_space_tl |
| 411 |
struct~#2,~ |
| 412 |
\exp_last_unbraced:Ne\use_i:nn { \prop_item:cn{ g__tag_struct_#2_prop}{tag} } |
| 413 |
} |
| 414 |
\msg_new:nnn { tag } {role-MC-child-forbidden} |
| 415 |
{ |
| 416 |
Parent-Child~'#2'~-->~'MC~(real~content)'.\\ |
| 417 |
Relation~is~not~allowed! ~\msg_line_context:\\ |
| 418 |
struct~#1,~ |
| 419 |
\exp_last_unbraced:Ne\use_i:nn { \prop_item:cn{ g__tag_struct_#1_prop}{tag} } |
| 420 |
} |
| 421 |
\msg_new:nnn { tag } {role-parent-child-forbidden} |
| 422 |
{ |
| 423 |
Parent-Child~'#2'~-->~'#3'.\\ |
| 424 |
Relation~is~not~allowed! ~\msg_line_context:\\ |
| 425 |
struct~#1,~\prop_item:cn{ g__tag_struct_#1_prop}{S} |
| 426 |
\c_space_tl |
| 427 |
\str_if_eq:nnF{#3}{MC~(realcontent)} |
| 428 |
{-->~struct~\int_eval:n {\c@g__tag_struct_abs_int}} |
| 429 |
} |
| 430 |
|
| 431 |
\cs_new_protected:Npn \__tag_check_forbidden_parent_child:nnnn #1#2#3#4 |
| 432 |
{ |
| 433 |
\int_compare:nNnT {#1 } <0 |
| 434 |
{ |
| 435 |
\msg_warning:nneee |
| 436 |
{ tag } |
| 437 |
{role-parent-child-forbidden} |
| 438 |
{ #2} |
| 439 |
{ #3 } |
| 440 |
{ #4 } |
| 441 |
} |
| 442 |
} |
| 443 |
\cs_generate_variant:Nn \__tag_check_forbidden_parent_child:nnnn {nnee} |
| 444 |
|
| 445 |
\cs_new_protected:Npn \__tag_check_struct_forbidden_parent_child:nnn #1#2#3 |
| 446 |
{ |
| 447 |
\int_compare:nNnT {#1 } <0 |
| 448 |
{ |
| 449 |
\prop_get:cnN {g__tag_struct_#2_prop}{parentrole}\l__tag_get_parent_tmpc_tl |
| 450 |
\prop_get:cnN {g__tag_struct_#3_prop}{rolemap}\l__tag_get_child_tmpc_tl |
| 451 |
\msg_warning:nneeee |
| 452 |
{ tag } |
| 453 |
{role-struct-parent-child-forbidden} |
| 454 |
{ #2 } |
| 455 |
{ #3 } |
| 456 |
{ |
| 457 |
\exp_last_unbraced:No \use_ii:nn { \l__tag_get_parent_tmpc_tl } |
| 458 |
: |
| 459 |
\exp_last_unbraced:No \use_i:nn {\l__tag_get_parent_tmpc_tl } |
| 460 |
} |
| 461 |
{ |
| 462 |
\exp_last_unbraced:No \use_ii:nn { \l__tag_get_child_tmpc_tl } |
| 463 |
: |
| 464 |
\exp_last_unbraced:No \use_i:nn { \l__tag_get_child_tmpc_tl } |
| 465 |
} |
| 466 |
} |
| 467 |
} |
| 468 |
\cs_generate_variant:Nn\__tag_check_struct_forbidden_parent_child:nnn{onn} |
| 469 |
\msg_new:nnn { tag } {role-parent-child-unresolved} |
| 470 |
{ |
| 471 |
Structure~\int_eval:n {\c@g__tag_struct_abs_int}~was~moved~into~structure~#1.\\ |
| 472 |
Parent-Child~'#2'~-->~'#3'~can~not~checked. |
| 473 |
} |
| 474 |
\cs_new_protected:Npn \__tag_check_unresolved_parent_child:nnnn #1#2#3#4 |
| 475 |
{ |
| 476 |
\int_compare:nNnT { #1 } = {\c__tag_role_rule_checkparent_tl} |
| 477 |
{ |
| 478 |
\msg_warning:nneee |
| 479 |
{ tag } |
| 480 |
{role-parent-child-unresolved} |
| 481 |
{ #2 } |
| 482 |
{ #3 } |
| 483 |
{ #4 } |
| 484 |
} |
| 485 |
} |
| 486 |
\socket_new:nn{tag/check/parent-child}{1} |
| 487 |
\socket_new:nn{tag/check/parent-child-end}{0} |
| 488 |
\socket_new_plug:nnn {tag/check/parent-child-end}{check} |
| 489 |
{ |
| 490 |
\sys_if_engine_luatex:T |
| 491 |
{ |
| 492 |
\lua_now:e |
| 493 |
{ |
| 494 |
ltx.__tag.func.check_parent_child_rules ( 2 ) |
| 495 |
} |
| 496 |
} |
| 497 |
} |
| 498 |
\keys_define:nn { __tag / setup} |
| 499 |
{ |
| 500 |
debug / parent-child-check .choice:, |
| 501 |
debug / parent-child-check / on .code:n = |
| 502 |
{ |
| 503 |
\socket_assign_plug:nn {tag/check/parent-child}{identity} |
| 504 |
}, |
| 505 |
debug / parent-child-check / off .code:n= |
| 506 |
{ |
| 507 |
\socket_assign_plug:nn {tag/check/parent-child}{noop} |
| 508 |
\socket_assign_plug:nn {tag/check/parent-child-end}{noop} |
| 509 |
}, |
| 510 |
debug / parent-child-check / atend .code:n= |
| 511 |
{ |
| 512 |
\socket_assign_plug:nn {tag/check/parent-child}{noop} |
| 513 |
\socket_assign_plug:nn {tag/check/parent-child-end}{check} |
| 514 |
} |
| 515 |
} |
| 516 |
\msg_new:nnn { tag } {role-remapping} |
| 517 |
{ remapping~tag~to~#1 } |
| 518 |
\msg_new:nnn { tag } {role-tag} { mapping~tag~#1~to~role~#2 } |
| 519 |
\msg_new:nnn { tag } {new-tag} { adding~new~tag~#1 } |
| 520 |
\msg_new:nnn { tag } {read-namespace} { reading~namespace~definitions~tagpdf-ns-#1.def } |
| 521 |
\msg_new:nnn { tag } {namespace-missing}{ namespace~definitions~tagpdf-ns-#1.def~not~found } |
| 522 |
\msg_new:nnn { tag } {namespace-unknown}{ namespace~#1~is~not~declared } |
| 523 |
\msg_new:nnn { tag } {wrong-pdfversion} |
| 524 |
{ |
| 525 |
The~PDF~version~has~changed~after~the~loading~of~tagpdf~from~#1~to~#2.\\ |
| 526 |
The~structure~will~be~faulty.\\ |
| 527 |
Trying~to~revert~to~#1. |
| 528 |
} |
| 529 |
\msg_new:nnn { tag } {tree-mcid-index-wrong} |
| 530 |
{something~is~wrong~with~the~mcid--rerun} |
| 531 |
\msg_new:nnn { tag } {sys-no-interwordspace} |
| 532 |
{engine/output~mode~#1~doesn't~support~the~interword~spaces} |
| 533 |
\cs_set_eq:NN \__tag_check_typeout_v:n \use_none:n |
| 534 |
\msg_new:nnnn { tag } {para-hook-count-wrong} |
| 535 |
{The~number~of~automatic~begin~(#1)~and~end~(#2)~#3~para~hooks~differ!} |
| 536 |
{This~quite~probably~a~coding~error~and~the~structure~will~be~wrong!} |
| 537 |
\tl_const:Ne\c__tag_check_pdfversion_tl {\pdf_version:} |
| 538 |
\AddToHook{begindocument/before} |
| 539 |
{ |
| 540 |
\tl_if_eq:eeF{\c__tag_check_pdfversion_tl}{\pdf_version:} |
| 541 |
{ |
| 542 |
\msg_error:nnee {tag}{wrong-pdfversion}{\c__tag_check_pdfversion_tl}{\pdf_version:} |
| 543 |
\pdf_version_gset:e {\c__tag_check_pdfversion_tl} |
| 544 |
\pdf_object_unnamed_write:nn{dict}{} |
| 545 |
} |
| 546 |
} |
| 547 |
\prg_set_conditional:Npnn \tag_if_active: { p , T , TF, F } |
| 548 |
{ |
| 549 |
\bool_lazy_all:nTF |
| 550 |
{ |
| 551 |
{\g__tag_active_struct_bool} |
| 552 |
{\g__tag_active_mc_bool} |
| 553 |
{\g__tag_active_tree_bool} |
| 554 |
{\l__tag_active_struct_bool} |
| 555 |
{\l__tag_active_mc_bool} |
| 556 |
} |
| 557 |
{ |
| 558 |
\prg_return_true: |
| 559 |
} |
| 560 |
{ |
| 561 |
\prg_return_false: |
| 562 |
} |
| 563 |
} |
| 564 |
\prg_new_conditional:Npnn\tag_if_in:n #1 {T,F,TF} |
| 565 |
{ |
| 566 |
\seq_if_in:NnTF \g__tag_struct_roletag_stack_seq {#1} |
| 567 |
{\prg_return_true:} |
| 568 |
{\prg_return_false:} |
| 569 |
} |
| 570 |
\prg_new_conditional:Npnn \__tag_check_if_active_mc: {T,F,TF} |
| 571 |
{ |
| 572 |
\bool_lazy_and:nnTF { \g__tag_active_mc_bool } { \l__tag_active_mc_bool } |
| 573 |
{ |
| 574 |
\prg_return_true: |
| 575 |
} |
| 576 |
{ |
| 577 |
\prg_return_false: |
| 578 |
} |
| 579 |
} |
| 580 |
\prg_new_conditional:Npnn \__tag_check_if_active_struct: {T,F,TF} |
| 581 |
{ |
| 582 |
\bool_lazy_and:nnTF { \g__tag_active_struct_bool } { \l__tag_active_struct_bool } |
| 583 |
{ |
| 584 |
\prg_return_true: |
| 585 |
} |
| 586 |
{ |
| 587 |
\prg_return_false: |
| 588 |
} |
| 589 |
} |
| 590 |
\cs_new_protected:Npn \__tag_check_structure_has_tag:n #1 %#1 struct num |
| 591 |
{ |
| 592 |
\prop_get:cnNF |
| 593 |
{ g__tag_struct_#1_prop } |
| 594 |
{S} |
| 595 |
\l__tag_tmp_unused_tl |
| 596 |
{ |
| 597 |
\msg_error:nn { tag } {struct-missing-tag} |
| 598 |
} |
| 599 |
} |
| 600 |
\cs_new_protected:Npn \__tag_check_structure_tag:N #1 |
| 601 |
{ |
| 602 |
\prop_get:NoNF \g__tag_role_tags_NS_prop {#1}\l__tag_tmp_unused_tl |
| 603 |
{ |
| 604 |
\msg_warning:nne { tag } {role-unknown-tag} {#1} |
| 605 |
} |
| 606 |
} |
| 607 |
\cs_new_protected:Npn \__tag_check_info_closing_struct:n #1 %#1 struct num |
| 608 |
{ |
| 609 |
\int_compare:nNnT {\l__tag_loglevel_int} > { 0 } |
| 610 |
{ |
| 611 |
\msg_info:nnn { tag } {struct-show-closing} {#1} |
| 612 |
} |
| 613 |
} |
| 614 |
|
| 615 |
\cs_generate_variant:Nn \__tag_check_info_closing_struct:n {o,e} |
| 616 |
\cs_new_protected:Npn \__tag_check_no_open_struct: |
| 617 |
{ |
| 618 |
\msg_error:nn { tag } {struct-faulty-nesting} |
| 619 |
} |
| 620 |
\cs_new_protected:Npn \__tag_check_struct_used:n #1 %#1 label |
| 621 |
{ |
| 622 |
\prop_get:cnNT |
| 623 |
{g__tag_struct_\property_ref:enn{tagpdfstruct-#1}{tagstruct}{unknown}_prop} |
| 624 |
{parentnum} |
| 625 |
\l__tag_tmpa_tl |
| 626 |
{ |
| 627 |
\msg_warning:nnn { tag } {struct-used-twice} {#1} |
| 628 |
} |
| 629 |
} |
| 630 |
\cs_new_protected:Npn \__tag_check_add_tag_role:nn #1 #2 %#1 tag, #2 role |
| 631 |
{ |
| 632 |
\tl_if_empty:nTF {#2} |
| 633 |
{ |
| 634 |
\msg_error:nnn { tag } {role-missing} {#1} |
| 635 |
} |
| 636 |
{ |
| 637 |
\prop_get:NnNTF \g__tag_role_tags_NS_prop {#2} \l__tag_tmpa_tl |
| 638 |
{ |
| 639 |
\int_compare:nNnT {\l__tag_loglevel_int} > { 0 } |
| 640 |
{ |
| 641 |
\msg_info:nnnn { tag } {role-tag} {#1} {#2} |
| 642 |
} |
| 643 |
} |
| 644 |
{ |
| 645 |
\msg_error:nnn { tag } {role-unknown} {#2} |
| 646 |
} |
| 647 |
} |
| 648 |
} |
| 649 |
\cs_new_protected:Npn \__tag_check_add_tag_role:nnn #1 #2 #3 %#1 tag/NS, #2 role #3 namespace |
| 650 |
{ |
| 651 |
\tl_if_empty:nTF {#2} |
| 652 |
{ |
| 653 |
\msg_error:nnn { tag } {role-missing} {#1} |
| 654 |
} |
| 655 |
{ |
| 656 |
\prop_get:cnNTF { g__tag_role_NS_#3_prop } {#2} \l__tag_tmpa_tl |
| 657 |
{ |
| 658 |
\int_compare:nNnT {\l__tag_loglevel_int} > { 0 } |
| 659 |
{ |
| 660 |
\msg_info:nnnn { tag } {role-tag} {#1} {#2/#3} |
| 661 |
} |
| 662 |
} |
| 663 |
{ |
| 664 |
\msg_error:nnn { tag } {role-unknown} {#2/#3} |
| 665 |
} |
| 666 |
} |
| 667 |
} |
| 668 |
|
| 669 |
\cs_new_protected:Npn \__tag_check_mc_if_nested: |
| 670 |
{ |
| 671 |
\__tag_mc_if_in:T |
| 672 |
{ |
| 673 |
\msg_warning:nne { tag } {mc-nested} { \__tag_get_mc_abs_cnt: } |
| 674 |
} |
| 675 |
} |
| 676 |
|
| 677 |
\cs_new_protected:Npn \__tag_check_mc_if_open: |
| 678 |
{ |
| 679 |
\__tag_mc_if_in:F |
| 680 |
{ |
| 681 |
\msg_warning:nne { tag } {mc-not-open} { \__tag_get_mc_abs_cnt: } |
| 682 |
} |
| 683 |
} |
| 684 |
\cs_new_protected:Npn \__tag_check_mc_pushed_popped:nn #1 #2 |
| 685 |
{ |
| 686 |
\int_compare:nNnT |
| 687 |
{ \l__tag_loglevel_int } ={ 2 } |
| 688 |
{ \msg_info:nne {tag}{mc-#1}{#2} } |
| 689 |
\int_compare:nNnT |
| 690 |
{ \l__tag_loglevel_int } > { 2 } |
| 691 |
{ |
| 692 |
\msg_info:nne {tag}{mc-#1}{#2} |
| 693 |
\seq_log:N \g__tag_mc_stack_seq |
| 694 |
} |
| 695 |
} |
| 696 |
\cs_new_protected:Npn \__tag_check_mc_tag:N #1 %#1 is var with a tag name in it |
| 697 |
{ |
| 698 |
\tl_if_empty:NTF #1 |
| 699 |
{ |
| 700 |
\tl_set:No #1 { \g__tag_struct_tag_tl } |
| 701 |
\msg_info:nnee { tag } {mc-tag-missing} { \g__tag_struct_tag_tl }{ \__tag_get_mc_abs_cnt: } |
| 702 |
} |
| 703 |
{ |
| 704 |
\prop_get:NoNF \g__tag_role_tags_NS_prop {#1}\l__tag_tmp_unused_tl |
| 705 |
{ |
| 706 |
\msg_warning:nne { tag } {role-unknown-tag} {#1} |
| 707 |
} |
| 708 |
} |
| 709 |
} |
| 710 |
\cs_new_protected:Npn \__tag_check_init_mc_used: |
| 711 |
{ |
| 712 |
\intarray_new:Nn \g__tag_check_mc_used_intarray { 65536 } |
| 713 |
\cs_gset_eq:NN \__tag_check_init_mc_used: \prg_do_nothing: |
| 714 |
} |
| 715 |
\cs_new_protected:Npn \__tag_check_mc_used:n #1 %#1 mcid abscnt |
| 716 |
{ |
| 717 |
\int_compare:nNnT {\l__tag_loglevel_int} > { 2 } |
| 718 |
{ |
| 719 |
\__tag_check_init_mc_used: |
| 720 |
\intarray_gset:Nnn \g__tag_check_mc_used_intarray |
| 721 |
{#1} |
| 722 |
{ \intarray_item:Nn \g__tag_check_mc_used_intarray {#1} + 1 } |
| 723 |
\int_compare:nNnT |
| 724 |
{ |
| 725 |
\intarray_item:Nn \g__tag_check_mc_used_intarray {#1} |
| 726 |
} |
| 727 |
> |
| 728 |
{ 1 } |
| 729 |
{ |
| 730 |
\msg_warning:nnn { tag } {mc-used-twice} {#1} |
| 731 |
} |
| 732 |
} |
| 733 |
} |
| 734 |
\cs_new_protected:Npn \__tag_check_show_MCID_by_page: |
| 735 |
{ |
| 736 |
\tl_set:Ne \l__tag_tmpa_tl |
| 737 |
{ |
| 738 |
\__tag_property_ref_lastpage:nn |
| 739 |
{abspage} |
| 740 |
{-1} |
| 741 |
} |
| 742 |
\int_step_inline:nnnn {1}{1} |
| 743 |
{ |
| 744 |
\l__tag_tmpa_tl |
| 745 |
} |
| 746 |
{ |
| 747 |
\seq_clear:N \l__tag_tmpa_seq |
| 748 |
\int_step_inline:nnnn |
| 749 |
{1} |
| 750 |
{1} |
| 751 |
{ |
| 752 |
\__tag_property_ref_lastpage:nn |
| 753 |
{tagmcabs} |
| 754 |
{-1} |
| 755 |
} |
| 756 |
{ |
| 757 |
\int_compare:nT |
| 758 |
{ |
| 759 |
\property_ref:enn |
| 760 |
{mcid-####1} |
| 761 |
{tagabspage} |
| 762 |
{-1} |
| 763 |
= |
| 764 |
##1 |
| 765 |
} |
| 766 |
{ |
| 767 |
\seq_gput_right:Ne \l__tag_tmpa_seq |
| 768 |
{ |
| 769 |
Page##1-####1- |
| 770 |
\property_ref:enn |
| 771 |
{mcid-####1} |
| 772 |
{tagmcid} |
| 773 |
{-1} |
| 774 |
} |
| 775 |
} |
| 776 |
} |
| 777 |
\seq_show:N \l__tag_tmpa_seq |
| 778 |
} |
| 779 |
} |
| 780 |
\prg_new_conditional:Npnn \__tag_check_if_mc_in_galley: { T,F,TF } |
| 781 |
{ |
| 782 |
\tl_if_eq:NNTF \l__tag_mc_firstmarks_seq \l__tag_mc_botmarks_seq |
| 783 |
{ \prg_return_false: } |
| 784 |
{ \prg_return_true: } |
| 785 |
} |
| 786 |
|
| 787 |
\prg_new_conditional:Npnn \__tag_check_if_mc_tmb_missing: { T,F,TF } |
| 788 |
{ |
| 789 |
\bool_if:nTF |
| 790 |
{ |
| 791 |
\str_if_eq_p:ee {\seq_item:Nn \l__tag_mc_firstmarks_seq {1}}{e-} |
| 792 |
|| |
| 793 |
\str_if_eq_p:ee {\seq_item:Nn \l__tag_mc_firstmarks_seq {1}}{b+} |
| 794 |
} |
| 795 |
{ \prg_return_true: } |
| 796 |
{ \prg_return_false: } |
| 797 |
} |
| 798 |
|
| 799 |
\prg_new_conditional:Npnn \__tag_check_if_mc_tme_missing: { T,F,TF } |
| 800 |
{ |
| 801 |
\str_if_eq:eeTF {\seq_item:Nn \l__tag_mc_botmarks_seq {1}}{b+} |
| 802 |
{ \prg_return_true: } |
| 803 |
{ \prg_return_false: } |
| 804 |
} |
| 805 |
\cs_new_protected:Npn \__tag_check_benchmark_tic:{} |
| 806 |
\cs_new_protected:Npn \__tag_check_benchmark_toc:{} |
| 807 |
\cs_new_protected:Npn \tag_check_benchmark_on: |
| 808 |
{ |
| 809 |
\cs_if_exist:NT \benchmark_tic: |
| 810 |
{ |
| 811 |
\cs_set_eq:NN \__tag_check_benchmark_tic: \benchmark_tic: |
| 812 |
\cs_set_eq:NN \__tag_check_benchmark_toc: \benchmark_toc: |
| 813 |
} |
| 814 |
} |
| 815 |
%% File: tagpdf-mc-shared.dtx |
| 816 |
\cs_new:Npn \__tag_get_mc_abs_cnt: { \int_use:N \c@g__tag_MCID_abs_int } |
| 817 |
\bool_new:N \g__tag_in_mc_bool |
| 818 |
\__tag_prop_new_linked:N \g__tag_mc_parenttree_prop |
| 819 |
\seq_new:N \g__tag_mc_stack_seq |
| 820 |
\tl_new:N \l__tag_mc_artifact_type_tl |
| 821 |
\bool_new:N \l__tag_mc_key_stash_bool |
| 822 |
\bool_new:N \l__tag_mc_artifact_bool |
| 823 |
\tl_new:N \l__tag_mc_lang_tl |
| 824 |
\tl_new:N \l__tag_mc_key_tag_tl |
| 825 |
\tl_new:N \g__tag_mc_key_tag_tl |
| 826 |
\tl_new:N \l__tag_mc_key_label_tl |
| 827 |
\tl_new:N \l__tag_mc_key_properties_tl |
| 828 |
\cs_new:Npn \__tag_mc_handle_mc_label:e #1 |
| 829 |
{ |
| 830 |
\__tag_property_record:en{tagpdf-#1}{tagabspage,tagmcabs} |
| 831 |
} |
| 832 |
\cs_new_protected:Npn \__tag_mc_set_label_used:n #1 %#1 labelname |
| 833 |
{ |
| 834 |
\tl_new:c { g__tag_mc_label_\tl_to_str:n{#1}_used_tl } |
| 835 |
} |
| 836 |
\cs_set_protected:Npn \tag_mc_use:n #1 %#1: label name |
| 837 |
{ |
| 838 |
\__tag_check_if_active_struct:T |
| 839 |
{ |
| 840 |
\tl_set:Ne \l__tag_tmpa_tl { \property_ref:nnn{tagpdf-#1}{tagmcabs}{} } |
| 841 |
\tl_if_empty:NTF\l__tag_tmpa_tl |
| 842 |
{ |
| 843 |
\msg_warning:nnn {tag} {mc-label-unknown} {#1} |
| 844 |
} |
| 845 |
{ |
| 846 |
\cs_if_free:cTF { g__tag_mc_label_\tl_to_str:n{#1}_used_tl } |
| 847 |
{ |
| 848 |
\__tag_mc_handle_stash:e { \l__tag_tmpa_tl } |
| 849 |
\__tag_mc_set_label_used:n {#1} |
| 850 |
} |
| 851 |
{ |
| 852 |
\msg_warning:nnn {tag}{mc-used-twice}{#1} |
| 853 |
} |
| 854 |
} |
| 855 |
} |
| 856 |
} |
| 857 |
\cs_set_protected:Npn \tag_mc_artifact_group_begin:n #1 |
| 858 |
{ |
| 859 |
\tag_mc_end_push: |
| 860 |
\tag_mc_begin:n {artifact=#1} |
| 861 |
\group_begin: |
| 862 |
\tag_suspend:n{artifact-group} |
| 863 |
} |
| 864 |
|
| 865 |
\cs_set_protected:Npn \tag_mc_artifact_group_end: |
| 866 |
{ |
| 867 |
\tag_resume:n{artifact-group} |
| 868 |
\group_end: |
| 869 |
\tag_mc_end: |
| 870 |
\tag_mc_begin_pop:n{} |
| 871 |
} |
| 872 |
\cs_set_protected:Npn \tag_mc_end_push: |
| 873 |
{ |
| 874 |
\__tag_check_if_active_mc:T |
| 875 |
{ |
| 876 |
\__tag_mc_if_in:TF |
| 877 |
{ |
| 878 |
\seq_gpush:Ne \g__tag_mc_stack_seq { \tag_get:n {mc_tag} } |
| 879 |
\__tag_check_mc_pushed_popped:nn |
| 880 |
{ pushed } |
| 881 |
{ \tag_get:n {mc_tag} } |
| 882 |
\tag_mc_end: |
| 883 |
} |
| 884 |
{ |
| 885 |
\seq_gpush:Nn \g__tag_mc_stack_seq {-1} |
| 886 |
\__tag_check_mc_pushed_popped:nn { pushed }{-1} |
| 887 |
} |
| 888 |
} |
| 889 |
} |
| 890 |
|
| 891 |
\cs_set_protected:Npn \tag_mc_begin_pop:n #1 |
| 892 |
{ |
| 893 |
\__tag_check_if_active_mc:T |
| 894 |
{ |
| 895 |
\seq_gpop:NNTF \g__tag_mc_stack_seq \l__tag_tmpa_tl |
| 896 |
{ |
| 897 |
\tl_if_eq:NnTF \l__tag_tmpa_tl {-1} |
| 898 |
{ |
| 899 |
\__tag_check_mc_pushed_popped:nn {popped}{-1} |
| 900 |
} |
| 901 |
{ |
| 902 |
\__tag_check_mc_pushed_popped:nn {popped}{\l__tag_tmpa_tl} |
| 903 |
\tag_mc_begin:n {tag=\l__tag_tmpa_tl,#1} |
| 904 |
} |
| 905 |
} |
| 906 |
{ |
| 907 |
\__tag_check_mc_pushed_popped:nn {popped}{empty~stack,~nothing} |
| 908 |
} |
| 909 |
} |
| 910 |
} |
| 911 |
\cs_new_protected:Npn \__tag_mc_check_parent_child:n #1 |
| 912 |
{ |
| 913 |
\int_compare:nNnT {\l__tag_loglevel_int} > { 0 } |
| 914 |
{ |
| 915 |
\prop_get:cnN{g__tag_struct_#1_prop}{tag}\l__tag_get_parent_tmpa_tl |
| 916 |
\msg_note:nnee |
| 917 |
{ tag } |
| 918 |
{ role-parent-child-check } |
| 919 |
{ |
| 920 |
\quark_if_no_value:NTF \l__tag_get_parent_tmpa_tl |
| 921 |
{??} |
| 922 |
{ |
| 923 |
\exp_last_unbraced:No\use_ii:nn |
| 924 |
{ \l__tag_get_parent_tmpa_tl } |
| 925 |
: |
| 926 |
\exp_last_unbraced:No\use_i:nn |
| 927 |
{ \l__tag_get_parent_tmpa_tl } |
| 928 |
} |
| 929 |
} |
| 930 |
{ |
| 931 |
MC~(real~content) |
| 932 |
} |
| 933 |
} |
| 934 |
\__tag_struct_get_role:nnNN |
| 935 |
{#1} |
| 936 |
{rolemap} |
| 937 |
\l__tag_get_parent_tmpa_tl |
| 938 |
\l__tag_get_parent_tmpb_tl |
| 939 |
\__tag_role_check_parent_child:ooooN |
| 940 |
{ \l__tag_get_parent_tmpa_tl } |
| 941 |
{ \l__tag_get_parent_tmpb_tl } |
| 942 |
{ MC } % |
| 943 |
{ } % |
| 944 |
\l__tag_parent_child_check_tl |
| 945 |
\int_compare:nNnT {\l__tag_parent_child_check_tl} = { \c__tag_role_rule_checkparent_tl } |
| 946 |
{ |
| 947 |
\__tag_struct_get_role:nnNN |
| 948 |
{#1} |
| 949 |
{parentrole} |
| 950 |
\l__tag_get_parent_tmpa_tl |
| 951 |
\l__tag_get_parent_tmpb_tl |
| 952 |
\__tag_role_check_parent_child:ooooN |
| 953 |
{ \l__tag_get_parent_tmpa_tl } |
| 954 |
{ \l__tag_get_parent_tmpb_tl } |
| 955 |
{ MC } % |
| 956 |
{ } % |
| 957 |
\l__tag_parent_child_check_tl |
| 958 |
} |
| 959 |
\__tag_check_forbidden_parent_child:nnee |
| 960 |
{\l__tag_parent_child_check_tl} |
| 961 |
{#1} |
| 962 |
{ |
| 963 |
\l__tag_get_parent_tmpb_tl : \l__tag_get_parent_tmpa_tl |
| 964 |
} |
| 965 |
{ |
| 966 |
MC~(real content) |
| 967 |
} |
| 968 |
} |
| 969 |
\cs_generate_variant:Nn \__tag_mc_check_parent_child:n {o} |
| 970 |
\keys_define:nn { __tag / mc } |
| 971 |
{ |
| 972 |
stash .bool_set:N = \l__tag_mc_key_stash_bool, |
| 973 |
__artifact-bool .bool_set:N = \l__tag_mc_artifact_bool, |
| 974 |
__artifact-type .choice:, |
| 975 |
__artifact-type / pagination .code:n = |
| 976 |
{ |
| 977 |
\tl_set:Nn \l__tag_mc_artifact_type_tl { Pagination } |
| 978 |
}, |
| 979 |
__artifact-type / pagination/header .code:n = |
| 980 |
{ |
| 981 |
\tl_set:Nn \l__tag_mc_artifact_type_tl { Pagination/Subtype/Header } |
| 982 |
}, |
| 983 |
__artifact-type / pagination/footer .code:n = |
| 984 |
{ |
| 985 |
\tl_set:Nn \l__tag_mc_artifact_type_tl { Pagination/Subtype/Footer } |
| 986 |
}, |
| 987 |
__artifact-type / layout .code:n = |
| 988 |
{ |
| 989 |
\tl_set:Nn \l__tag_mc_artifact_type_tl { Layout } |
| 990 |
}, |
| 991 |
__artifact-type / page .code:n = |
| 992 |
{ |
| 993 |
\tl_set:Nn \l__tag_mc_artifact_type_tl { Page } |
| 994 |
}, |
| 995 |
__artifact-type / background .code:n = |
| 996 |
{ |
| 997 |
\tl_set:Nn \l__tag_mc_artifact_type_tl { Background } |
| 998 |
}, |
| 999 |
__artifact-type / notype .code:n = |
| 1000 |
{ |
| 1001 |
\tl_set:Nn \l__tag_mc_artifact_type_tl {} |
| 1002 |
}, |
| 1003 |
__artifact-type / .code:n = |
| 1004 |
{ |
| 1005 |
\tl_set:Nn \l__tag_mc_artifact_type_tl {} |
| 1006 |
}, |
| 1007 |
} |
| 1008 |
%% File: tagpdf.dtx |
| 1009 |
\bool_if:NTF \g__tag_mode_lua_bool |
| 1010 |
{ |
| 1011 |
\RequirePackage {tagpdf-mc-code-lua} |
| 1012 |
} |
| 1013 |
{ |
| 1014 |
\RequirePackage {tagpdf-mc-code-generic} % |
| 1015 |
} |
| 1016 |
%% File: tagpdf-tree.dtx |
| 1017 |
\hook_gput_code:nnn{begindocument}{tagpdf} |
| 1018 |
{ |
| 1019 |
\bool_if:NT \g__tag_active_tree_bool |
| 1020 |
{ |
| 1021 |
\sys_if_output_pdf:TF |
| 1022 |
{ |
| 1023 |
\AddToHook{enddocument/end} { \__tag_finish_structure: } |
| 1024 |
} |
| 1025 |
{ |
| 1026 |
\AddToHook{shipout/lastpage} { \__tag_finish_structure: } |
| 1027 |
} |
| 1028 |
} |
| 1029 |
} |
| 1030 |
\cs_new_protected:Npn \__tag_tree_final_checks: |
| 1031 |
{ |
| 1032 |
\int_compare:nNnF {\seq_count:N\g__tag_struct_stack_seq}={1} |
| 1033 |
{ |
| 1034 |
\msg_warning:nn {tag}{tree-struct-still-open} |
| 1035 |
\int_step_inline:nnn{2}{\seq_count:N\g__tag_struct_stack_seq} |
| 1036 |
{\tag_struct_end:} |
| 1037 |
} |
| 1038 |
\socket_use:n { tag/check/parent-child-end } |
| 1039 |
\msg_note:nn {tag}{tree-statistic} |
| 1040 |
} |
| 1041 |
\pdf_object_new_indexed:nn { __tag/struct }{ 1 } |
| 1042 |
\tl_new:N \g__tag_tree_openaction_struct_tl |
| 1043 |
\tl_gset:Nn \g__tag_tree_openaction_struct_tl { 2 } |
| 1044 |
\keys_define:nn { __tag / setup } |
| 1045 |
{ |
| 1046 |
viewer/startstructure .code:n = |
| 1047 |
{ |
| 1048 |
\tl_gset:Ne \g__tag_tree_openaction_struct_tl {#1} |
| 1049 |
} |
| 1050 |
,viewer/startstructure .default:n = { \int_use:N \c@g__tag_struct_abs_int } |
| 1051 |
} |
| 1052 |
\cs_new_protected:Npn \__tag_tree_update_openaction: |
| 1053 |
{ |
| 1054 |
\prop_get:cnNT |
| 1055 |
{ \__kernel_pdfdict_name:n { g__pdf_Core/Catalog } } |
| 1056 |
{OpenAction} |
| 1057 |
\l__tag_tmpa_tl |
| 1058 |
{ |
| 1059 |
\tl_if_head_eq_charcode:eNT { \tl_trim_spaces:o { \l__tag_tmpa_tl } } [ %] |
| 1060 |
{ |
| 1061 |
\seq_set_split:Nno\l__tag_tmpa_seq {/} {\l__tag_tmpa_tl} |
| 1062 |
\pdfmanagement_add:nne {Catalog} { OpenAction } |
| 1063 |
{ |
| 1064 |
<< |
| 1065 |
/S/GoTo \c_space_tl |
| 1066 |
/D~\l__tag_tmpa_tl\c_space_tl |
| 1067 |
/SD~[\pdf_object_ref_indexed:nn{__tag/struct}{\g__tag_tree_openaction_struct_tl} |
| 1068 |
\int_compare:nNnTF{ \seq_count:N \l__tag_tmpa_seq } > {1} |
| 1069 |
{ /\seq_item:Nn\l__tag_tmpa_seq{2} } |
| 1070 |
{ ] } |
| 1071 |
>> |
| 1072 |
} |
| 1073 |
} |
| 1074 |
} |
| 1075 |
} |
| 1076 |
\hook_gput_code:nnn{shipout/lastpage}{tagpdf} |
| 1077 |
{ |
| 1078 |
\bool_if:NT \g__tag_active_tree_bool |
| 1079 |
{ |
| 1080 |
\pdfmanagement_add:nnn { Catalog / MarkInfo } { Marked } { true } |
| 1081 |
\pdfmanagement_add:nne |
| 1082 |
{ Catalog } |
| 1083 |
{ StructTreeRoot } |
| 1084 |
{ \pdf_object_ref_indexed:nn { __tag/struct } { 1 } } |
| 1085 |
\__tag_tree_update_openaction: |
| 1086 |
} |
| 1087 |
} |
| 1088 |
\int_new:N\g__tag_tree_id_pad_int |
| 1089 |
\cs_generate_variant:Nn \tl_count:n {e} |
| 1090 |
\hook_gput_code:nnn{begindocument}{tagpdf} |
| 1091 |
{ |
| 1092 |
\int_gset:Nn\g__tag_tree_id_pad_int |
| 1093 |
{\tl_count:e { \__tag_property_ref_lastpage:nn{tagstruct}{1000}}+1} |
| 1094 |
} |
| 1095 |
|
| 1096 |
\cs_new_protected:Npn \__tag_tree_write_idtree: |
| 1097 |
{ |
| 1098 |
\tl_clear:N \l__tag_tmpa_tl |
| 1099 |
\tl_clear:N \l__tag_tmpb_tl |
| 1100 |
\int_zero:N \l__tag_tmpa_int |
| 1101 |
\int_step_inline:nnn {2} {\c@g__tag_struct_abs_int} |
| 1102 |
{ |
| 1103 |
\int_incr:N\l__tag_tmpa_int |
| 1104 |
\tl_put_right:Ne \l__tag_tmpa_tl |
| 1105 |
{ |
| 1106 |
\__tag_struct_get_id:n{##1}~\pdf_object_ref_indexed:nn {__tag/struct}{##1}~ |
| 1107 |
} |
| 1108 |
\int_compare:nNnF {\l__tag_tmpa_int}<{50} % |
| 1109 |
{ |
| 1110 |
\pdf_object_unnamed_write:ne {dict} |
| 1111 |
{ /Limits~[\__tag_struct_get_id:n{##1-\l__tag_tmpa_int+1}~\__tag_struct_get_id:n{##1}] |
| 1112 |
/Names~[\l__tag_tmpa_tl] |
| 1113 |
} |
| 1114 |
\tl_put_right:Ne\l__tag_tmpb_tl {\pdf_object_ref_last:\c_space_tl} |
| 1115 |
\int_zero:N \l__tag_tmpa_int |
| 1116 |
\tl_clear:N \l__tag_tmpa_tl |
| 1117 |
} |
| 1118 |
} |
| 1119 |
\tl_if_empty:NF \l__tag_tmpa_tl |
| 1120 |
{ |
| 1121 |
\pdf_object_unnamed_write:ne {dict} |
| 1122 |
{ |
| 1123 |
/Limits~ |
| 1124 |
[\__tag_struct_get_id:n{\c@g__tag_struct_abs_int-\l__tag_tmpa_int+1}~ |
| 1125 |
\__tag_struct_get_id:n{\c@g__tag_struct_abs_int}] |
| 1126 |
/Names~[\l__tag_tmpa_tl] |
| 1127 |
} |
| 1128 |
\tl_put_right:Ne\l__tag_tmpb_tl {\pdf_object_ref_last:} |
| 1129 |
} |
| 1130 |
\pdf_object_unnamed_write:ne {dict}{/Kids~[\l__tag_tmpb_tl]} |
| 1131 |
\__tag_prop_gput:cne |
| 1132 |
{ g__tag_struct_1_prop } |
| 1133 |
{ IDTree } |
| 1134 |
{ \pdf_object_ref_last: } |
| 1135 |
} |
| 1136 |
\cs_new_protected:Npn \__tag_tree_write_structtreeroot: |
| 1137 |
{ |
| 1138 |
\__tag_prop_gput:cne |
| 1139 |
{ g__tag_struct_1_prop } |
| 1140 |
{ ParentTree } |
| 1141 |
{ \pdf_object_ref:n { __tag/tree/parenttree } } |
| 1142 |
\__tag_prop_gput:cne |
| 1143 |
{ g__tag_struct_1_prop } |
| 1144 |
{ RoleMap } |
| 1145 |
{ \pdf_object_ref:n { __tag/tree/rolemap } } |
| 1146 |
\__tag_struct_fill_kid_key:n { 1 } |
| 1147 |
\prop_gremove:cn { g__tag_struct_1_prop } {S} |
| 1148 |
\__tag_struct_get_dict_content:nN { 1 } \l__tag_tmpa_tl |
| 1149 |
\pdf_object_write_indexed:nnne |
| 1150 |
{ __tag/struct } { 1 } |
| 1151 |
{dict} |
| 1152 |
{ |
| 1153 |
\l__tag_tmpa_tl |
| 1154 |
} |
| 1155 |
\prop_gput:cnn { g__tag_struct_1_prop } {S}{ /StructTreeRoot } |
| 1156 |
} |
| 1157 |
\cs_new_protected:Npn \__tag_tree_write_structelements: |
| 1158 |
{ |
| 1159 |
\int_step_inline:nnnn {2}{1}{\c@g__tag_struct_abs_int} |
| 1160 |
{ |
| 1161 |
\__tag_struct_write_obj:n { ##1 } |
| 1162 |
} |
| 1163 |
} |
| 1164 |
\pdf_object_new:n { __tag/tree/parenttree } |
| 1165 |
\int_new:N \c@g__tag_parenttree_obj_int |
| 1166 |
\hook_gput_code:nnn{begindocument}{tagpdf} |
| 1167 |
{ |
| 1168 |
\int_gset:Nn |
| 1169 |
\c@g__tag_parenttree_obj_int |
| 1170 |
{ \__tag_property_ref_lastpage:nn{abspage}{100} } |
| 1171 |
} |
| 1172 |
\tl_new:N \g__tag_parenttree_objr_tl |
| 1173 |
\cs_new_protected:Npn \__tag_parenttree_add_objr:nn #1 #2 %#1 StructParent number, #2 objref |
| 1174 |
{ |
| 1175 |
\tl_gput_right:Ne \g__tag_parenttree_objr_tl |
| 1176 |
{ |
| 1177 |
#1 \c_space_tl #2 ^^J |
| 1178 |
} |
| 1179 |
} |
| 1180 |
\tl_new:N \l__tag_parenttree_content_tl |
| 1181 |
\cs_new_protected:Npn \__tag_tree_parenttree_rerun_msg: {} |
| 1182 |
\cs_new_protected:Npn \__tag_tree_fill_parenttree: |
| 1183 |
{ |
| 1184 |
\int_step_inline:nnnn{1}{1}{\__tag_property_ref_lastpage:nn{abspage}{-1}} %not quite clear if labels are needed. See lua code |
| 1185 |
{ %page ##1 |
| 1186 |
\prop_clear:N \l__tag_tmpa_prop |
| 1187 |
\int_step_inline:nnnn{1}{1}{\__tag_property_ref_lastpage:nn{tagmcabs}{-1}} |
| 1188 |
{ |
| 1189 |
%mcid####1 |
| 1190 |
\int_compare:nT |
| 1191 |
{\property_ref:enn{mcid-####1}{tagabspage}{-1}=##1} %mcid is on current page |
| 1192 |
{% yes |
| 1193 |
\prop_get:NnNT |
| 1194 |
\g__tag_mc_parenttree_prop |
| 1195 |
{####1} |
| 1196 |
\l__tag_tmpa_tl |
| 1197 |
{ |
| 1198 |
\prop_put:Nee |
| 1199 |
\l__tag_tmpa_prop |
| 1200 |
{\property_ref:enn{mcid-####1}{tagmcid}{-1}} |
| 1201 |
{\l__tag_tmpa_tl} |
| 1202 |
} |
| 1203 |
} |
| 1204 |
} |
| 1205 |
\tl_put_right:Ne\l__tag_parenttree_content_tl |
| 1206 |
{ |
| 1207 |
\int_eval:n {##1-1}\c_space_tl |
| 1208 |
[\c_space_tl %] |
| 1209 |
} |
| 1210 |
\int_step_inline:nnnn %####1 |
| 1211 |
{0} |
| 1212 |
{1} |
| 1213 |
{ \prop_count:N \l__tag_tmpa_prop -1 } |
| 1214 |
{ |
| 1215 |
\prop_get:NnNTF \l__tag_tmpa_prop {####1} \l__tag_tmpa_tl |
| 1216 |
{% page#1:mcid##1:\l__tag_tmpa_tl :content |
| 1217 |
\tl_put_right:Ne \l__tag_parenttree_content_tl |
| 1218 |
{ |
| 1219 |
\prop_if_exist:cTF { g__tag_struct_ \l__tag_tmpa_tl _prop } |
| 1220 |
{ |
| 1221 |
\pdf_object_ref_indexed:nn { __tag/struct }{ \l__tag_tmpa_tl } |
| 1222 |
} |
| 1223 |
{ |
| 1224 |
null |
| 1225 |
} |
| 1226 |
\c_space_tl |
| 1227 |
} |
| 1228 |
} |
| 1229 |
{ |
| 1230 |
\cs_set_protected:Npn \__tag_tree_parenttree_rerun_msg: |
| 1231 |
{ |
| 1232 |
\msg_warning:nn { tag } {tree-mcid-index-wrong} |
| 1233 |
} |
| 1234 |
} |
| 1235 |
} |
| 1236 |
\tl_put_right:Nn |
| 1237 |
\l__tag_parenttree_content_tl |
| 1238 |
{%[ |
| 1239 |
]^^J |
| 1240 |
} |
| 1241 |
} |
| 1242 |
} |
| 1243 |
\cs_new_protected:Npn \__tag_tree_lua_fill_parenttree: |
| 1244 |
{ |
| 1245 |
\tl_set:Nn \l__tag_parenttree_content_tl |
| 1246 |
{ |
| 1247 |
\lua_now:e |
| 1248 |
{ |
| 1249 |
ltx.__tag.func.output_parenttree |
| 1250 |
( |
| 1251 |
\int_use:N\g_shipout_readonly_int |
| 1252 |
) |
| 1253 |
} |
| 1254 |
} |
| 1255 |
} |
| 1256 |
\cs_new_protected:Npn \__tag_tree_write_parenttree: |
| 1257 |
{ |
| 1258 |
\bool_if:NTF \g__tag_mode_lua_bool |
| 1259 |
{ |
| 1260 |
\__tag_tree_lua_fill_parenttree: |
| 1261 |
} |
| 1262 |
{ |
| 1263 |
\__tag_tree_fill_parenttree: |
| 1264 |
} |
| 1265 |
\__tag_tree_parenttree_rerun_msg: |
| 1266 |
\tl_put_right:No \l__tag_parenttree_content_tl { \g__tag_parenttree_objr_tl } |
| 1267 |
\pdf_object_write:nne { __tag/tree/parenttree }{dict} |
| 1268 |
{ |
| 1269 |
/Nums\c_space_tl [\l__tag_parenttree_content_tl] |
| 1270 |
} |
| 1271 |
} |
| 1272 |
\pdf_object_new:n { __tag/tree/rolemap } |
| 1273 |
\cs_new_protected:Npn \__tag_tree_write_rolemap: |
| 1274 |
{ |
| 1275 |
\bool_if:NT \g__tag_role_add_mathml_bool |
| 1276 |
{ |
| 1277 |
\prop_map_inline:Nn \g__tag_role_NS_mathml_prop |
| 1278 |
{ |
| 1279 |
\prop_gput:Nnn \g__tag_role_rolemap_prop {##1}{Span} |
| 1280 |
} |
| 1281 |
} |
| 1282 |
\prop_map_inline:Nn\g__tag_role_rolemap_prop |
| 1283 |
{ |
| 1284 |
\tl_if_eq:nnF {##1}{##2} |
| 1285 |
{ |
| 1286 |
\pdfdict_gput:nne {g__tag_role/RoleMap_dict} |
| 1287 |
{##1} |
| 1288 |
{\pdf_name_from_unicode_e:n{##2}} |
| 1289 |
} |
| 1290 |
} |
| 1291 |
\pdf_object_write:nne { __tag/tree/rolemap }{dict} |
| 1292 |
{ |
| 1293 |
\pdfdict_use:n{g__tag_role/RoleMap_dict} |
| 1294 |
} |
| 1295 |
} |
| 1296 |
\cs_new_protected:Npn \__tag_tree_write_classmap: |
| 1297 |
{ |
| 1298 |
\tl_clear:N \l__tag_tmpa_tl |
| 1299 |
\seq_map_inline:Nn \g__tag_attr_class_used_seq |
| 1300 |
{ |
| 1301 |
\prop_gput:Nnn \g__tag_attr_class_used_prop {##1}{} |
| 1302 |
} |
| 1303 |
\prop_map_inline:Nn \g__tag_attr_class_used_prop |
| 1304 |
{ |
| 1305 |
\prop_get:NnNT \g__tag_attr_entries_prop {##1} \l__tag_tmpb_tl |
| 1306 |
{ |
| 1307 |
\tl_put_right:Ne \l__tag_tmpa_tl |
| 1308 |
{ |
| 1309 |
##1\c_space_tl |
| 1310 |
<< |
| 1311 |
\l__tag_tmpb_tl |
| 1312 |
>> |
| 1313 |
\iow_newline: |
| 1314 |
} |
| 1315 |
} |
| 1316 |
} |
| 1317 |
\tl_if_empty:NF |
| 1318 |
\l__tag_tmpa_tl |
| 1319 |
{ |
| 1320 |
\pdf_object_new:n { __tag/tree/classmap } |
| 1321 |
\pdf_object_write:nne |
| 1322 |
{ __tag/tree/classmap } |
| 1323 |
{dict} |
| 1324 |
{ \l__tag_tmpa_tl } |
| 1325 |
\__tag_prop_gput:cne |
| 1326 |
{ g__tag_struct_1_prop } |
| 1327 |
{ ClassMap } |
| 1328 |
{ \pdf_object_ref:n { __tag/tree/classmap } } |
| 1329 |
} |
| 1330 |
} |
| 1331 |
\pdf_object_new:n { __tag/tree/namespaces } |
| 1332 |
\cs_new_protected:Npn \__tag_tree_write_namespaces: |
| 1333 |
{ |
| 1334 |
\pdf_version_compare:NnF < {2.0} |
| 1335 |
{ |
| 1336 |
\prop_map_inline:Nn \g__tag_role_NS_prop |
| 1337 |
{ |
| 1338 |
\pdfdict_if_empty:nF {g__tag_role/RoleMapNS_##1_dict} |
| 1339 |
{ |
| 1340 |
\pdf_object_write:nne {__tag/RoleMapNS/##1}{dict} |
| 1341 |
{ |
| 1342 |
\pdfdict_use:n {g__tag_role/RoleMapNS_##1_dict} |
| 1343 |
} |
| 1344 |
\pdfdict_gput:nne{g__tag_role/Namespace_##1_dict} |
| 1345 |
{RoleMapNS}{\pdf_object_ref:n {__tag/RoleMapNS/##1}} |
| 1346 |
} |
| 1347 |
\pdf_object_write:nne{tag/NS/##1}{dict} |
| 1348 |
{ |
| 1349 |
\pdfdict_use:n {g__tag_role/Namespace_##1_dict} |
| 1350 |
} |
| 1351 |
} |
| 1352 |
\pdf_object_write:nne {__tag/tree/namespaces}{array} |
| 1353 |
{ |
| 1354 |
\prop_map_tokens:Nn \g__tag_role_NS_prop{\use_ii:nn} |
| 1355 |
} |
| 1356 |
} |
| 1357 |
} |
| 1358 |
\hook_new:n {tagpdf/finish/before} |
| 1359 |
\cs_new_protected:Npn \__tag_finish_structure: |
| 1360 |
{ |
| 1361 |
\bool_if:NT\g__tag_active_tree_bool |
| 1362 |
{ |
| 1363 |
\hook_use:n {tagpdf/finish/before} |
| 1364 |
\__tag_tree_final_checks: |
| 1365 |
\iow_term:n{Package~tagpdf~Info:~writing~ParentTree} |
| 1366 |
\__tag_check_benchmark_tic: |
| 1367 |
\__tag_tree_write_parenttree: |
| 1368 |
\__tag_check_benchmark_toc: |
| 1369 |
\iow_term:n{Package~tagpdf~Info:~writing~IDTree} |
| 1370 |
\__tag_check_benchmark_tic: |
| 1371 |
\__tag_tree_write_idtree: |
| 1372 |
\__tag_check_benchmark_toc: |
| 1373 |
\iow_term:n{Package~tagpdf~Info:~writing~RoleMap} |
| 1374 |
\__tag_check_benchmark_tic: |
| 1375 |
\__tag_tree_write_rolemap: |
| 1376 |
\__tag_check_benchmark_toc: |
| 1377 |
\iow_term:n{Package~tagpdf~Info:~writing~ClassMap} |
| 1378 |
\__tag_check_benchmark_tic: |
| 1379 |
\__tag_tree_write_classmap: |
| 1380 |
\__tag_check_benchmark_toc: |
| 1381 |
\iow_term:n{Package~tagpdf~Info:~writing~NameSpaces} |
| 1382 |
\__tag_check_benchmark_tic: |
| 1383 |
\__tag_tree_write_namespaces: |
| 1384 |
\__tag_check_benchmark_toc: |
| 1385 |
\iow_term:n{Package~tagpdf~Info:~writing~StructElems} |
| 1386 |
\__tag_check_benchmark_tic: |
| 1387 |
\__tag_tree_write_structelements: %this is rather slow!! |
| 1388 |
\__tag_check_benchmark_toc: |
| 1389 |
\iow_term:n{Package~tagpdf~Info:~writing~Root} |
| 1390 |
\__tag_check_benchmark_tic: |
| 1391 |
\__tag_tree_write_structtreeroot: |
| 1392 |
\__tag_check_benchmark_toc: |
| 1393 |
} |
| 1394 |
} |
| 1395 |
\hook_gput_code:nnn{begindocument}{tagpdf} |
| 1396 |
{ |
| 1397 |
\bool_if:NT\g__tag_active_tree_bool |
| 1398 |
{ |
| 1399 |
\hook_gput_code:nnn{shipout/before} { tagpdf/structparents } |
| 1400 |
{ |
| 1401 |
\pdfmanagement_add:nne |
| 1402 |
{ Page } |
| 1403 |
{ StructParents } |
| 1404 |
{ \int_eval:n { \g_shipout_readonly_int} } |
| 1405 |
} |
| 1406 |
} |
| 1407 |
} |
| 1408 |
%% File: tagpdf-data.dtx |
| 1409 |
\prop_const_from_keyval:Nn \c__tag_role_rules_prop |
| 1410 |
{ |
| 1411 |
0..n = 1, |
| 1412 |
0..1 = 2, |
| 1413 |
1 = 3, %StructTreeRoot, not really needed |
| 1414 |
[a] = 4, %ruby |
| 1415 |
[b] = 5, %warichu |
| 1416 |
c = 6, % WP ?? |
| 1417 |
‡ = 7, % Part,Div,NonStruct -> "check parent" |
| 1418 |
∅* = 8, % or negative by default? |
| 1419 |
∅ = -1, |
| 1420 |
} |
| 1421 |
\tl_const:Nn \c__tag_role_rule_checkparent_tl {7} |
| 1422 |
\prop_const_from_keyval:Nn \c__tag_role_rules_num_prop |
| 1423 |
{ |
| 1424 |
1 = 0..n, |
| 1425 |
2 = 0..1, |
| 1426 |
3 = 1 , %StructTreeRoot, not really needed |
| 1427 |
4 = [a] , %ruby |
| 1428 |
5 = [b] , %warichu |
| 1429 |
6 = c , % WP ?? |
| 1430 |
7 = ‡ , % Part,Div,NonStruct -> "check parent" |
| 1431 |
8 = ∅* , % or negative by default? |
| 1432 |
-1 = ∅ , |
| 1433 |
} |
| 1434 |
%% File: tagpdf-roles.dtx |
| 1435 |
\prop_new_linked:N \g__tag_role_tags_NS_prop |
| 1436 |
\prop_new:N \g__tag_role_tags_class_prop |
| 1437 |
\prop_new:N \g__tag_role_NS_prop |
| 1438 |
\prop_new:N \g__tag_role_index_prop |
| 1439 |
\prop_new:N \l__tag_role_debug_prop |
| 1440 |
\tl_new:N \l__tag_role_tag_tmpa_tl |
| 1441 |
\tl_new:N \l__tag_role_tag_namespace_tmpa_tl |
| 1442 |
\tl_new:N \l__tag_role_tag_namespace_tmpb_tl |
| 1443 |
\tl_new:N \l__tag_role_role_tmpa_tl |
| 1444 |
\tl_new:N \l__tag_role_role_namespace_tmpa_tl |
| 1445 |
\seq_new:N\l__tag_role_tmpa_seq |
| 1446 |
\pdfdict_new:n {g__tag_role/RoleMap_dict} |
| 1447 |
\__tag_prop_new:N \g__tag_role_rolemap_prop |
| 1448 |
\pdf_version_compare:NnTF < {2.0} |
| 1449 |
{ |
| 1450 |
\cs_new_protected:Npn \__tag_role_NS_new:nnn #1 #2 #3 |
| 1451 |
{ |
| 1452 |
\__tag_prop_new:c { g__tag_role_NS_#1_prop } |
| 1453 |
\prop_new:c { g__tag_role_NS_#1_class_prop } |
| 1454 |
\prop_gput:Nne \g__tag_role_NS_prop {#1}{} |
| 1455 |
} |
| 1456 |
} |
| 1457 |
{ |
| 1458 |
\cs_new_protected:Npn \__tag_role_NS_new:nnn #1 #2 #3 |
| 1459 |
{ |
| 1460 |
\__tag_prop_new:c { g__tag_role_NS_#1_prop } |
| 1461 |
\prop_new:c { g__tag_role_NS_#1_class_prop } |
| 1462 |
\pdf_object_new:n {tag/NS/#1} |
| 1463 |
\pdfdict_new:n {g__tag_role/Namespace_#1_dict} |
| 1464 |
\pdf_object_new:n {__tag/RoleMapNS/#1} |
| 1465 |
\pdfdict_new:n {g__tag_role/RoleMapNS_#1_dict} |
| 1466 |
\pdfdict_gput:nnn |
| 1467 |
{g__tag_role/Namespace_#1_dict} |
| 1468 |
{Type} |
| 1469 |
{/Namespace} |
| 1470 |
\pdf_string_from_unicode:nnN{utf8/string}{#2}\l__tag_tmpa_str |
| 1471 |
\tl_if_empty:NF \l__tag_tmpa_str |
| 1472 |
{ |
| 1473 |
\pdfdict_gput:nne |
| 1474 |
{g__tag_role/Namespace_#1_dict} |
| 1475 |
{NS} |
| 1476 |
{\l__tag_tmpa_str} |
| 1477 |
} |
| 1478 |
%RoleMapNS is added in tree |
| 1479 |
\tl_if_empty:nF {#3} |
| 1480 |
{ |
| 1481 |
\pdfdict_gput:nne{g__tag_role/Namespace_#1_dict} |
| 1482 |
{Schema}{#3} |
| 1483 |
} |
| 1484 |
\prop_gput:Nne \g__tag_role_NS_prop {#1}{\pdf_object_ref:n{tag/NS/#1}~} |
| 1485 |
} |
| 1486 |
} |
| 1487 |
\str_const:Ne \c__tag_role_userNS_id_str |
| 1488 |
{ data:, |
| 1489 |
\int_to_Hex:n{\int_rand:n {65535}} |
| 1490 |
\int_to_Hex:n{\int_rand:n {65535}} |
| 1491 |
- |
| 1492 |
\int_to_Hex:n{\int_rand:n {65535}} |
| 1493 |
- |
| 1494 |
\int_to_Hex:n{\int_rand:n {65535}} |
| 1495 |
- |
| 1496 |
\int_to_Hex:n{\int_rand:n {65535}} |
| 1497 |
- |
| 1498 |
\int_to_Hex:n{\int_rand:n {16777215}} |
| 1499 |
\int_to_Hex:n{\int_rand:n {16777215}} |
| 1500 |
} |
| 1501 |
\bool_new:N \g__tag_role_add_mathml_bool |
| 1502 |
\__tag_role_NS_new:nnn {pdf} {http://iso.org/pdf/ssn}{} |
| 1503 |
\__tag_role_NS_new:nnn {pdf2} {http://iso.org/pdf2/ssn}{} |
| 1504 |
\__tag_role_NS_new:nnn {mathml}{http://www.w3.org/1998/Math/MathML}{} |
| 1505 |
\__tag_role_NS_new:nnn {latex} {https://www.latex-project.org/ns/dflt}{} |
| 1506 |
\__tag_role_NS_new:nnn {latex-book} {https://www.latex-project.org/ns/book}{} |
| 1507 |
\exp_args:Nne |
| 1508 |
\__tag_role_NS_new:nnn {user}{\c__tag_role_userNS_id_str}{} |
| 1509 |
\pdf_version_compare:NnTF < {2.0} |
| 1510 |
{ |
| 1511 |
\sys_if_engine_luatex:TF |
| 1512 |
{ |
| 1513 |
\cs_new_protected:Npn \__tag_role_alloctag:nnn #1 #2 #3 %#1 tagname, ns, type |
| 1514 |
{ |
| 1515 |
\lua_now:e { ltx.__tag.func.alloctag ('#1') } |
| 1516 |
\prop_gput:Nnn \g__tag_role_tags_NS_prop {#1}{#2} |
| 1517 |
\__tag_prop_gput:cnn {g__tag_role_NS_#2_prop} {#1}{{}{}} |
| 1518 |
\prop_gput:Nnn \g__tag_role_tags_class_prop {#1}{#3} |
| 1519 |
\prop_gput:cnn {g__tag_role_NS_#2_class_prop} {#1}{--UNUSED--} |
| 1520 |
} |
| 1521 |
} |
| 1522 |
{ |
| 1523 |
\cs_new_protected:Npn \__tag_role_alloctag:nnn #1 #2 #3 |
| 1524 |
{ |
| 1525 |
\prop_gput:Nnn \g__tag_role_tags_NS_prop {#1}{#2} |
| 1526 |
\__tag_prop_gput:cnn {g__tag_role_NS_#2_prop} {#1}{{}{}} |
| 1527 |
\prop_gput:Nnn \g__tag_role_tags_class_prop {#1}{#3} |
| 1528 |
\prop_gput:cnn {g__tag_role_NS_#2_class_prop} {#1}{--UNUSED--} |
| 1529 |
} |
| 1530 |
} |
| 1531 |
} |
| 1532 |
{ |
| 1533 |
\sys_if_engine_luatex:TF |
| 1534 |
{ |
| 1535 |
\cs_new_protected:Npn \__tag_role_alloctag:nnn #1 #2 #3 %#1 tagname, ns, type |
| 1536 |
{ |
| 1537 |
\lua_now:e { ltx.__tag.func.alloctag ('#1') } |
| 1538 |
\prop_gput:Nnn \g__tag_role_tags_NS_prop {#1}{#2} |
| 1539 |
\__tag_prop_gput:cnn {g__tag_role_NS_#2_prop} {#1}{{}{}} |
| 1540 |
\prop_gput:Nnn \g__tag_role_tags_class_prop {#1}{--UNUSED--} |
| 1541 |
\prop_gput:cnn {g__tag_role_NS_#2_class_prop} {#1}{#3} |
| 1542 |
} |
| 1543 |
} |
| 1544 |
{ |
| 1545 |
\cs_new_protected:Npn \__tag_role_alloctag:nnn #1 #2 #3 |
| 1546 |
{ |
| 1547 |
\prop_gput:Nnn \g__tag_role_tags_NS_prop {#1}{#2} |
| 1548 |
\__tag_prop_gput:cnn {g__tag_role_NS_#2_prop} {#1}{{}{}} |
| 1549 |
\prop_gput:Nnn \g__tag_role_tags_class_prop {#1}{--UNUSED--} |
| 1550 |
\prop_gput:cnn {g__tag_role_NS_#2_class_prop} {#1}{#3} |
| 1551 |
} |
| 1552 |
} |
| 1553 |
} |
| 1554 |
\cs_generate_variant:Nn \__tag_role_alloctag:nnn {nno} |
| 1555 |
\cs_new_protected:Nn \__tag_role_add_tag:nn % (new) name, reference to old |
| 1556 |
{ |
| 1557 |
\__tag_check_add_tag_role:nn {#1}{#2} |
| 1558 |
\prop_get:NnNF \g__tag_role_tags_NS_prop {#1}\l__tag_tmp_unused_tl |
| 1559 |
{ |
| 1560 |
\int_compare:nNnT {\l__tag_loglevel_int} > { 0 } |
| 1561 |
{ |
| 1562 |
\msg_info:nnn { tag }{new-tag}{#1} |
| 1563 |
} |
| 1564 |
} |
| 1565 |
\prop_get:NnNF \g__tag_role_tags_class_prop {#2}\l__tag_tmpa_tl |
| 1566 |
{ |
| 1567 |
\tl_set:Nn\l__tag_tmpa_tl{--UNKNOWN--} |
| 1568 |
} |
| 1569 |
\__tag_role_alloctag:nno {#1}{user} { \l__tag_tmpa_tl } |
| 1570 |
\tl_if_empty:nF { #2 } |
| 1571 |
{ |
| 1572 |
\prop_get:NnNTF \g__tag_role_rolemap_prop {#2}\l__tag_tmpa_tl |
| 1573 |
{ |
| 1574 |
\__tag_prop_gput:Nno \g__tag_role_rolemap_prop {#1}{\l__tag_tmpa_tl} |
| 1575 |
} |
| 1576 |
{ |
| 1577 |
\__tag_prop_gput:Nne \g__tag_role_rolemap_prop {#1}{\tl_to_str:n{#2}} |
| 1578 |
} |
| 1579 |
} |
| 1580 |
} |
| 1581 |
\cs_generate_variant:Nn \__tag_role_add_tag:nn {oo,ne} |
| 1582 |
\pdf_version_compare:NnT < {2.0} |
| 1583 |
{ |
| 1584 |
\cs_new:Npn \__tag_role_get:nnNN #1#2#3#4 %#1 tag, #2 NS, #3 tlvar which hold the role tag #4 empty |
| 1585 |
{ |
| 1586 |
\prop_get:NnNF \g__tag_role_rolemap_prop {#1}#3 |
| 1587 |
{ |
| 1588 |
\tl_set:Nn #3 {#1} |
| 1589 |
} |
| 1590 |
\tl_set:Nn #4 {} |
| 1591 |
} |
| 1592 |
\cs_generate_variant:Nn \__tag_role_get:nnNN {ooNN} |
| 1593 |
} |
| 1594 |
|
| 1595 |
\cs_new_protected:Nn \__tag_role_add_tag:nnnn %tag/namespace/role/namespace |
| 1596 |
{ |
| 1597 |
\__tag_check_add_tag_role:nnn {#1/#2}{#3}{#4} |
| 1598 |
\int_compare:nNnT {\l__tag_loglevel_int} > { 0 } |
| 1599 |
{ |
| 1600 |
\msg_info:nnn { tag }{new-tag}{#1} |
| 1601 |
} |
| 1602 |
\prop_if_exist:cTF |
| 1603 |
{ g__tag_role_NS_#4_class_prop } |
| 1604 |
{ |
| 1605 |
\prop_get:cnN { g__tag_role_NS_#4_class_prop } {#3}\l__tag_tmpa_tl |
| 1606 |
\quark_if_no_value:NT \l__tag_tmpa_tl |
| 1607 |
{ |
| 1608 |
\tl_set:Nn\l__tag_tmpa_tl{--UNKNOWN--} |
| 1609 |
} |
| 1610 |
} |
| 1611 |
{ \tl_set:Nn\l__tag_tmpa_tl{--UNKNOWN--} } |
| 1612 |
\__tag_role_alloctag:nno {#1}{#2}{ \l__tag_tmpa_tl } |
| 1613 |
\tl_if_in:nnF {-pdf-pdf2-mathml-}{-#2-} |
| 1614 |
{ |
| 1615 |
\pdfdict_gput:nne {g__tag_role/RoleMapNS_#2_dict}{#1} |
| 1616 |
{ |
| 1617 |
[ |
| 1618 |
\pdf_name_from_unicode_e:n{#3} |
| 1619 |
\c_space_tl |
| 1620 |
\pdf_object_ref:n {tag/NS/#4} |
| 1621 |
] |
| 1622 |
} |
| 1623 |
} |
| 1624 |
\tl_if_empty:nF { #2 } |
| 1625 |
{ |
| 1626 |
\prop_get:cnN { g__tag_role_NS_#4_prop } {#3}\l__tag_tmpa_tl |
| 1627 |
\quark_if_no_value:NTF \l__tag_tmpa_tl |
| 1628 |
{ |
| 1629 |
\__tag_prop_gput:cne { g__tag_role_NS_#2_prop } {#1} |
| 1630 |
{{\tl_to_str:n{#3}}{\tl_to_str:n{#4}}} |
| 1631 |
} |
| 1632 |
{ |
| 1633 |
\__tag_prop_gput:cno { g__tag_role_NS_#2_prop } {#1}{\l__tag_tmpa_tl} |
| 1634 |
} |
| 1635 |
} |
| 1636 |
\bool_if:NT \l__tag_role_update_bool |
| 1637 |
{ |
| 1638 |
\tl_if_empty:nF { #3 } |
| 1639 |
{ |
| 1640 |
\tl_if_eq:nnF{#1}{#3} |
| 1641 |
{ |
| 1642 |
\prop_get:NnN \g__tag_role_rolemap_prop {#3}\l__tag_tmpa_tl |
| 1643 |
\quark_if_no_value:NTF \l__tag_tmpa_tl |
| 1644 |
{ |
| 1645 |
\__tag_prop_gput:Nne \g__tag_role_rolemap_prop {#1}{\tl_to_str:n{#3}} |
| 1646 |
} |
| 1647 |
{ |
| 1648 |
\__tag_prop_gput:Nno \g__tag_role_rolemap_prop {#1}{\l__tag_tmpa_tl} |
| 1649 |
} |
| 1650 |
} |
| 1651 |
} |
| 1652 |
} |
| 1653 |
} |
| 1654 |
\cs_generate_variant:Nn \__tag_role_add_tag:nnnn {oooo} |
| 1655 |
\pdf_version_compare:NnF < {2.0} |
| 1656 |
{ |
| 1657 |
\cs_new:Npn \__tag_role_get:nnNN #1#2#3#4 |
| 1658 |
%#1 tag, #2 NS, |
| 1659 |
%#3 tlvar which hold the role tag |
| 1660 |
%#4 tlvar which hold the name of the target NS |
| 1661 |
{ |
| 1662 |
\prop_if_exist:cTF {g__tag_role_NS_#2_prop} |
| 1663 |
{ |
| 1664 |
\prop_get:cnNTF {g__tag_role_NS_#2_prop} {#1}\l__tag_get_tmpc_tl |
| 1665 |
{ |
| 1666 |
\tl_set:Ne #3 {\exp_last_unbraced:No\use_i:nn {\l__tag_get_tmpc_tl}} |
| 1667 |
\tl_set:Ne #4 {\exp_last_unbraced:No\use_ii:nn {\l__tag_get_tmpc_tl}} |
| 1668 |
} |
| 1669 |
{ |
| 1670 |
\msg_warning:nnn { tag } {role-unknown-tag} { #1 } |
| 1671 |
\tl_set:Nn #3 {#1} |
| 1672 |
\tl_set:Nn #4 {#2} |
| 1673 |
} |
| 1674 |
} |
| 1675 |
{ |
| 1676 |
\msg_warning:nnn { tag } {role-unknown-NS} { #2 } |
| 1677 |
\tl_set:Nn #3 {#1} |
| 1678 |
\tl_set:Nn #4 {#2} |
| 1679 |
} |
| 1680 |
} |
| 1681 |
\cs_generate_variant:Nn \__tag_role_get:nnNN {ooNN} |
| 1682 |
} |
| 1683 |
|
| 1684 |
\bool_new:N\l__tag_role_update_bool |
| 1685 |
\bool_set_true:N \l__tag_role_update_bool |
| 1686 |
\pdf_version_compare:NnTF < {2.0} |
| 1687 |
{ |
| 1688 |
\cs_new_protected:Npn \__tag_role_read_namespace_line:nw #1#2,#3,#4,#5,#6\q_stop % |
| 1689 |
% #1 NS, #2 tag, #3 rolemap, #4 NS rolemap #5 type |
| 1690 |
{ |
| 1691 |
\tl_if_empty:nF { #2 } |
| 1692 |
{ |
| 1693 |
\bool_if:NTF \l__tag_role_update_bool |
| 1694 |
{ |
| 1695 |
\tl_if_empty:nTF {#5} |
| 1696 |
{ |
| 1697 |
\prop_get:NnN \g__tag_role_tags_class_prop {#3}\l__tag_tmpa_tl |
| 1698 |
\quark_if_no_value:NT \l__tag_tmpa_tl |
| 1699 |
{ |
| 1700 |
\tl_set:Nn\l__tag_tmpa_tl{--UNKNOWN--} |
| 1701 |
} |
| 1702 |
} |
| 1703 |
{ |
| 1704 |
\tl_set:Nn \l__tag_tmpa_tl {#5} |
| 1705 |
} |
| 1706 |
\__tag_role_alloctag:nno {#2} {#1} { \l__tag_tmpa_tl } |
| 1707 |
\tl_if_eq:nnF {#2}{#3} |
| 1708 |
{ |
| 1709 |
\__tag_role_add_tag:nn {#2}{#3} |
| 1710 |
} |
| 1711 |
\__tag_prop_gput:cnn {g__tag_role_NS_#1_prop} {#2}{{#3}{}} |
| 1712 |
} |
| 1713 |
{ |
| 1714 |
\__tag_prop_gput:cnn {g__tag_role_NS_#1_prop} {#2}{{#3}{}} |
| 1715 |
\prop_gput:cnn {g__tag_role_NS_#1_class_prop} {#2}{--UNUSED--} |
| 1716 |
} |
| 1717 |
} |
| 1718 |
} |
| 1719 |
} |
| 1720 |
{ |
| 1721 |
\cs_new_protected:Npn \__tag_role_read_namespace_line:nw #1#2,#3,#4,#5,#6\q_stop % |
| 1722 |
% #1 NS, #2 tag, #3 rolemap, #4 NS rolemap #5 type |
| 1723 |
{ |
| 1724 |
\tl_if_empty:nF {#2} |
| 1725 |
{ |
| 1726 |
\tl_if_empty:nTF {#5} |
| 1727 |
{ |
| 1728 |
\prop_get:cnN { g__tag_role_NS_#4_class_prop } {#3}\l__tag_tmpa_tl |
| 1729 |
\quark_if_no_value:NT \l__tag_tmpa_tl |
| 1730 |
{ |
| 1731 |
\tl_set:Nn\l__tag_tmpa_tl{--UNKNOWN--} |
| 1732 |
} |
| 1733 |
} |
| 1734 |
{ |
| 1735 |
\tl_set:Nn \l__tag_tmpa_tl {#5} |
| 1736 |
} |
| 1737 |
\__tag_role_alloctag:nno {#2} {#1} { \l__tag_tmpa_tl } |
| 1738 |
\bool_lazy_and:nnT |
| 1739 |
{ ! \tl_if_empty_p:n {#3} }{! \str_if_eq_p:nn {#1}{pdf2}} |
| 1740 |
{ |
| 1741 |
\__tag_role_add_tag:nnnn {#2}{#1}{#3}{#4} |
| 1742 |
} |
| 1743 |
\__tag_prop_gput:cnn {g__tag_role_NS_#1_prop} {#2}{{#3}{#4}} |
| 1744 |
} |
| 1745 |
} |
| 1746 |
} |
| 1747 |
\cs_new_protected:Npn \__tag_role_read_namespace:nn #1 #2 %name of namespace #2 name of file |
| 1748 |
{ |
| 1749 |
\prop_if_exist:cF {g__tag_role_NS_#1_prop} |
| 1750 |
{ \msg_warning:nnn {tag}{namespace-unknown}{#1} } |
| 1751 |
\file_if_exist:nTF { tagpdf-ns-#2.def } |
| 1752 |
{ |
| 1753 |
\ior_open:Nn \g_tmpa_ior {tagpdf-ns-#2.def} |
| 1754 |
\msg_info:nnn {tag}{read-namespace}{#2} |
| 1755 |
\ior_map_inline:Nn \g_tmpa_ior |
| 1756 |
{ |
| 1757 |
\__tag_role_read_namespace_line:nw {#1} ##1,,,,\q_stop |
| 1758 |
} |
| 1759 |
\ior_close:N\g_tmpa_ior |
| 1760 |
} |
| 1761 |
{ |
| 1762 |
\msg_info:nnn{tag}{namespace-missing}{#2} |
| 1763 |
} |
| 1764 |
} |
| 1765 |
|
| 1766 |
\cs_new_protected:Npn \__tag_role_read_namespace:n #1 %name of namespace |
| 1767 |
{ |
| 1768 |
\__tag_role_read_namespace:nn {#1}{#1} |
| 1769 |
} |
| 1770 |
\__tag_role_read_namespace:n {pdf} |
| 1771 |
\__tag_role_read_namespace:n {pdf2} |
| 1772 |
\__tag_role_read_namespace:n {mathml} |
| 1773 |
\bool_set_false:N\l__tag_role_update_bool |
| 1774 |
\__tag_role_read_namespace:n {latex-book} |
| 1775 |
\bool_set_true:N\l__tag_role_update_bool |
| 1776 |
\__tag_role_read_namespace:n {latex} |
| 1777 |
\__tag_role_read_namespace:nn {latex} {latex-lab} |
| 1778 |
\__tag_role_read_namespace:n {pdf} |
| 1779 |
\__tag_role_read_namespace:n {pdf2} |
| 1780 |
\pdf_version_compare:NnTF < {2.0} |
| 1781 |
{ |
| 1782 |
\hook_gput_code:nnn {begindocument}{tagpdf} |
| 1783 |
{ |
| 1784 |
\bool_lazy_and:nnT |
| 1785 |
{ |
| 1786 |
\cs_if_exist_p:N \chapter |
| 1787 |
} |
| 1788 |
{ |
| 1789 |
\cs_if_exist_p:N \c@chapter |
| 1790 |
} |
| 1791 |
{ |
| 1792 |
\prop_map_inline:cn{g__tag_role_NS_latex-book_prop} |
| 1793 |
{ |
| 1794 |
\__tag_role_add_tag:ne {#1}{\use_i:nn #2\c_empty_tl\c_empty_tl} |
| 1795 |
} |
| 1796 |
} |
| 1797 |
} |
| 1798 |
} |
| 1799 |
{ |
| 1800 |
\hook_gput_code:nnn {begindocument}{tagpdf} |
| 1801 |
{ |
| 1802 |
\bool_lazy_and:nnT |
| 1803 |
{ |
| 1804 |
\cs_if_exist_p:N \chapter |
| 1805 |
} |
| 1806 |
{ |
| 1807 |
\cs_if_exist_p:N \c@chapter |
| 1808 |
} |
| 1809 |
{ |
| 1810 |
\prop_map_inline:cn{g__tag_role_NS_latex-book_prop} |
| 1811 |
{ |
| 1812 |
\prop_gput:Nnn \g__tag_role_tags_NS_prop { #1 }{ latex-book } |
| 1813 |
\__tag_prop_gput:Nne |
| 1814 |
\g__tag_role_rolemap_prop {#1}{\use_i:nn #2\c_empty_tl\c_empty_tl} |
| 1815 |
} |
| 1816 |
} |
| 1817 |
} |
| 1818 |
} |
| 1819 |
\intarray_new:Nn \g__tag_role_parent_child_intarray {6000} |
| 1820 |
\sys_if_engine_luatex:TF |
| 1821 |
{ |
| 1822 |
\cs_new_protected:Npn \__tag_store_parent_child_rule:nnn #1 #2 #3 % num parent, num child, #3 string |
| 1823 |
{ |
| 1824 |
\prop_get:NeNTF \c__tag_role_rules_prop{#3} \l__tag_tmp_unused_tl |
| 1825 |
{ |
| 1826 |
\intarray_gset:Nnn \g__tag_role_parent_child_intarray |
| 1827 |
{ #1#2 }{0\l__tag_tmp_unused_tl} |
| 1828 |
\lua_now:e |
| 1829 |
{ |
| 1830 |
ltx.__tag.role.matrix[#1] = ltx.__tag.role.matrix[#1] or {} |
| 1831 |
ltx.__tag.role.matrix[#1][#2] = 0\l__tag_tmp_unused_tl |
| 1832 |
} |
| 1833 |
} |
| 1834 |
{ |
| 1835 |
\intarray_gset:Nnn \g__tag_role_parent_child_intarray |
| 1836 |
{ #1#2 }{0} |
| 1837 |
\lua_now:e |
| 1838 |
{ |
| 1839 |
ltx.__tag.role.matrix[#1] = ltx.__tag.role.matrix[#1] or {} |
| 1840 |
ltx.__tag.role.matrix[#1][#2] = 0 |
| 1841 |
} |
| 1842 |
} |
| 1843 |
} |
| 1844 |
} |
| 1845 |
{ |
| 1846 |
\cs_new_protected:Npn \__tag_store_parent_child_rule:nnn #1 #2 #3 % num parent, num child, #3 string |
| 1847 |
{ |
| 1848 |
\prop_get:NeNTF \c__tag_role_rules_prop{#3} \l__tag_tmp_unused_tl |
| 1849 |
{ |
| 1850 |
\intarray_gset:Nnn \g__tag_role_parent_child_intarray |
| 1851 |
{ #1#2 }{0\l__tag_tmp_unused_tl} |
| 1852 |
} |
| 1853 |
{ |
| 1854 |
\intarray_gset:Nnn \g__tag_role_parent_child_intarray |
| 1855 |
{ #1#2 }{0} |
| 1856 |
} |
| 1857 |
} |
| 1858 |
} |
| 1859 |
\int_zero:N \l__tag_tmpa_int |
| 1860 |
\pdf_version_compare:NnTF < {2.0} |
| 1861 |
{ |
| 1862 |
\ior_open:Nn \g_tmpa_ior {tagpdf-parent-child.csv} |
| 1863 |
} |
| 1864 |
{ |
| 1865 |
\ior_open:Nn \g_tmpa_ior {tagpdf-parent-child-2.csv} |
| 1866 |
} |
| 1867 |
|
| 1868 |
\ior_map_inline:Nn \g_tmpa_ior |
| 1869 |
{ |
| 1870 |
\tl_if_empty:nF{#1} |
| 1871 |
{ |
| 1872 |
\int_incr:N\l__tag_tmpa_int |
| 1873 |
\seq_set_from_clist:Nn\l__tag_tmpa_seq { #1 } |
| 1874 |
\int_compare:nNnTF {\l__tag_tmpa_int}=1 |
| 1875 |
{ |
| 1876 |
\seq_map_indexed_inline:Nn \l__tag_tmpa_seq |
| 1877 |
{ |
| 1878 |
\prop_gput:Nne\g__tag_role_index_prop |
| 1879 |
{##2} |
| 1880 |
{\int_compare:nNnT{##1}<{10}{0}##1} |
| 1881 |
} |
| 1882 |
} |
| 1883 |
{ |
| 1884 |
\seq_set_from_clist:Nn\l__tag_tmpa_seq { #1 } |
| 1885 |
\seq_pop_left:NN\l__tag_tmpa_seq\l__tag_tmpa_tl |
| 1886 |
\prop_get:NoN \g__tag_role_index_prop { \l__tag_tmpa_tl } \l__tag_tmpb_tl |
| 1887 |
\seq_pop_left:NN\l__tag_tmpa_seq\l__tag_tmpa_tl |
| 1888 |
\seq_pop_left:NN\l__tag_tmpa_seq\l__tag_tmpa_tl |
| 1889 |
\seq_map_indexed_inline:Nn \l__tag_tmpa_seq |
| 1890 |
{ |
| 1891 |
\exp_args:Nne |
| 1892 |
\__tag_store_parent_child_rule:nnn {##1}{\l__tag_tmpb_tl}{ ##2 } |
| 1893 |
} |
| 1894 |
} |
| 1895 |
} |
| 1896 |
} |
| 1897 |
\ior_close:N\g_tmpa_ior |
| 1898 |
\prop_get:NnN\g__tag_role_index_prop{StructTreeRoot}\l__tag_tmpa_tl |
| 1899 |
\prop_gput:Nne\g__tag_role_index_prop{Root}{\l__tag_tmpa_tl} |
| 1900 |
\prop_get:NnN\g__tag_role_index_prop{Hn}\l__tag_tmpa_tl |
| 1901 |
\pdf_version_compare:NnTF < {2.0} |
| 1902 |
{ |
| 1903 |
\int_step_inline:nn{6} |
| 1904 |
{ |
| 1905 |
\prop_gput:Nne\g__tag_role_index_prop{H#1}{\l__tag_tmpa_tl} |
| 1906 |
} |
| 1907 |
} |
| 1908 |
{ |
| 1909 |
\int_step_inline:nn{10} |
| 1910 |
{ |
| 1911 |
\prop_gput:Nne\g__tag_role_index_prop{H#1}{\l__tag_tmpa_tl} |
| 1912 |
} |
| 1913 |
\prop_get:NnN\g__tag_role_index_prop {mathml}\l__tag_tmpa_tl |
| 1914 |
\prop_get:NnN\g__tag_role_index_prop {math}\l__tag_tmpb_tl |
| 1915 |
\prop_get:NnN\g__tag_role_index_prop {mtext}\l__tag_tmpc_tl |
| 1916 |
\prop_map_inline:Nn \g__tag_role_NS_mathml_prop |
| 1917 |
{ |
| 1918 |
\prop_gput:Nno\g__tag_role_index_prop {#1} {\l__tag_tmpa_tl} |
| 1919 |
} |
| 1920 |
\prop_gput:Nno\g__tag_role_index_prop{math}{\l__tag_tmpb_tl} |
| 1921 |
\prop_gput:Nno\g__tag_role_index_prop{mtext}{\l__tag_tmpc_tl} |
| 1922 |
} |
| 1923 |
\sys_if_engine_luatex:T |
| 1924 |
{ |
| 1925 |
\prop_map_inline:Nn\g__tag_role_index_prop |
| 1926 |
{ |
| 1927 |
\lua_now:e { ltx.__tag.role.index['#1']=#2 } |
| 1928 |
} |
| 1929 |
} |
| 1930 |
\tl_new:N \l__tag_parent_child_check_tl |
| 1931 |
\sys_if_engine_luatex:TF |
| 1932 |
{ |
| 1933 |
\cs_new_protected:Npn \__tag_role_get_parent_child_rule:nnN #1 #2 #3 |
| 1934 |
% #1 parent (string, standard tag after rolemapping!) |
| 1935 |
% #2 child (string, standard tag after rolemapping!) |
| 1936 |
% #3 tl for state |
| 1937 |
{ |
| 1938 |
\tl_set:Ne#3 |
| 1939 |
{ |
| 1940 |
\lua_now:e{tex.print(\int_use:N\c_document_cctab,ltx.__tag.func.role_get_parent_child_rule('#1','#2'))} |
| 1941 |
} |
| 1942 |
\int_compare:nNnT {\l__tag_loglevel_int} > { 0 } |
| 1943 |
{ |
| 1944 |
\prop_get:NoNF\c__tag_role_rules_num_prop {#3} \l__tag_tmpa_tl |
| 1945 |
{ |
| 1946 |
\tl_set:Nn \l__tag_tmpa_tl {unknown} |
| 1947 |
} |
| 1948 |
\tl_set:Nn \l__tag_tmpb_tl {#1} |
| 1949 |
\msg_note:nneee |
| 1950 |
{ tag } |
| 1951 |
{ role-parent-child-result } |
| 1952 |
{ #1 } |
| 1953 |
{ #2 } |
| 1954 |
{ |
| 1955 |
#3~(='\l__tag_tmpa_tl') |
| 1956 |
} |
| 1957 |
} |
| 1958 |
\int_compare:nNnT {#3} = { 0 } |
| 1959 |
{ |
| 1960 |
\msg_warning:nneee |
| 1961 |
{ tag } |
| 1962 |
{role-parent-child-result} |
| 1963 |
{ #1 } |
| 1964 |
{ #2 } |
| 1965 |
{ unknown! } |
| 1966 |
} |
| 1967 |
|
| 1968 |
} |
| 1969 |
} |
| 1970 |
{ |
| 1971 |
\cs_new_protected:Npn \__tag_role_get_parent_child_rule:nnN #1 #2 #3 |
| 1972 |
% #1 parent (string, standard tag after rolemapping) |
| 1973 |
% #2 child (string, standard tag after rolemapping) |
| 1974 |
% #3 tl for state |
| 1975 |
{ |
| 1976 |
\prop_get:NnN \g__tag_role_index_prop{#1}\l__tag_tmpa_tl |
| 1977 |
\prop_get:NnN \g__tag_role_index_prop{#2}\l__tag_tmpb_tl |
| 1978 |
\bool_lazy_and:nnTF |
| 1979 |
{ ! \quark_if_no_value_p:N \l__tag_tmpa_tl } |
| 1980 |
{ ! \quark_if_no_value_p:N \l__tag_tmpb_tl } |
| 1981 |
{ |
| 1982 |
\tl_set:Ne#3 |
| 1983 |
{ |
| 1984 |
\intarray_item:Nn |
| 1985 |
\g__tag_role_parent_child_intarray |
| 1986 |
{\l__tag_tmpa_tl\l__tag_tmpb_tl} |
| 1987 |
} |
| 1988 |
} |
| 1989 |
{ |
| 1990 |
\tl_set:Nn#3 {0} |
| 1991 |
} |
| 1992 |
\int_compare:nNnT {\l__tag_loglevel_int} > { 0 } |
| 1993 |
{ |
| 1994 |
\prop_get:NoNF\c__tag_role_rules_num_prop {#3} \l__tag_tmpa_tl |
| 1995 |
{ |
| 1996 |
\tl_set:Nn \l__tag_tmpa_tl {unknown} |
| 1997 |
} |
| 1998 |
\tl_set:Nn \l__tag_tmpb_tl {#1} |
| 1999 |
\msg_note:nneee |
| 2000 |
{ tag } |
| 2001 |
{ role-parent-child-result } |
| 2002 |
{ #1 } |
| 2003 |
{ #2 } |
| 2004 |
{ |
| 2005 |
#3~(='\l__tag_tmpa_tl') |
| 2006 |
} |
| 2007 |
} |
| 2008 |
\int_compare:nNnT {#3} = { 0 } |
| 2009 |
{ |
| 2010 |
\msg_warning:nneee |
| 2011 |
{ tag } |
| 2012 |
{role-parent-child-result} |
| 2013 |
{ #1 } |
| 2014 |
{ #2 } |
| 2015 |
{ unknown! } |
| 2016 |
} |
| 2017 |
} |
| 2018 |
} |
| 2019 |
\cs_generate_variant:Nn\__tag_role_get_parent_child_rule:nnN {ooN} |
| 2020 |
\pdf_version_compare:NnTF < {2.0} |
| 2021 |
{ |
| 2022 |
\cs_new_protected:Npn \__tag_role_check_parent_child:nnnnN #1 #2 #3 #4 #5 |
| 2023 |
% #1 parent tag,% not necessarly rolemapped, but often the case |
| 2024 |
% #2 NS (empty in pdf 1.x) |
| 2025 |
% #3 child tag, % not necessarly rolemapped, but often the case |
| 2026 |
% #4 NS (empty in pdf 1.x) |
| 2027 |
% #5 tl var: to give the result back. |
| 2028 |
{ |
| 2029 |
\prop_get:NnNTF \g__tag_role_index_prop {#1}\l__tag_tmpa_tl |
| 2030 |
{ |
| 2031 |
\tl_set:Nn \l__tag_tmpa_tl {#1} |
| 2032 |
} |
| 2033 |
{ |
| 2034 |
\prop_get:NnNF \g__tag_role_rolemap_prop {#1}\l__tag_tmpa_tl |
| 2035 |
{ |
| 2036 |
\tl_set:Nn \l__tag_tmpa_tl {\q_no_value} |
| 2037 |
} |
| 2038 |
} |
| 2039 |
\prop_get:NnNTF \g__tag_role_index_prop {#3}\l__tag_tmpb_tl |
| 2040 |
{ |
| 2041 |
\tl_set:Nn \l__tag_tmpb_tl {#3} |
| 2042 |
} |
| 2043 |
{ |
| 2044 |
\prop_get:NnNF \g__tag_role_rolemap_prop {#3}\l__tag_tmpb_tl |
| 2045 |
{ |
| 2046 |
\tl_set:Nn \l__tag_tmpb_tl {\q_no_value} |
| 2047 |
} |
| 2048 |
} |
| 2049 |
\bool_lazy_and:nnTF |
| 2050 |
{ ! \quark_if_no_value_p:N \l__tag_tmpa_tl } |
| 2051 |
{ ! \quark_if_no_value_p:N \l__tag_tmpb_tl } |
| 2052 |
{ |
| 2053 |
\__tag_role_get_parent_child_rule:ooN |
| 2054 |
{ \l__tag_tmpa_tl} |
| 2055 |
{ \l__tag_tmpb_tl} |
| 2056 |
#5 |
| 2057 |
} |
| 2058 |
{ |
| 2059 |
\tl_set:Nn #5 {0} |
| 2060 |
\msg_warning:nneee |
| 2061 |
{ tag } |
| 2062 |
{role-parent-child-result} |
| 2063 |
{ #1 } |
| 2064 |
{ #3 } |
| 2065 |
{ unknown! } |
| 2066 |
} |
| 2067 |
} |
| 2068 |
} |
| 2069 |
{ |
| 2070 |
\cs_new_protected:Npn \__tag_role_check_parent_child:nnnnN #1 #2 #3 #4 #5 %tag,NS,tag,NS, tl var |
| 2071 |
{ |
| 2072 |
% \end{macrocode} |
| 2073 |
\tl_if_empty:nTF {#2} |
| 2074 |
{ |
| 2075 |
\tl_set:Nn \l__tag_tmpa_tl {#1} |
| 2076 |
} |
| 2077 |
{ |
| 2078 |
\prop_if_exist:cTF { g__tag_role_NS_#2_prop } |
| 2079 |
{ |
| 2080 |
\prop_get:cnNTF |
| 2081 |
{ g__tag_role_NS_#2_prop } |
| 2082 |
{#1} |
| 2083 |
\l__tag_tmpa_tl |
| 2084 |
{ |
| 2085 |
\tl_set:Ne \l__tag_tmpa_tl {\tl_head:N\l__tag_tmpa_tl} |
| 2086 |
\tl_if_empty:NT\l__tag_tmpa_tl |
| 2087 |
{ |
| 2088 |
\tl_set:Nn \l__tag_tmpa_tl {#1} |
| 2089 |
} |
| 2090 |
} |
| 2091 |
{ |
| 2092 |
\tl_set:Nn \l__tag_tmpa_tl {\q_no_value} |
| 2093 |
} |
| 2094 |
} |
| 2095 |
{ |
| 2096 |
\msg_warning:nnn { tag } {role-unknown-NS} { #2} |
| 2097 |
\tl_set:Nn \l__tag_tmpa_tl {\q_no_value} |
| 2098 |
} |
| 2099 |
} |
| 2100 |
\tl_if_empty:nTF {#4} |
| 2101 |
{ |
| 2102 |
\tl_set:Nn \l__tag_tmpb_tl {#3} |
| 2103 |
} |
| 2104 |
{ |
| 2105 |
\prop_if_exist:cTF { g__tag_role_NS_#4_prop } |
| 2106 |
{ |
| 2107 |
\prop_get:cnNTF |
| 2108 |
{ g__tag_role_NS_#4_prop } |
| 2109 |
{#3} |
| 2110 |
\l__tag_tmpb_tl |
| 2111 |
{ |
| 2112 |
\tl_set:Ne \l__tag_tmpb_tl { \tl_head:N\l__tag_tmpb_tl } |
| 2113 |
\tl_if_empty:NT\l__tag_tmpb_tl |
| 2114 |
{ |
| 2115 |
\tl_set:Nn \l__tag_tmpb_tl {#3} |
| 2116 |
} |
| 2117 |
} |
| 2118 |
{ |
| 2119 |
\tl_set:Nn \l__tag_tmpb_tl {\q_no_value} |
| 2120 |
} |
| 2121 |
} |
| 2122 |
{ |
| 2123 |
\msg_warning:nnn { tag } {role-unknown-NS} { #4} |
| 2124 |
\tl_set:Nn \l__tag_tmpb_tl {\q_no_value} |
| 2125 |
} |
| 2126 |
} |
| 2127 |
\bool_lazy_and:nnTF |
| 2128 |
{ ! \quark_if_no_value_p:N \l__tag_tmpa_tl } |
| 2129 |
{ ! \quark_if_no_value_p:N \l__tag_tmpb_tl } |
| 2130 |
{ |
| 2131 |
\__tag_role_get_parent_child_rule:ooN |
| 2132 |
{ \l__tag_tmpa_tl } |
| 2133 |
{ \l__tag_tmpb_tl } |
| 2134 |
#5 |
| 2135 |
} |
| 2136 |
{ |
| 2137 |
\tl_set:Nn #5 {0} |
| 2138 |
\msg_warning:nneee |
| 2139 |
{ tag } |
| 2140 |
{role-parent-child-result} |
| 2141 |
{ #2 : #1 } |
| 2142 |
{ #4 : #3 } |
| 2143 |
{ unknown! } |
| 2144 |
} |
| 2145 |
} |
| 2146 |
} |
| 2147 |
\cs_generate_variant:Nn\__tag_role_check_parent_child:nnnnN {oonnN,ooooN} |
| 2148 |
\prg_set_protected_conditional:Npnn \tag_check_child:nn #1 #2 {T,F,TF} %#1 tag, #2 NS |
| 2149 |
{ |
| 2150 |
\seq_get:NN\g__tag_struct_stack_seq\l__tag_tmpa_tl |
| 2151 |
\__tag_struct_get_role:enNN |
| 2152 |
{\l__tag_tmpa_tl} |
| 2153 |
{rolemap} |
| 2154 |
\l__tag_get_parent_tmpa_tl |
| 2155 |
\l__tag_get_parent_tmpb_tl |
| 2156 |
\__tag_role_check_parent_child:oonnN |
| 2157 |
{ \l__tag_get_parent_tmpa_tl } |
| 2158 |
{ \l__tag_get_parent_tmpb_tl } |
| 2159 |
{#1}{#2} |
| 2160 |
\l__tag_parent_child_check_tl |
| 2161 |
\int_compare:nNnT {\l__tag_parent_child_check_tl} = { \c__tag_role_rule_checkparent_tl } |
| 2162 |
{ |
| 2163 |
\seq_get:NN\g__tag_struct_stack_seq\l__tag_tmpa_tl |
| 2164 |
\__tag_struct_get_role:enNN |
| 2165 |
{\l__tag_tmpa_tl} |
| 2166 |
{parentrole} |
| 2167 |
\l__tag_get_parent_tmpa_tl |
| 2168 |
\l__tag_get_parent_tmpb_tl |
| 2169 |
\__tag_role_check_parent_child:oonnN |
| 2170 |
{ \l__tag_get_parent_tmpa_tl } |
| 2171 |
{ \l__tag_get_parent_tmpb_tl } |
| 2172 |
{#1}{#2} |
| 2173 |
\l__tag_parent_child_check_tl |
| 2174 |
} |
| 2175 |
\int_compare:nNnTF { \l__tag_parent_child_check_tl } < {0} |
| 2176 |
{\prg_return_false:} |
| 2177 |
{\prg_return_true:} |
| 2178 |
} |
| 2179 |
\keys_define:nn { __tag / tag-role } |
| 2180 |
{ |
| 2181 |
,tag .tl_set:N = \l__tag_role_tag_tmpa_tl |
| 2182 |
,tag-namespace .tl_set:N = \l__tag_role_tag_namespace_tmpa_tl |
| 2183 |
,role .tl_set:N = \l__tag_role_role_tmpa_tl |
| 2184 |
,role-namespace .tl_set:N = \l__tag_role_role_namespace_tmpa_tl |
| 2185 |
} |
| 2186 |
|
| 2187 |
\keys_define:nn { __tag / setup } |
| 2188 |
{ |
| 2189 |
role/mathml-tags .bool_gset:N = \g__tag_role_add_mathml_bool |
| 2190 |
,role/new-tag .code:n = |
| 2191 |
{ |
| 2192 |
\keys_set_known:nnnN |
| 2193 |
{__tag/tag-role} |
| 2194 |
{ |
| 2195 |
tag-namespace=user, |
| 2196 |
role-namespace=, %so that we can test for it. |
| 2197 |
#1 |
| 2198 |
}{__tag/tag-role}\l__tag_tmpa_tl |
| 2199 |
\tl_if_empty:NF \l__tag_tmpa_tl |
| 2200 |
{ |
| 2201 |
\exp_args:NNno \seq_set_split:Nnn \l__tag_tmpa_seq { / } {\l__tag_tmpa_tl/} |
| 2202 |
\tl_set:Ne \l__tag_role_tag_tmpa_tl { \seq_item:Nn \l__tag_tmpa_seq {1} } |
| 2203 |
\tl_set:Ne \l__tag_role_role_tmpa_tl { \seq_item:Nn \l__tag_tmpa_seq {2} } |
| 2204 |
} |
| 2205 |
\tl_if_empty:NT \l__tag_role_role_namespace_tmpa_tl |
| 2206 |
{ |
| 2207 |
\prop_get:NoNTF |
| 2208 |
\g__tag_role_tags_NS_prop |
| 2209 |
{ \l__tag_role_role_tmpa_tl } |
| 2210 |
\l__tag_role_role_namespace_tmpa_tl |
| 2211 |
{ |
| 2212 |
\prop_get:NoNF |
| 2213 |
\g__tag_role_NS_prop |
| 2214 |
{ \l__tag_role_role_namespace_tmpa_tl } |
| 2215 |
\l__tag_tmp_unused_tl |
| 2216 |
{ |
| 2217 |
\tl_set:Nn \l__tag_role_role_namespace_tmpa_tl {user} |
| 2218 |
} |
| 2219 |
} |
| 2220 |
{ |
| 2221 |
\tl_set:Nn \l__tag_role_role_namespace_tmpa_tl {user} |
| 2222 |
} |
| 2223 |
} |
| 2224 |
\pdf_version_compare:NnTF < {2.0} |
| 2225 |
{ |
| 2226 |
%TODO add check for emptyness? |
| 2227 |
\__tag_role_add_tag:oo |
| 2228 |
{ \l__tag_role_tag_tmpa_tl } |
| 2229 |
{ \l__tag_role_role_tmpa_tl } |
| 2230 |
} |
| 2231 |
{ |
| 2232 |
\__tag_role_add_tag:oooo |
| 2233 |
{ \l__tag_role_tag_tmpa_tl } |
| 2234 |
{ \l__tag_role_tag_namespace_tmpa_tl } |
| 2235 |
{ \l__tag_role_role_tmpa_tl } |
| 2236 |
{ \l__tag_role_role_namespace_tmpa_tl } |
| 2237 |
} |
| 2238 |
} |
| 2239 |
,role/map-tags .choice: |
| 2240 |
,role/map-tags/false .code:n = { \socket_assign_plug:nn { tag/struct/tag } {latex-tags} } |
| 2241 |
,role/map-tags/pdf .code:n = { \socket_assign_plug:nn { tag/struct/tag } {pdf-tags} } |
| 2242 |
,role/user-NS .code:n = |
| 2243 |
{ |
| 2244 |
\pdf_version_compare:NnF < {2.0} |
| 2245 |
{ |
| 2246 |
\pdf_string_from_unicode:nnN{utf8/string}{https://www.latex-project.org/ns/local/#1}\l__tag_tmpa_str |
| 2247 |
\tl_if_empty:NF \l__tag_tmpa_str |
| 2248 |
{ |
| 2249 |
\pdfdict_gput:nne |
| 2250 |
{g__tag_role/Namespace_user_dict} |
| 2251 |
{NS} |
| 2252 |
{\l__tag_tmpa_str} |
| 2253 |
} |
| 2254 |
} |
| 2255 |
} |
| 2256 |
, mathml-tags .bool_gset:N = \g__tag_role_add_mathml_bool |
| 2257 |
, add-new-tag .meta:n = {role/new-tag={#1}} |
| 2258 |
} |
| 2259 |
%% File: tagpdf-struct.dtx |
| 2260 |
\__tag_seq_new:N \g__tag_struct_objR_seq |
| 2261 |
\tl_const:Nn\c__tag_struct_null_tl {null} |
| 2262 |
|
| 2263 |
\__tag_prop_new:N \g__tag_struct_cont_mc_prop |
| 2264 |
\seq_new:N \g__tag_struct_stack_seq |
| 2265 |
\seq_gpush:Nn \g__tag_struct_stack_seq {1} |
| 2266 |
\seq_new:N \g__tag_struct_tag_stack_seq |
| 2267 |
\seq_new:N \g__tag_struct_roletag_stack_seq |
| 2268 |
\seq_gpush:Nn \g__tag_struct_tag_stack_seq {{Root}{StructTreeRoot}} |
| 2269 |
\seq_gpush:Nn \g__tag_struct_roletag_stack_seq {StructTreeRoot} |
| 2270 |
\tl_new:N \l__tag_struct_stack_parent_tmpa_tl |
| 2271 |
\sys_if_engine_luatex:TF |
| 2272 |
{ |
| 2273 |
\cs_new:Npn \__tag_struct_set_attribute: |
| 2274 |
{ |
| 2275 |
\lua_now:e |
| 2276 |
{ |
| 2277 |
tex.setattribute |
| 2278 |
( |
| 2279 |
"global", |
| 2280 |
luatexbase.attributes.g__tag_structnum_attr, |
| 2281 |
\g__tag_struct_stack_current_tl |
| 2282 |
) |
| 2283 |
} |
| 2284 |
} |
| 2285 |
} |
| 2286 |
{ |
| 2287 |
\cs_new_eq:NN \__tag_struct_set_attribute: \prg_do_nothing: |
| 2288 |
} |
| 2289 |
|
| 2290 |
\seq_const_from_clist:Nn \c__tag_struct_StructTreeRoot_entries_seq |
| 2291 |
{%p. 857/858 |
| 2292 |
Type, % always /StructTreeRoot |
| 2293 |
K, % kid, dictionary or array of dictionaries |
| 2294 |
IDTree, % currently unused |
| 2295 |
ParentTree, % required,obj ref to the parent tree |
| 2296 |
ParentTreeNextKey, % optional |
| 2297 |
RoleMap, |
| 2298 |
ClassMap, |
| 2299 |
Namespaces, |
| 2300 |
AF %pdf 2.0 |
| 2301 |
} |
| 2302 |
|
| 2303 |
\seq_const_from_clist:Nn \c__tag_struct_StructElem_entries_seq |
| 2304 |
{%p 858 f |
| 2305 |
Type, %always /StructElem |
| 2306 |
S, %tag/type |
| 2307 |
P, %parent |
| 2308 |
ID, %optional |
| 2309 |
Ref, %optional, pdf 2.0 Use? |
| 2310 |
Pg, %obj num of starting page, optional |
| 2311 |
K, %kids |
| 2312 |
A, %attributes, probably unused |
| 2313 |
C, %class "" |
| 2314 |
%R, %attribute revision number, irrelevant for us as we |
| 2315 |
% don't update/change existing PDF and (probably) |
| 2316 |
% deprecated in PDF 2.0 |
| 2317 |
T, %title, value in () or <> |
| 2318 |
Lang, %language |
| 2319 |
Alt, % value in () or <> |
| 2320 |
E, % abbreviation |
| 2321 |
ActualText, |
| 2322 |
AF, %pdf 2.0, array of dict, associated files |
| 2323 |
NS, %pdf 2.0, dict, namespace |
| 2324 |
PhoneticAlphabet, %pdf 2.0 |
| 2325 |
Phoneme %pdf 2.0 |
| 2326 |
} |
| 2327 |
\tl_new:N \g__tag_struct_tag_tl |
| 2328 |
\tl_new:N \g__tag_struct_tag_NS_tl |
| 2329 |
\tl_new:N \l__tag_struct_roletag_tl |
| 2330 |
\tl_new:N \l__tag_struct_roletag_NS_tl |
| 2331 |
\tl_new:N \l__tag_struct_parenttag_tl |
| 2332 |
\tl_set:Nn \l__tag_struct_parenttag_tl {STASHED} |
| 2333 |
\tl_new:N \l__tag_struct_parenttag_NS_tl |
| 2334 |
\tl_set:Nn \l__tag_struct_parenttag_NS_tl {latex} |
| 2335 |
\prop_new_linked:N \g__tag_struct_label_num_prop |
| 2336 |
|
| 2337 |
\bool_new:N \l__tag_struct_elem_stash_bool |
| 2338 |
\tl_new:N \l__tag_struct_addkid_tl |
| 2339 |
\tl_set:Nn \l__tag_struct_addkid_tl {right} |
| 2340 |
|
| 2341 |
\prop_new_linked:N \g__tag_struct_ref_by_dest_prop |
| 2342 |
|
| 2343 |
\cs_new_protected:Npn \__tag_struct_prop_gput:nnn #1 #2 #3 |
| 2344 |
{ |
| 2345 |
\__tag_prop_gput:cnn |
| 2346 |
{ g__tag_struct_#1_prop }{#2}{#3} |
| 2347 |
} |
| 2348 |
\cs_generate_variant:Nn \__tag_struct_prop_gput:nnn {onn,nne,nee,nno} |
| 2349 |
|
| 2350 |
\tl_gset:Nn \g__tag_struct_stack_current_tl {1} |
| 2351 |
\cs_new:Npn \__tag_pdf_name_e:n #1{\pdf_name_from_unicode_e:n{#1}} |
| 2352 |
\__tag_prop_new:c { g__tag_struct_1_prop } |
| 2353 |
\__tag_seq_new:c { g__tag_struct_kids_1_seq } |
| 2354 |
|
| 2355 |
\__tag_struct_prop_gput:nne |
| 2356 |
{ 1 } |
| 2357 |
{ Type } |
| 2358 |
{ \pdf_name_from_unicode_e:n {StructTreeRoot} } |
| 2359 |
|
| 2360 |
\__tag_struct_prop_gput:nne |
| 2361 |
{ 1 } |
| 2362 |
{ S } |
| 2363 |
{ \pdf_name_from_unicode_e:n {StructTreeRoot} } |
| 2364 |
|
| 2365 |
\__tag_struct_prop_gput:nne |
| 2366 |
{ 1 } |
| 2367 |
{ tag } |
| 2368 |
{ {StructTreeRoot}{pdf} } |
| 2369 |
|
| 2370 |
\__tag_struct_prop_gput:nne |
| 2371 |
{ 1 } |
| 2372 |
{ rolemap } |
| 2373 |
{ {StructTreeRoot}{pdf} } |
| 2374 |
|
| 2375 |
\__tag_struct_prop_gput:nne |
| 2376 |
{ 1 } |
| 2377 |
{ parentrole } |
| 2378 |
{ {StructTreeRoot}{pdf} } |
| 2379 |
|
| 2380 |
\pdf_version_compare:NnF < {2.0} |
| 2381 |
{ |
| 2382 |
\__tag_struct_prop_gput:nne |
| 2383 |
{ 1 } |
| 2384 |
{ Namespaces } |
| 2385 |
{ \pdf_object_ref:n { __tag/tree/namespaces } } |
| 2386 |
} |
| 2387 |
\cs_new:Npn \__tag_struct_get_id:n #1 %#1=struct num |
| 2388 |
{ |
| 2389 |
( |
| 2390 |
ID. |
| 2391 |
\prg_replicate:nn |
| 2392 |
{ \int_abs:n{\g__tag_tree_id_pad_int - \tl_count:e { \int_to_arabic:n { #1 } }} } |
| 2393 |
{ 0 } |
| 2394 |
\int_to_arabic:n { #1 } |
| 2395 |
) |
| 2396 |
} |
| 2397 |
|
| 2398 |
\pdf_version_compare:NnTF < {2.0} |
| 2399 |
{ |
| 2400 |
\cs_new_protected:Npn \__tag_struct_set_tag_info:nnn #1 #2 #3 |
| 2401 |
%#1 structure number, #2 tag, #3 NS |
| 2402 |
{ |
| 2403 |
\__tag_struct_prop_gput:nne |
| 2404 |
{ #1 } |
| 2405 |
{ S } |
| 2406 |
{ \pdf_name_from_unicode_e:n {#2} } % |
| 2407 |
\__tag_struct_prop_gput:nnn |
| 2408 |
{ #1 } |
| 2409 |
{ tag } |
| 2410 |
{ {#2} {} } |
| 2411 |
} |
| 2412 |
} |
| 2413 |
{ |
| 2414 |
\cs_new_protected:Npn \__tag_struct_set_tag_info:nnn #1 #2 #3 |
| 2415 |
{ |
| 2416 |
\__tag_struct_prop_gput:nne |
| 2417 |
{ #1 } |
| 2418 |
{ S } |
| 2419 |
{ \pdf_name_from_unicode_e:n {#2} } % |
| 2420 |
\prop_get:NnNT \g__tag_role_NS_prop {#3} \l__tag_get_tmpc_tl |
| 2421 |
{ |
| 2422 |
\__tag_struct_prop_gput:nne |
| 2423 |
{ #1 } |
| 2424 |
{ NS } |
| 2425 |
{ \l__tag_get_tmpc_tl } % |
| 2426 |
} |
| 2427 |
\__tag_struct_prop_gput:nnn |
| 2428 |
{ #1 } |
| 2429 |
{ tag } |
| 2430 |
{ {#2} {#3} } |
| 2431 |
} |
| 2432 |
} |
| 2433 |
\cs_generate_variant:Nn \__tag_struct_set_tag_info:nnn {eoo} |
| 2434 |
\cs_new_protected:Npn \__tag_struct_get_role:nnNN #1 #2 #3 #4 |
| 2435 |
%#1 :struct num, |
| 2436 |
%#2 :rolemap or parentrole |
| 2437 |
%#3 :tlvar for tag (rolemapped) |
| 2438 |
%#4 :tlvar for NS (rolemapped, so standard or empty or UNKNOWN) |
| 2439 |
{ |
| 2440 |
\prop_get:cnNTF |
| 2441 |
{ g__tag_struct_#1_prop } |
| 2442 |
{ #2 } |
| 2443 |
\l__tag_get_tmpc_tl |
| 2444 |
{ |
| 2445 |
\tl_set:Ne #3{\exp_last_unbraced:No\use_i:nn { \l__tag_get_tmpc_tl }} |
| 2446 |
\tl_set:Ne #4{\exp_last_unbraced:No\use_ii:nn { \l__tag_get_tmpc_tl }} |
| 2447 |
} |
| 2448 |
{ |
| 2449 |
\tl_clear:N#3 |
| 2450 |
\tl_clear:N#4 |
| 2451 |
} |
| 2452 |
} |
| 2453 |
\cs_generate_variant:Nn\__tag_struct_get_role:nnNN {enNN} |
| 2454 |
\cs_new:Npn \__tag_struct_mcid_dict:n #1 %#1 MCID absnum |
| 2455 |
{ |
| 2456 |
<< |
| 2457 |
/Type \c_space_tl /MCR \c_space_tl |
| 2458 |
/Pg |
| 2459 |
\c_space_tl |
| 2460 |
\pdf_pageobject_ref:n { \property_ref:enn{mcid-#1}{tagabspage}{1} } |
| 2461 |
/MCID \c_space_tl \property_ref:enn{mcid-#1}{tagmcid}{1} |
| 2462 |
>> |
| 2463 |
} |
| 2464 |
\cs_new_protected:Npn \__tag_struct_kid_mc_gput_right:nn #1 #2 |
| 2465 |
{ |
| 2466 |
\__tag_seq_gput_right:ce |
| 2467 |
{ g__tag_struct_kids_#1_seq } |
| 2468 |
{ |
| 2469 |
\__tag_struct_mcid_dict:n {#2} |
| 2470 |
} |
| 2471 |
\__tag_seq_gput_right:cn |
| 2472 |
{ g__tag_struct_kids_#1_seq } |
| 2473 |
{ |
| 2474 |
\prop_item:Nn \g__tag_struct_cont_mc_prop {#2} |
| 2475 |
} |
| 2476 |
} |
| 2477 |
\cs_generate_variant:Nn \__tag_struct_kid_mc_gput_right:nn {ne} |
| 2478 |
\cs_new_protected:Npn\__tag_struct_kid_struct_gput_right:nn #1 #2 |
| 2479 |
%%#1 num of parent struct, #2 kid struct |
| 2480 |
{ |
| 2481 |
\__tag_seq_gput_right:ce |
| 2482 |
{ g__tag_struct_kids_#1_seq } |
| 2483 |
{ |
| 2484 |
\pdf_object_ref_indexed:nn { __tag/struct }{ #2 } |
| 2485 |
} |
| 2486 |
} |
| 2487 |
\cs_generate_variant:Nn \__tag_struct_kid_struct_gput_right:nn {ee} |
| 2488 |
\cs_new_protected:Npn\__tag_struct_kid_struct_gput_left:nn #1 #2 |
| 2489 |
%%#1 num of parent struct, #2 kid struct |
| 2490 |
{ |
| 2491 |
\__tag_seq_gput_left:ce |
| 2492 |
{ g__tag_struct_kids_#1_seq } |
| 2493 |
{ |
| 2494 |
\pdf_object_ref_indexed:nn { __tag/struct }{ #2 } |
| 2495 |
} |
| 2496 |
} |
| 2497 |
\cs_generate_variant:Nn \__tag_struct_kid_struct_gput_left:nn {ee} |
| 2498 |
\cs_new_protected:Npn\__tag_struct_kid_OBJR_gput_right:nnn #1 #2 #3 |
| 2499 |
|
| 2500 |
|
| 2501 |
%%#1 num of parent struct,#2 obj reference,#3 page object reference |
| 2502 |
{ |
| 2503 |
\pdf_object_unnamed_write:nn |
| 2504 |
{ dict } |
| 2505 |
{ |
| 2506 |
/Type/OBJR/Obj~#2/Pg~#3 |
| 2507 |
} |
| 2508 |
\__tag_seq_gput_right:ce |
| 2509 |
{ g__tag_struct_kids_#1_seq } |
| 2510 |
{ |
| 2511 |
\pdf_object_ref_last: |
| 2512 |
} |
| 2513 |
} |
| 2514 |
\cs_generate_variant:Nn\__tag_struct_kid_OBJR_gput_right:nnn { eee } |
| 2515 |
\cs_new_protected:Npn\__tag_struct_exchange_kid_command:N #1 %#1 = seq var |
| 2516 |
{ |
| 2517 |
\seq_gpop_left:NN #1 \l__tag_tmpa_tl |
| 2518 |
\tl_replace_once:Nnn \l__tag_tmpa_tl |
| 2519 |
{\__tag_mc_insert_mcid_kids:n} |
| 2520 |
{\__tag_mc_insert_mcid_single_kids:n} |
| 2521 |
\seq_gput_left:No #1 { \l__tag_tmpa_tl } |
| 2522 |
} |
| 2523 |
|
| 2524 |
\cs_generate_variant:Nn\__tag_struct_exchange_kid_command:N { c } |
| 2525 |
\cs_new_protected:Npn \__tag_struct_fill_kid_key:n #1 %#1 is the struct num |
| 2526 |
{ |
| 2527 |
\bool_if:NF \g__tag_mode_lua_bool |
| 2528 |
{ |
| 2529 |
\seq_clear:N \l__tag_tmpa_seq |
| 2530 |
\seq_map_inline:cn { g__tag_struct_kids_#1_seq } |
| 2531 |
{ \seq_put_right:Ne \l__tag_tmpa_seq { ##1 } } |
| 2532 |
%\seq_show:c { g__tag_struct_kids_#1_seq } |
| 2533 |
%\seq_show:N \l__tag_tmpa_seq |
| 2534 |
\seq_remove_all:Nn \l__tag_tmpa_seq {} |
| 2535 |
%\seq_show:N \l__tag_tmpa_seq |
| 2536 |
\seq_gset_eq:cN { g__tag_struct_kids_#1_seq } \l__tag_tmpa_seq |
| 2537 |
} |
| 2538 |
|
| 2539 |
\int_case:nnF |
| 2540 |
{ |
| 2541 |
\seq_count:c |
| 2542 |
{ |
| 2543 |
g__tag_struct_kids_#1_seq |
| 2544 |
} |
| 2545 |
} |
| 2546 |
{ |
| 2547 |
{ 0 } |
| 2548 |
{ } %no kids, do nothing |
| 2549 |
{ 1 } % 1 kid, insert |
| 2550 |
{ |
| 2551 |
% in this case we need a special command in |
| 2552 |
% luamode to get the array right. See issue #13 |
| 2553 |
\sys_if_engine_luatex:TF |
| 2554 |
{ |
| 2555 |
\__tag_struct_exchange_kid_command:c |
| 2556 |
{g__tag_struct_kids_#1_seq} |
| 2557 |
\tl_set:Ne\l__tag_tmpa_tl |
| 2558 |
{\use:e{\seq_item:cn {g__tag_struct_kids_#1_seq} {1}}} |
| 2559 |
\tl_if_eq:NNF\l__tag_tmpa_tl \c__tag_struct_null_tl |
| 2560 |
{ |
| 2561 |
\__tag_struct_prop_gput:nne |
| 2562 |
{#1} |
| 2563 |
{K} |
| 2564 |
{ |
| 2565 |
\seq_item:cn |
| 2566 |
{ |
| 2567 |
g__tag_struct_kids_#1_seq |
| 2568 |
} |
| 2569 |
{1} |
| 2570 |
} |
| 2571 |
} |
| 2572 |
} |
| 2573 |
{ |
| 2574 |
\__tag_struct_prop_gput:nne |
| 2575 |
{#1} |
| 2576 |
{K} |
| 2577 |
{ |
| 2578 |
\seq_item:cn |
| 2579 |
{ |
| 2580 |
g__tag_struct_kids_#1_seq |
| 2581 |
} |
| 2582 |
{1} |
| 2583 |
} |
| 2584 |
} |
| 2585 |
} % |
| 2586 |
} |
| 2587 |
{ %many kids, use an array |
| 2588 |
\__tag_struct_prop_gput:nne |
| 2589 |
{#1} |
| 2590 |
{K} |
| 2591 |
{ |
| 2592 |
[ |
| 2593 |
\seq_use:cn |
| 2594 |
{ |
| 2595 |
g__tag_struct_kids_#1_seq |
| 2596 |
} |
| 2597 |
{ |
| 2598 |
\c_space_tl |
| 2599 |
} |
| 2600 |
] |
| 2601 |
} |
| 2602 |
} |
| 2603 |
} |
| 2604 |
|
| 2605 |
\cs_new_protected:Npn \__tag_struct_get_dict_content:nN #1 #2 %#1: structure num |
| 2606 |
{ |
| 2607 |
\tl_clear:N #2 |
| 2608 |
\prop_map_inline:cn { g__tag_struct_#1_prop } |
| 2609 |
{ |
| 2610 |
\cs_if_exist_use:cTF {__tag_struct_format_##1:nnN} |
| 2611 |
{ |
| 2612 |
{##1}{##2}#2 |
| 2613 |
} |
| 2614 |
{ |
| 2615 |
\tl_put_right:Ne #2 { \c_space_tl/##1~##2 } |
| 2616 |
} |
| 2617 |
} |
| 2618 |
} |
| 2619 |
\cs_new:Nn\__tag_struct_format_rolemap:nnN{} |
| 2620 |
\cs_new:Nn\__tag_struct_format_parentrole:nnN{} |
| 2621 |
\cs_new:Nn\__tag_struct_format_tag:nnN{} |
| 2622 |
\cs_new_protected:Nn\__tag_struct_format_parentnum:nnN |
| 2623 |
{ |
| 2624 |
\tl_put_right:Ne #3 { ~/P~\pdf_object_ref_indexed:nn { __tag/struct} { #2 } } |
| 2625 |
} |
| 2626 |
\cs_new_protected:Nn\__tag_struct_format_Ref:nnN |
| 2627 |
{ |
| 2628 |
\tl_put_right:Nn #3 { ~/#1~[ } %] |
| 2629 |
\clist_map_inline:nn{ #2 } |
| 2630 |
{ |
| 2631 |
##1 #3 |
| 2632 |
} |
| 2633 |
\tl_put_right:Nn #3 |
| 2634 |
{ %[ |
| 2635 |
\c_space_tl] |
| 2636 |
} |
| 2637 |
} |
| 2638 |
\cs_new_protected:Npn \__tag_struct_write_obj:n #1 % #1 is the struct num |
| 2639 |
{ |
| 2640 |
\prop_if_exist:cTF { g__tag_struct_#1_prop } |
| 2641 |
{ |
| 2642 |
\prop_get:cnNF { g__tag_struct_#1_prop } {parentnum}\l__tag_tmpb_tl |
| 2643 |
{ |
| 2644 |
\prop_gput:cne { g__tag_struct_#1_prop } {parentnum}{2} |
| 2645 |
\prop_gput:cne { g__tag_struct_#1_prop } {S}{/Artifact} |
| 2646 |
\seq_if_empty:cF {g__tag_struct_kids_#1_seq} |
| 2647 |
{ |
| 2648 |
\msg_warning:nnee |
| 2649 |
{tag} |
| 2650 |
{struct-orphan} |
| 2651 |
{ #1 } |
| 2652 |
{\seq_count:c{g__tag_struct_kids_#1_seq}} |
| 2653 |
} |
| 2654 |
} |
| 2655 |
\__tag_struct_fill_kid_key:n { #1 } |
| 2656 |
\__tag_struct_get_dict_content:nN { #1 } \l__tag_tmpa_tl |
| 2657 |
\pdf_object_write_indexed:nnne |
| 2658 |
{ __tag/struct }{ #1 } |
| 2659 |
{dict} |
| 2660 |
{ |
| 2661 |
\l__tag_tmpa_tl\c_space_tl |
| 2662 |
/ID~\__tag_struct_get_id:n{#1} |
| 2663 |
} |
| 2664 |
|
| 2665 |
} |
| 2666 |
{ |
| 2667 |
\msg_error:nnn { tag } { struct-no-objnum } { #1} |
| 2668 |
} |
| 2669 |
} |
| 2670 |
\cs_new_protected:Npn \__tag_struct_insert_annot:nn #1 #2 |
| 2671 |
%#1 object reference to the annotation/xform |
| 2672 |
%#2 structparent number |
| 2673 |
{ |
| 2674 |
\bool_if:NT \g__tag_active_struct_bool |
| 2675 |
{ |
| 2676 |
%get the number of the parent structure: |
| 2677 |
\seq_get:NNF |
| 2678 |
\g__tag_struct_stack_seq |
| 2679 |
\l__tag_struct_stack_parent_tmpa_tl |
| 2680 |
{ |
| 2681 |
\msg_error:nn { tag } { struct-faulty-nesting } |
| 2682 |
} |
| 2683 |
%put the obj number of the annot in the kid entry, this also creates |
| 2684 |
%the OBJR object |
| 2685 |
\__tag_property_record:nn {@tag@objr@page@#2 }{ tagabspage } |
| 2686 |
\__tag_struct_kid_OBJR_gput_right:eee |
| 2687 |
{ |
| 2688 |
\l__tag_struct_stack_parent_tmpa_tl |
| 2689 |
} |
| 2690 |
{ |
| 2691 |
#1 % |
| 2692 |
} |
| 2693 |
{ |
| 2694 |
\pdf_pageobject_ref:n |
| 2695 |
{ \property_ref:nnn {@tag@objr@page@#2 }{ tagabspage }{1} } |
| 2696 |
} |
| 2697 |
% add the parent obj number to the parent tree: |
| 2698 |
% the command always expands its arguments! |
| 2699 |
\__tag_parenttree_add_objr:nn |
| 2700 |
{ |
| 2701 |
#2 |
| 2702 |
} |
| 2703 |
{ |
| 2704 |
\pdf_object_ref_indexed:nn |
| 2705 |
{ __tag/struct }{ \l__tag_struct_stack_parent_tmpa_tl } |
| 2706 |
} |
| 2707 |
% increase the int: |
| 2708 |
\int_gincr:N \c@g__tag_parenttree_obj_int |
| 2709 |
} |
| 2710 |
} |
| 2711 |
\cs_new_protected:Npn\__tag_struct_insert_annot_shipout:nnn #1#2#3 |
| 2712 |
{ |
| 2713 |
\__tag_struct_kid_OBJR_gput_right:eee |
| 2714 |
{ |
| 2715 |
#1 |
| 2716 |
} |
| 2717 |
{ |
| 2718 |
#2 |
| 2719 |
} |
| 2720 |
{ |
| 2721 |
\pdf_pageobject_ref:n |
| 2722 |
{ \int_use:N \g_shipout_readonly_int } % |
| 2723 |
} |
| 2724 |
% add the parent obj number to the parent tree: |
| 2725 |
% the command always expands its arguments! |
| 2726 |
\__tag_parenttree_add_objr:nn |
| 2727 |
{ |
| 2728 |
#3 |
| 2729 |
} |
| 2730 |
{ |
| 2731 |
\pdf_object_ref_indexed:nn |
| 2732 |
{ __tag/struct }{ #1 } |
| 2733 |
} |
| 2734 |
} |
| 2735 |
\cs_new:Npn \__tag_get_data_struct_tag: |
| 2736 |
{ |
| 2737 |
\exp_args:Ne |
| 2738 |
\tl_tail:n |
| 2739 |
{ |
| 2740 |
\prop_item:cn {g__tag_struct_\g__tag_struct_stack_current_tl _prop}{S} |
| 2741 |
} |
| 2742 |
} |
| 2743 |
\cs_new:Npn \__tag_get_data_struct_id: |
| 2744 |
{ |
| 2745 |
\__tag_struct_get_id:n {\g__tag_struct_stack_current_tl} |
| 2746 |
} |
| 2747 |
\cs_new_protected:Npn \__tag_struct_check_parent_child_aux:nnnnN #1#2#3#4#5 |
| 2748 |
{ |
| 2749 |
\__tag_struct_get_role:nnNN |
| 2750 |
{#1} |
| 2751 |
{#2} |
| 2752 |
\l__tag_get_parent_tmpa_tl |
| 2753 |
\l__tag_get_parent_tmpb_tl |
| 2754 |
\__tag_struct_get_role:nnNN |
| 2755 |
{#3} |
| 2756 |
{#4} |
| 2757 |
\l__tag_get_child_tmpa_tl |
| 2758 |
\l__tag_get_child_tmpb_tl |
| 2759 |
\__tag_role_check_parent_child:ooooN |
| 2760 |
{ \l__tag_get_parent_tmpa_tl } % rolemapped from above |
| 2761 |
{ \l__tag_get_parent_tmpb_tl } % rolemapped from above |
| 2762 |
{ \l__tag_get_child_tmpa_tl } % |
| 2763 |
{ \l__tag_get_child_tmpb_tl } % |
| 2764 |
#5 |
| 2765 |
} |
| 2766 |
\cs_new_protected:Npn \__tag_struct_check_parent_child:nn #1 #2 |
| 2767 |
{ |
| 2768 |
\int_compare:nNnT {\l__tag_loglevel_int} > { 0 } |
| 2769 |
{ |
| 2770 |
\prop_get:cnN{g__tag_struct_#1_prop}{tag}\l__tag_get_parent_tmpa_tl |
| 2771 |
\prop_get:cnN{g__tag_struct_#2_prop}{tag}\l__tag_get_parent_tmpb_tl |
| 2772 |
\msg_note:nnee |
| 2773 |
{ tag } |
| 2774 |
{ role-parent-child-check } |
| 2775 |
{ |
| 2776 |
\quark_if_no_value:NTF \l__tag_get_parent_tmpa_tl |
| 2777 |
{??} |
| 2778 |
{ |
| 2779 |
\exp_last_unbraced:No\use_ii:nn |
| 2780 |
{ \l__tag_get_parent_tmpa_tl } |
| 2781 |
: |
| 2782 |
\exp_last_unbraced:No\use_i:nn |
| 2783 |
{ \l__tag_get_parent_tmpa_tl } |
| 2784 |
} |
| 2785 |
} |
| 2786 |
{ |
| 2787 |
\quark_if_no_value:NTF \l__tag_get_parent_tmpb_tl |
| 2788 |
{??} |
| 2789 |
{ |
| 2790 |
\exp_last_unbraced:No\use_ii:nn |
| 2791 |
{ \l__tag_get_parent_tmpb_tl } |
| 2792 |
: |
| 2793 |
\exp_last_unbraced:No\use_i:nn |
| 2794 |
{ \l__tag_get_parent_tmpb_tl } |
| 2795 |
} |
| 2796 |
} |
| 2797 |
} |
| 2798 |
\__tag_struct_check_parent_child_aux:nnnnN |
| 2799 |
{#1} |
| 2800 |
{rolemap} |
| 2801 |
{#2} |
| 2802 |
{rolemap} |
| 2803 |
\l__tag_parent_child_check_tl |
| 2804 |
\int_compare:nNnT {\l__tag_parent_child_check_tl} = { \c__tag_role_rule_checkparent_tl } |
| 2805 |
{ |
| 2806 |
\__tag_struct_check_parent_child_aux:nnnnN |
| 2807 |
{#1} |
| 2808 |
{parentrole} |
| 2809 |
{#2} |
| 2810 |
{rolemap} |
| 2811 |
\l__tag_parent_child_check_tl |
| 2812 |
} |
| 2813 |
\__tag_check_struct_forbidden_parent_child:onn |
| 2814 |
{\l__tag_parent_child_check_tl} |
| 2815 |
{#1} |
| 2816 |
{#2} |
| 2817 |
} |
| 2818 |
\cs_generate_variant:Nn \__tag_struct_check_parent_child:nn {oo} |
| 2819 |
\cs_new_protected:Npn \__tag_struct_use_check_parent_child:nn #1 #2 |
| 2820 |
{ |
| 2821 |
\__tag_struct_get_role:enNN |
| 2822 |
{#2} |
| 2823 |
{rolemap} |
| 2824 |
\l__tag_get_child_tmpa_tl |
| 2825 |
\l__tag_get_child_tmpb_tl |
| 2826 |
\str_case:onTF { \l__tag_get_child_tmpa_tl } |
| 2827 |
{ |
| 2828 |
{Part} {} |
| 2829 |
{Div} {} |
| 2830 |
{NonStruct} {} |
| 2831 |
} |
| 2832 |
{ %child=Part etc |
| 2833 |
\__tag_struct_get_role:enNN |
| 2834 |
{#2} |
| 2835 |
{parentrole} |
| 2836 |
\l__tag_get_child_tmpa_tl |
| 2837 |
\l__tag_get_child_tmpb_tl |
| 2838 |
\str_if_eq:noTF |
| 2839 |
{STASHED}{\l__tag_get_child_tmpa_tl} |
| 2840 |
{ |
| 2841 |
% warn about unknown relationship |
| 2842 |
} |
| 2843 |
{ |
| 2844 |
% test if |
| 2845 |
\__tag_struct_get_role:enNN |
| 2846 |
{#1} |
| 2847 |
{parentrole} |
| 2848 |
\l__tag_get_parent_tmpa_tl |
| 2849 |
\l__tag_get_parent_tmpb_tl |
| 2850 |
\tl_if_eq:NNTF\l__tag_get_parent_tmpa_tl \l__tag_get_child_tmpa_tl |
| 2851 |
{ |
| 2852 |
\__tag_struct_check_parent_child:nn {#1}{#2} |
| 2853 |
} |
| 2854 |
{ |
| 2855 |
%warn that parent-tag was misused. |
| 2856 |
} |
| 2857 |
} |
| 2858 |
} |
| 2859 |
{ |
| 2860 |
%child not Part etc, normal parent child test. |
| 2861 |
\__tag_struct_check_parent_child:nn {#1}{#2} |
| 2862 |
} |
| 2863 |
} |
| 2864 |
\cs_generate_variant:Nn { \__tag_struct_use_check_parent_child:nn }{oo} |
| 2865 |
\socket_new:nn { tag/struct/tag }{1} |
| 2866 |
\socket_new_plug:nnn { tag/struct/tag }{ latex-tags } |
| 2867 |
{ |
| 2868 |
\prop_get:NeNTF \g__tag_role_tags_NS_prop {#1} \l__tag_tmp_unused_tl |
| 2869 |
{ |
| 2870 |
\seq_set_split:Nne \l__tag_tmpa_seq { / } |
| 2871 |
{#1/\l__tag_tmp_unused_tl} |
| 2872 |
} |
| 2873 |
{ |
| 2874 |
\seq_set_split:Nne \l__tag_tmpa_seq { / } |
| 2875 |
{#1/} |
| 2876 |
} |
| 2877 |
\tl_gset:Ne \g__tag_struct_tag_tl { \seq_item:Nn\l__tag_tmpa_seq {1} } |
| 2878 |
\tl_gset:Ne \g__tag_struct_tag_NS_tl{ \seq_item:Nn\l__tag_tmpa_seq {2} } |
| 2879 |
\__tag_check_structure_tag:N \g__tag_struct_tag_tl |
| 2880 |
} |
| 2881 |
|
| 2882 |
\socket_new_plug:nnn { tag/struct/tag }{ pdf-tags } |
| 2883 |
{ |
| 2884 |
\prop_get:NeNTF \g__tag_role_tags_NS_prop {#1} \l__tag_tmp_unused_tl |
| 2885 |
{ |
| 2886 |
\seq_set_split:Nne \l__tag_tmpa_seq { / } |
| 2887 |
{#1/\l__tag_tmp_unused_tl} |
| 2888 |
} |
| 2889 |
{ |
| 2890 |
\seq_set_split:Nne \l__tag_tmpa_seq { / } |
| 2891 |
{#1/} |
| 2892 |
} |
| 2893 |
\tl_gset:Ne \g__tag_struct_tag_tl { \seq_item:Nn\l__tag_tmpa_seq {1} } |
| 2894 |
\tl_gset:Ne \g__tag_struct_tag_NS_tl{ \seq_item:Nn\l__tag_tmpa_seq {2} } |
| 2895 |
\__tag_role_get:ooNN |
| 2896 |
{ \g__tag_struct_tag_tl } |
| 2897 |
{ \g__tag_struct_tag_NS_tl} |
| 2898 |
\l__tag_tmpa_tl |
| 2899 |
\l__tag_tmpb_tl |
| 2900 |
\tl_gset:Ne \g__tag_struct_tag_tl {\l__tag_tmpa_tl} |
| 2901 |
\tl_gset:Ne \g__tag_struct_tag_NS_tl{\l__tag_tmpb_tl} |
| 2902 |
\__tag_check_structure_tag:N \g__tag_struct_tag_tl |
| 2903 |
} |
| 2904 |
\socket_assign_plug:nn { tag/struct/tag } {latex-tags} |
| 2905 |
|
| 2906 |
\keys_define:nn { __tag / struct } |
| 2907 |
{ |
| 2908 |
label .code:n = |
| 2909 |
{ |
| 2910 |
\prop_gput:Nee\g__tag_struct_label_num_prop |
| 2911 |
{#1}{\int_use:N \c@g__tag_struct_abs_int} |
| 2912 |
\__tag_property_record:eo |
| 2913 |
{tagpdfstruct-#1} |
| 2914 |
{ \c__tag_property_struct_clist } |
| 2915 |
}, |
| 2916 |
stash .bool_set:N = \l__tag_struct_elem_stash_bool, |
| 2917 |
parent .code:n = |
| 2918 |
{ |
| 2919 |
\bool_lazy_and:nnTF |
| 2920 |
{ |
| 2921 |
\prop_if_exist_p:c { g__tag_struct_\int_eval:n {#1}_prop } |
| 2922 |
} |
| 2923 |
{ |
| 2924 |
\int_compare_p:nNn {#1}<{\c@g__tag_struct_abs_int} |
| 2925 |
} |
| 2926 |
{ \tl_set:Ne \l__tag_struct_stack_parent_tmpa_tl { \int_eval:n {#1} } } |
| 2927 |
{ |
| 2928 |
\msg_warning:nnee { tag } { struct-unknown } |
| 2929 |
{ \int_eval:n {#1} } |
| 2930 |
{ parent~key~ignored } |
| 2931 |
} |
| 2932 |
}, |
| 2933 |
parent .default:n = {-1}, |
| 2934 |
parent-tag .code:n = |
| 2935 |
{ |
| 2936 |
\prop_get:NeNTF \g__tag_role_tags_NS_prop {#1} \l__tag_tmp_unused_tl |
| 2937 |
{ |
| 2938 |
\seq_set_split:Nne \l__tag_tmpa_seq { / } |
| 2939 |
{#1/\l__tag_tmp_unused_tl} |
| 2940 |
} |
| 2941 |
{ |
| 2942 |
\seq_set_split:Nne \l__tag_tmpa_seq { / } |
| 2943 |
{#1/} |
| 2944 |
} |
| 2945 |
\tl_set:Ne \l__tag_struct_parenttag_tl { \seq_item:Nn\l__tag_tmpa_seq {1} } |
| 2946 |
\tl_set:Ne \l__tag_struct_parenttag_NS_tl{ \seq_item:Nn\l__tag_tmpa_seq {2} } |
| 2947 |
\__tag_role_get:ooNN |
| 2948 |
{ \l__tag_struct_parenttag_tl } |
| 2949 |
{ \l__tag_struct_parenttag_NS_tl} |
| 2950 |
\l__tag_tmpa_tl |
| 2951 |
\l__tag_tmpb_tl |
| 2952 |
\tl_set:No \l__tag_struct_parenttag_tl {\l__tag_tmpa_tl} |
| 2953 |
\tl_set:No \l__tag_struct_parenttag_NS_tl{\l__tag_tmpb_tl} |
| 2954 |
\__tag_check_structure_tag:N \l__tag_struct_parenttag_tl |
| 2955 |
}, |
| 2956 |
firstkid .code:n = { \tl_set:Nn \l__tag_struct_addkid_tl {left} }, |
| 2957 |
tag .code:n = % S property |
| 2958 |
{ |
| 2959 |
\socket_use:nn { tag/struct/tag }{#1} |
| 2960 |
}, |
| 2961 |
title .code:n = % T property |
| 2962 |
{ |
| 2963 |
\str_set_convert:Nnnn |
| 2964 |
\l__tag_tmpa_str |
| 2965 |
{ #1 } |
| 2966 |
{ default } |
| 2967 |
{ utf16/hex } |
| 2968 |
\__tag_struct_prop_gput:nne |
| 2969 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 2970 |
{ T } |
| 2971 |
{ <\l__tag_tmpa_str> } |
| 2972 |
}, |
| 2973 |
title-o .code:n = % T property |
| 2974 |
{ |
| 2975 |
\str_set_convert:Nonn |
| 2976 |
\l__tag_tmpa_str |
| 2977 |
{ #1 } |
| 2978 |
{ default } |
| 2979 |
{ utf16/hex } |
| 2980 |
\__tag_struct_prop_gput:nne |
| 2981 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 2982 |
{ T } |
| 2983 |
{ <\l__tag_tmpa_str> } |
| 2984 |
}, |
| 2985 |
alt .code:n = % Alt property |
| 2986 |
{ |
| 2987 |
\tl_if_empty:oF{#1} |
| 2988 |
{ |
| 2989 |
\str_set_convert:Noon |
| 2990 |
\l__tag_tmpa_str |
| 2991 |
{ #1 } |
| 2992 |
{ default } |
| 2993 |
{ utf16/hex } |
| 2994 |
\__tag_struct_prop_gput:nne |
| 2995 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 2996 |
{ Alt } |
| 2997 |
{ <\l__tag_tmpa_str> } |
| 2998 |
} |
| 2999 |
}, |
| 3000 |
alttext .meta:n = {alt=#1}, |
| 3001 |
actualtext .code:n = % ActualText property |
| 3002 |
{ |
| 3003 |
\tl_if_empty:oF{#1} |
| 3004 |
{ |
| 3005 |
\str_set_convert:Noon |
| 3006 |
\l__tag_tmpa_str |
| 3007 |
{ #1 } |
| 3008 |
{ default } |
| 3009 |
{ utf16/hex } |
| 3010 |
\__tag_struct_prop_gput:nne |
| 3011 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3012 |
{ ActualText } |
| 3013 |
{ <\l__tag_tmpa_str>} |
| 3014 |
} |
| 3015 |
}, |
| 3016 |
phoneme .code:n = % Phoneme property |
| 3017 |
{ |
| 3018 |
\tl_if_empty:oF{#1} |
| 3019 |
{ |
| 3020 |
\str_set_convert:Noon |
| 3021 |
\l__tag_tmpa_str |
| 3022 |
{ #1 } |
| 3023 |
{ default } |
| 3024 |
{ utf16/hex } |
| 3025 |
\__tag_struct_prop_gput:nne |
| 3026 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3027 |
{ Phoneme } |
| 3028 |
{ <\l__tag_tmpa_str>} |
| 3029 |
} |
| 3030 |
}, |
| 3031 |
lang .code:n = % Lang property |
| 3032 |
{ |
| 3033 |
\__tag_struct_prop_gput:nne |
| 3034 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3035 |
{ Lang } |
| 3036 |
{ (#1) } |
| 3037 |
}, |
| 3038 |
} |
| 3039 |
\cs_new_protected:Npn \__tag_struct_Ref_obj:nN #1 #2 %#1 a object reference |
| 3040 |
{ |
| 3041 |
\tl_put_right:Ne#2 |
| 3042 |
{ |
| 3043 |
\c_space_tl#1 |
| 3044 |
} |
| 3045 |
} |
| 3046 |
|
| 3047 |
\cs_new_protected:Npn \__tag_struct_Ref_label:nN #1 #2 %#1 a label |
| 3048 |
{ |
| 3049 |
\prop_get:NnNTF \g__tag_struct_label_num_prop {#1} \l__tag_tmpb_tl |
| 3050 |
{ |
| 3051 |
\tl_put_right:Ne#2 |
| 3052 |
{ |
| 3053 |
\c_space_tl\tag_struct_object_ref:e{ \l__tag_tmpb_tl } |
| 3054 |
} |
| 3055 |
} |
| 3056 |
{ |
| 3057 |
\msg_warning:nnn {tag}{struct-Ref-unknown}{Label~'#1'} |
| 3058 |
} |
| 3059 |
} |
| 3060 |
\cs_new_protected:Npn \__tag_struct_Ref_dest:nN #1 #2 %#1 a dest name |
| 3061 |
{ |
| 3062 |
\prop_get:NnNTF \g__tag_struct_dest_num_prop {#1} \l__tag_tmpb_tl |
| 3063 |
{ |
| 3064 |
\tl_put_right:Ne#2 |
| 3065 |
{ |
| 3066 |
\c_space_tl\tag_struct_object_ref:e{ \l__tag_tmpb_tl } |
| 3067 |
} |
| 3068 |
} |
| 3069 |
{ |
| 3070 |
\msg_warning:nnn {tag}{struct-Ref-unknown}{Destination~'#1'} |
| 3071 |
} |
| 3072 |
} |
| 3073 |
\cs_new_protected:Npn \__tag_struct_Ref_dest_parent:nN #1 #2 %#1 a dest name |
| 3074 |
{ |
| 3075 |
\prop_get:NnNTF \g__tag_struct_dest_num_prop {#1} \l__tag_tmpb_tl |
| 3076 |
{ %do not overwrite \l__tag_tmpa_tl! |
| 3077 |
\prop_get:cnN |
| 3078 |
{ g__tag_struct_\l__tag_tmpb_tl _prop }{parentnum}\l__tag_tmpb_tl |
| 3079 |
\tl_put_right:Ne#2 |
| 3080 |
{ |
| 3081 |
\c_space_tl\tag_struct_object_ref:e{ \l__tag_tmpb_tl } |
| 3082 |
} |
| 3083 |
} |
| 3084 |
{ |
| 3085 |
\msg_warning:nnn {tag}{struct-Ref-unknown}{Destination~'#1'} |
| 3086 |
} |
| 3087 |
} |
| 3088 |
\cs_new_protected:Npn \__tag_struct_Ref_num:nN #1 #2 %#1 a structure number |
| 3089 |
{ |
| 3090 |
\tl_put_right:Ne#2 |
| 3091 |
{ |
| 3092 |
\c_space_tl\tag_struct_object_ref:e{ #1 } |
| 3093 |
} |
| 3094 |
} |
| 3095 |
|
| 3096 |
\keys_define:nn { __tag / struct } |
| 3097 |
{ |
| 3098 |
ref .code:n = % ref property |
| 3099 |
{ |
| 3100 |
\clist_map_inline:on {#1} |
| 3101 |
{ |
| 3102 |
\tag_struct_gput:nne |
| 3103 |
{\int_use:N \c@g__tag_struct_abs_int}{ref_label}{ ##1 } |
| 3104 |
} |
| 3105 |
}, |
| 3106 |
E .code:n = % E property |
| 3107 |
{ |
| 3108 |
\str_set_convert:Nnon |
| 3109 |
\l__tag_tmpa_str |
| 3110 |
{ #1 } |
| 3111 |
{ default } |
| 3112 |
{ utf16/hex } |
| 3113 |
\__tag_struct_prop_gput:nne |
| 3114 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3115 |
{ E } |
| 3116 |
{ <\l__tag_tmpa_str> } |
| 3117 |
}, |
| 3118 |
} |
| 3119 |
\int_new:N\g__tag_struct_AFobj_int |
| 3120 |
\cs_generate_variant:Nn \pdffile_embed_stream:nnN {neN} |
| 3121 |
\cs_new_protected:Npn \__tag_struct_add_inline_AF:nn #1 #2 |
| 3122 |
{ |
| 3123 |
\tl_if_empty:nF{#1} |
| 3124 |
{ |
| 3125 |
\group_begin: |
| 3126 |
\int_gincr:N \g__tag_struct_AFobj_int |
| 3127 |
\pdffile_embed_stream:neN |
| 3128 |
{#1} |
| 3129 |
{tag-AFfile\int_use:N\g__tag_struct_AFobj_int.#2} |
| 3130 |
\l__tag_tmpa_tl |
| 3131 |
\__tag_struct_add_AF:ee |
| 3132 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3133 |
{ \l__tag_tmpa_tl } |
| 3134 |
\__tag_struct_prop_gput:nne |
| 3135 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3136 |
{ AF } |
| 3137 |
{ |
| 3138 |
[ |
| 3139 |
\tl_use:c |
| 3140 |
{ g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_AF_tl } |
| 3141 |
] |
| 3142 |
} |
| 3143 |
\group_end: |
| 3144 |
} |
| 3145 |
} |
| 3146 |
|
| 3147 |
\cs_generate_variant:Nn \__tag_struct_add_inline_AF:nn {on} |
| 3148 |
\cs_new_protected:Npn \__tag_struct_add_AF:nn #1 #2 |
| 3149 |
{ |
| 3150 |
\tl_if_exist:cTF |
| 3151 |
{ |
| 3152 |
g__tag_struct_#1_AF_tl |
| 3153 |
} |
| 3154 |
{ |
| 3155 |
\tl_gput_right:ce |
| 3156 |
{ g__tag_struct_#1_AF_tl } |
| 3157 |
{ \c_space_tl #2 } |
| 3158 |
} |
| 3159 |
{ |
| 3160 |
\tl_new:c |
| 3161 |
{ g__tag_struct_#1_AF_tl } |
| 3162 |
\tl_gset:ce |
| 3163 |
{ g__tag_struct_#1_AF_tl } |
| 3164 |
{ #2 } |
| 3165 |
} |
| 3166 |
} |
| 3167 |
\cs_generate_variant:Nn \__tag_struct_add_AF:nn {en,ee} |
| 3168 |
\keys_define:nn { __tag / struct } |
| 3169 |
{ |
| 3170 |
AF .code:n = % AF property |
| 3171 |
{ |
| 3172 |
\pdf_object_if_exist:eTF {#1} |
| 3173 |
{ |
| 3174 |
\__tag_struct_add_AF:ee |
| 3175 |
{ \int_use:N \c@g__tag_struct_abs_int }{\pdf_object_ref:e {#1}} |
| 3176 |
\__tag_struct_prop_gput:nne |
| 3177 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3178 |
{ AF } |
| 3179 |
{ |
| 3180 |
[ |
| 3181 |
\tl_use:c |
| 3182 |
{ g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_AF_tl } |
| 3183 |
] |
| 3184 |
} |
| 3185 |
} |
| 3186 |
{ |
| 3187 |
% message? |
| 3188 |
} |
| 3189 |
}, |
| 3190 |
AFref .code:n = % AF property |
| 3191 |
{ |
| 3192 |
\tl_if_empty:eF {#1} |
| 3193 |
{ |
| 3194 |
\__tag_struct_add_AF:ee { \int_use:N \c@g__tag_struct_abs_int }{#1} |
| 3195 |
\__tag_struct_prop_gput:nne |
| 3196 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3197 |
{ AF } |
| 3198 |
{ |
| 3199 |
[ |
| 3200 |
\tl_use:c |
| 3201 |
{ g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_AF_tl } |
| 3202 |
] |
| 3203 |
} |
| 3204 |
} |
| 3205 |
}, |
| 3206 |
,AFinline .code:n = |
| 3207 |
{ |
| 3208 |
\__tag_struct_add_inline_AF:nn {#1}{txt} |
| 3209 |
} |
| 3210 |
,AFinline-o .code:n = |
| 3211 |
{ |
| 3212 |
\__tag_struct_add_inline_AF:on {#1}{txt} |
| 3213 |
} |
| 3214 |
,texsource .code:n = |
| 3215 |
{ |
| 3216 |
\group_begin: |
| 3217 |
\pdfdict_put:nnn { l_pdffile/Filespec } {Desc}{(TeX~source)} |
| 3218 |
\pdfdict_put:nnn { l_pdffile/Filespec }{AFRelationship} { /Source } |
| 3219 |
\__tag_struct_add_inline_AF:on {#1}{tex} |
| 3220 |
\group_end: |
| 3221 |
} |
| 3222 |
,mathml .code:n = |
| 3223 |
{ |
| 3224 |
\group_begin: |
| 3225 |
\pdfdict_put:nnn { l_pdffile/Filespec } {Desc}{(mathml~representation)} |
| 3226 |
\pdfdict_put:nnn { l_pdffile/Filespec }{AFRelationship} { /Supplement } |
| 3227 |
\pdfdict_put:nne { l_pdffile }{Subtype} |
| 3228 |
{ \pdf_name_from_unicode_e:n{application/mathml+xml} } |
| 3229 |
\__tag_struct_add_inline_AF:on {#1}{xml} |
| 3230 |
\group_end: |
| 3231 |
} |
| 3232 |
} |
| 3233 |
\keys_define:nn { __tag / setup } |
| 3234 |
{ |
| 3235 |
root-AF .code:n = |
| 3236 |
{ |
| 3237 |
\pdf_object_if_exist:nTF {#1} |
| 3238 |
{ |
| 3239 |
\__tag_struct_add_AF:ee { 1 }{\pdf_object_ref:n {#1}} |
| 3240 |
\__tag_struct_prop_gput:nne |
| 3241 |
{ 1 } |
| 3242 |
{ AF } |
| 3243 |
{ |
| 3244 |
[ |
| 3245 |
\tl_use:c |
| 3246 |
{ g__tag_struct_1_AF_tl } |
| 3247 |
] |
| 3248 |
} |
| 3249 |
} |
| 3250 |
{ |
| 3251 |
|
| 3252 |
} |
| 3253 |
}, |
| 3254 |
} |
| 3255 |
\keys_define:nn { __tag / setup } |
| 3256 |
{ |
| 3257 |
root-supplemental-file .code:n = |
| 3258 |
{ |
| 3259 |
\group_begin: |
| 3260 |
\pdfdict_put:nnn {l_pdffile/Filespec} {AFRelationship}{/Supplement} |
| 3261 |
\int_gincr:N \g__tag_unique_cnt_int |
| 3262 |
\pdffile_embed_file:eee |
| 3263 |
{#1} |
| 3264 |
{#1} |
| 3265 |
{__tag_latex_css_\int_use:N\g__tag_unique_cnt_int} |
| 3266 |
\keys_set:nn |
| 3267 |
{__tag / setup} |
| 3268 |
{root-AF={__tag_latex_css_\int_use:N\g__tag_unique_cnt_int}} |
| 3269 |
\group_end: |
| 3270 |
} |
| 3271 |
} |
| 3272 |
\keys_define:nn { __tag / setup } |
| 3273 |
{ |
| 3274 |
catalog-supplemental-file .code:n = |
| 3275 |
{ |
| 3276 |
\group_begin: |
| 3277 |
\pdfdict_put:nnn {l_pdffile/Filespec} {AFRelationship}{/Supplement} |
| 3278 |
\int_gincr:N \g__tag_unique_cnt_int |
| 3279 |
\pdffile_embed_file:eee |
| 3280 |
{#1} |
| 3281 |
{#1} |
| 3282 |
{__tag_latex_css_\int_use:N\g__tag_unique_cnt_int} |
| 3283 |
\pdfmanagement_add:nne |
| 3284 |
{Catalog} |
| 3285 |
{AF} |
| 3286 |
{\pdf_object_ref:e{__tag_latex_css_\int_use:N\g__tag_unique_cnt_int }} |
| 3287 |
\group_end: |
| 3288 |
} |
| 3289 |
} |
| 3290 |
\tl_new:N \l__tag_struct_lang_tl |
| 3291 |
\cs_set_protected:Npn \tag_struct_begin:n #1 %#1 key-val |
| 3292 |
{ |
| 3293 |
\__tag_check_if_active_struct:T |
| 3294 |
{ |
| 3295 |
\group_begin: |
| 3296 |
\int_gincr:N \c@g__tag_struct_abs_int |
| 3297 |
\__tag_prop_new:c { g__tag_struct_\int_eval:n { \c@g__tag_struct_abs_int }_prop } |
| 3298 |
\__tag_seq_new:c { g__tag_struct_kids_\int_eval:n { \c@g__tag_struct_abs_int }_seq} |
| 3299 |
\pdf_object_new_indexed:nn { __tag/struct } |
| 3300 |
{ \c@g__tag_struct_abs_int } |
| 3301 |
\__tag_struct_prop_gput:nnn |
| 3302 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3303 |
{ Type } |
| 3304 |
{ /StructElem } |
| 3305 |
\tl_if_empty:NF \l__tag_struct_lang_tl |
| 3306 |
{ |
| 3307 |
\__tag_struct_prop_gput:nne |
| 3308 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3309 |
{ Lang } |
| 3310 |
{ (\l__tag_struct_lang_tl) } |
| 3311 |
} |
| 3312 |
\__tag_struct_prop_gput:nnn |
| 3313 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3314 |
{ Type } |
| 3315 |
{ /StructElem } |
| 3316 |
|
| 3317 |
\tl_set:Nn \l__tag_struct_stack_parent_tmpa_tl {-1} |
| 3318 |
\keys_set:nn { __tag / struct} { #1 } |
| 3319 |
\__tag_struct_set_tag_info:eoo |
| 3320 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3321 |
{ \g__tag_struct_tag_tl } |
| 3322 |
{ \g__tag_struct_tag_NS_tl } |
| 3323 |
\__tag_check_structure_has_tag:n { \int_use:N \c@g__tag_struct_abs_int } |
| 3324 |
\int_compare:nNnT { \l__tag_struct_stack_parent_tmpa_tl } = { -1 } |
| 3325 |
{ |
| 3326 |
\seq_get:NNF |
| 3327 |
\g__tag_struct_stack_seq |
| 3328 |
\l__tag_struct_stack_parent_tmpa_tl |
| 3329 |
{ |
| 3330 |
\msg_error:nn { tag } { struct-faulty-nesting } |
| 3331 |
} |
| 3332 |
} |
| 3333 |
\seq_gpush:NV \g__tag_struct_stack_seq \c@g__tag_struct_abs_int |
| 3334 |
\__tag_role_get:ooNN |
| 3335 |
{ \g__tag_struct_tag_tl } |
| 3336 |
{ \g__tag_struct_tag_NS_tl } |
| 3337 |
\l__tag_struct_roletag_tl |
| 3338 |
\l__tag_struct_roletag_NS_tl |
| 3339 |
\seq_gpush:Ne \g__tag_struct_tag_stack_seq |
| 3340 |
{{\g__tag_struct_tag_tl}{\l__tag_struct_roletag_tl}} |
| 3341 |
\seq_gpush:Ne \g__tag_struct_roletag_stack_seq |
| 3342 |
{\l__tag_struct_roletag_tl} |
| 3343 |
\tl_gset:NV \g__tag_struct_stack_current_tl \c@g__tag_struct_abs_int |
| 3344 |
\__tag_struct_set_attribute: |
| 3345 |
%\seq_show:N \g__tag_struct_stack_seq |
| 3346 |
\__tag_struct_prop_gput:nne |
| 3347 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3348 |
{ rolemap } |
| 3349 |
{ |
| 3350 |
{\l__tag_struct_roletag_tl}{\l__tag_struct_roletag_NS_tl} |
| 3351 |
} |
| 3352 |
\str_case:onTF { \l__tag_struct_roletag_tl } |
| 3353 |
{ |
| 3354 |
{Part} {} |
| 3355 |
{Div} {} |
| 3356 |
{NonStruct} {} |
| 3357 |
} |
| 3358 |
{ |
| 3359 |
\bool_if:NTF \l__tag_struct_elem_stash_bool |
| 3360 |
{ |
| 3361 |
\__tag_struct_prop_gput:nne |
| 3362 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3363 |
{ parentrole } |
| 3364 |
{ |
| 3365 |
{\l__tag_struct_parenttag_tl}{\l__tag_struct_parenttag_NS_tl} |
| 3366 |
} |
| 3367 |
} |
| 3368 |
{ |
| 3369 |
\prop_get:cnNT |
| 3370 |
{ g__tag_struct_ \l__tag_struct_stack_parent_tmpa_tl _prop } |
| 3371 |
{ parentrole } |
| 3372 |
\l__tag_get_tmpc_tl |
| 3373 |
{ |
| 3374 |
\__tag_struct_prop_gput:nno |
| 3375 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3376 |
{ parentrole } |
| 3377 |
{ |
| 3378 |
\l__tag_get_tmpc_tl |
| 3379 |
} |
| 3380 |
} |
| 3381 |
} |
| 3382 |
} |
| 3383 |
{ |
| 3384 |
\__tag_struct_prop_gput:nne |
| 3385 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3386 |
{ parentrole } |
| 3387 |
{ |
| 3388 |
{\l__tag_struct_roletag_tl}{\l__tag_struct_roletag_NS_tl} |
| 3389 |
} |
| 3390 |
} |
| 3391 |
\bool_if:NF |
| 3392 |
\l__tag_struct_elem_stash_bool |
| 3393 |
{ |
| 3394 |
\socket_use:nn{tag/check/parent-child} |
| 3395 |
{ |
| 3396 |
\__tag_struct_check_parent_child:oo |
| 3397 |
{ \l__tag_struct_stack_parent_tmpa_tl } |
| 3398 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3399 |
} |
| 3400 |
\__tag_struct_prop_gput:nne |
| 3401 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3402 |
{ parentnum } |
| 3403 |
{ |
| 3404 |
\l__tag_struct_stack_parent_tmpa_tl |
| 3405 |
} |
| 3406 |
%record this structure as kid: |
| 3407 |
%\tl_show:N \g__tag_struct_stack_current_tl |
| 3408 |
%\tl_show:N \l__tag_struct_stack_parent_tmpa_tl |
| 3409 |
\use:c { __tag_struct_kid_struct_gput_ \l__tag_struct_addkid_tl :ee } |
| 3410 |
{ \l__tag_struct_stack_parent_tmpa_tl } |
| 3411 |
{ \g__tag_struct_stack_current_tl } |
| 3412 |
%\prop_show:c { g__tag_struct_\g__tag_struct_stack_current_tl _prop } |
| 3413 |
%\seq_show:c {g__tag_struct_kids_\l__tag_struct_stack_parent_tmpa_tl _seq} |
| 3414 |
} |
| 3415 |
%\prop_show:c { g__tag_struct_\g__tag_struct_stack_current_tl _prop } |
| 3416 |
%\seq_show:c {g__tag_struct_kids_\l__tag_struct_stack_parent_tmpa_tl _seq} |
| 3417 |
\group_end: |
| 3418 |
} |
| 3419 |
} |
| 3420 |
\cs_set_protected:Nn \tag_struct_end: |
| 3421 |
{ %take the current structure num from the stack: |
| 3422 |
%the objects are written later, lua mode hasn't all needed info yet |
| 3423 |
%\seq_show:N \g__tag_struct_stack_seq |
| 3424 |
\__tag_check_if_active_struct:T |
| 3425 |
{ |
| 3426 |
\seq_gpop:NN \g__tag_struct_roletag_stack_seq \l__tag_tmpa_tl |
| 3427 |
\seq_gpop:NN \g__tag_struct_tag_stack_seq \l__tag_tmpa_tl |
| 3428 |
\seq_gpop:NNTF \g__tag_struct_stack_seq \l__tag_tmpa_tl |
| 3429 |
{ |
| 3430 |
\__tag_check_info_closing_struct:o { \g__tag_struct_stack_current_tl } |
| 3431 |
} |
| 3432 |
{ \__tag_check_no_open_struct: } |
| 3433 |
% get the previous one, shouldn't be empty as the root should be there |
| 3434 |
\seq_get:NNTF \g__tag_struct_stack_seq \l__tag_tmpa_tl |
| 3435 |
{ |
| 3436 |
\tl_gset:No \g__tag_struct_stack_current_tl { \l__tag_tmpa_tl } |
| 3437 |
\__tag_struct_set_attribute: |
| 3438 |
} |
| 3439 |
{ |
| 3440 |
\__tag_check_no_open_struct: |
| 3441 |
} |
| 3442 |
\seq_get:NNT \g__tag_struct_tag_stack_seq \l__tag_tmpa_tl |
| 3443 |
{ |
| 3444 |
\tl_gset:Ne \g__tag_struct_tag_tl |
| 3445 |
{ \exp_last_unbraced:No\use_i:nn { \l__tag_tmpa_tl } } |
| 3446 |
\prop_get:NoNT\g__tag_role_tags_NS_prop { \g__tag_struct_tag_tl} \l__tag_tmpa_tl |
| 3447 |
{ |
| 3448 |
\tl_gset:Ne \g__tag_struct_tag_NS_tl { \l__tag_tmpa_tl } |
| 3449 |
} |
| 3450 |
} |
| 3451 |
} |
| 3452 |
} |
| 3453 |
|
| 3454 |
\cs_set_protected:Npn \tag_struct_end:n #1 |
| 3455 |
{ |
| 3456 |
\tag_struct_end: |
| 3457 |
} |
| 3458 |
\cs_set_protected:Npn \tag_struct_use:n #1 %#1 is the label |
| 3459 |
{ |
| 3460 |
\__tag_check_if_active_struct:T |
| 3461 |
{ |
| 3462 |
\prop_if_exist:cTF |
| 3463 |
{ g__tag_struct_\property_ref:enn{tagpdfstruct-#1}{tagstruct}{unknown}_prop } % |
| 3464 |
{ |
| 3465 |
\__tag_check_struct_used:n {#1} |
| 3466 |
\tl_set:Ne \l__tag_get_child_tmpa_tl |
| 3467 |
{ \property_ref:enn{tagpdfstruct-#1}{tagstruct}{1} } |
| 3468 |
\__tag_struct_kid_struct_gput_right:ee |
| 3469 |
{ \g__tag_struct_stack_current_tl } |
| 3470 |
{ \l__tag_get_child_tmpa_tl } |
| 3471 |
\__tag_prop_gput:cne |
| 3472 |
{ g__tag_struct_ \l__tag_get_child_tmpa_tl _prop } |
| 3473 |
{ parentnum } |
| 3474 |
{ |
| 3475 |
\g__tag_struct_stack_current_tl |
| 3476 |
} |
| 3477 |
\socket_use:nn{tag/check/parent-child} |
| 3478 |
{ |
| 3479 |
\__tag_struct_use_check_parent_child:oo |
| 3480 |
{ \g__tag_struct_stack_current_tl } |
| 3481 |
{ \l__tag_get_child_tmpa_tl } |
| 3482 |
} |
| 3483 |
} |
| 3484 |
{ |
| 3485 |
\msg_warning:nnn{ tag }{struct-label-unknown}{#1} |
| 3486 |
} |
| 3487 |
} |
| 3488 |
} |
| 3489 |
\cs_set_protected:Npn \tag_struct_use_num:n #1 %#1 is structure number |
| 3490 |
{ |
| 3491 |
\__tag_check_if_active_struct:T |
| 3492 |
{ |
| 3493 |
\prop_if_exist:cTF |
| 3494 |
{ g__tag_struct_#1_prop } % |
| 3495 |
{ |
| 3496 |
\prop_get:cnNT |
| 3497 |
{g__tag_struct_#1_prop} |
| 3498 |
{parentnum} |
| 3499 |
\l__tag_tmpa_tl |
| 3500 |
{ |
| 3501 |
\msg_warning:nnn { tag } {struct-used-twice} {#1} |
| 3502 |
} |
| 3503 |
\__tag_struct_kid_struct_gput_right:ee |
| 3504 |
{ \g__tag_struct_stack_current_tl } |
| 3505 |
{ #1 } |
| 3506 |
\__tag_struct_prop_gput:nne |
| 3507 |
{ #1 } |
| 3508 |
{ parentnum } |
| 3509 |
{ |
| 3510 |
\g__tag_struct_stack_current_tl |
| 3511 |
} |
| 3512 |
\socket_use:nn{tag/check/parent-child} |
| 3513 |
{ |
| 3514 |
\__tag_struct_use_check_parent_child:oo |
| 3515 |
{\g__tag_struct_stack_current_tl} |
| 3516 |
{#1} |
| 3517 |
} |
| 3518 |
} |
| 3519 |
{ |
| 3520 |
\msg_warning:nnn{ tag }{struct-label-unknown}{#1} |
| 3521 |
} |
| 3522 |
} |
| 3523 |
} |
| 3524 |
\cs_generate_variant:Nn\tag_struct_use_num:n {o} |
| 3525 |
\cs_new:Npn \tag_struct_object_ref:n #1 |
| 3526 |
{ |
| 3527 |
\pdf_object_ref_indexed:nn {__tag/struct}{ #1 } |
| 3528 |
} |
| 3529 |
\cs_generate_variant:Nn \tag_struct_object_ref:n {e} |
| 3530 |
\cs_set_protected:Npn \tag_struct_gput:nnn #1 #2 #3 |
| 3531 |
{ |
| 3532 |
\cs_if_exist_use:cF {__tag_struct_gput_data_#2:nn} |
| 3533 |
{ %warning?? |
| 3534 |
\use_none:nn |
| 3535 |
} |
| 3536 |
{#1}{#3} |
| 3537 |
} |
| 3538 |
\cs_generate_variant:Nn \tag_struct_gput:nnn {ene,nne} |
| 3539 |
\cs_new_protected:Npn \__tag_struct_gput_data_ref_aux:nnn #1 #2 #3 |
| 3540 |
% #1 receiving struct num, #2 key word #3 value |
| 3541 |
{ |
| 3542 |
\prop_get:cnNTF |
| 3543 |
{ g__tag_struct_#1_prop } |
| 3544 |
{Ref} |
| 3545 |
\l__tag_get_tmpc_tl |
| 3546 |
{ |
| 3547 |
\tl_put_right:No \l__tag_get_tmpc_tl |
| 3548 |
{\cs:w __tag_struct_Ref_#2:nN \cs_end: {#3},} |
| 3549 |
} |
| 3550 |
{ |
| 3551 |
\tl_set:No \l__tag_get_tmpc_tl |
| 3552 |
{\cs:w __tag_struct_Ref_#2:nN \cs_end: {#3},} |
| 3553 |
} |
| 3554 |
\__tag_struct_prop_gput:nno |
| 3555 |
{ #1 } |
| 3556 |
{ Ref } |
| 3557 |
{ \l__tag_get_tmpc_tl } |
| 3558 |
} |
| 3559 |
\cs_new_protected:Npn \__tag_struct_gput_data_ref:nn #1 #2 |
| 3560 |
{ |
| 3561 |
\__tag_struct_gput_data_ref_aux:nnn {#1}{obj}{#2} |
| 3562 |
} |
| 3563 |
\cs_new_protected:Npn \__tag_struct_gput_data_ref_label:nn #1 #2 |
| 3564 |
{ |
| 3565 |
\__tag_struct_gput_data_ref_aux:nnn {#1}{label}{#2} |
| 3566 |
} |
| 3567 |
\cs_new_protected:Npn \__tag_struct_gput_data_ref_dest:nn #1 #2 |
| 3568 |
{ |
| 3569 |
\__tag_struct_gput_data_ref_aux:nnn {#1}{dest}{#2} |
| 3570 |
} |
| 3571 |
\cs_new_protected:Npn \__tag_struct_gput_data_ref_dest_parent:nn #1 #2 |
| 3572 |
{ |
| 3573 |
\__tag_struct_gput_data_ref_aux:nnn {#1}{dest_parent}{#2} |
| 3574 |
} |
| 3575 |
\cs_new_protected:Npn \__tag_struct_gput_data_ref_num:nn #1 #2 |
| 3576 |
{ |
| 3577 |
\__tag_struct_gput_data_ref_aux:nnn {#1}{num}{#2} |
| 3578 |
} |
| 3579 |
|
| 3580 |
\cs_generate_variant:Nn \__tag_struct_gput_data_ref:nn {ee,no} |
| 3581 |
\cs_new_protected:Npn \__tag_struct_gput_data_attribute:nn #1 #2 |
| 3582 |
{ |
| 3583 |
\pdf_object_unnamed_write:nn {dict} {#2} |
| 3584 |
\prop_get:cnNTF { g__tag_struct_#1_prop }{A} \l__tag_tmpa_tl |
| 3585 |
{ |
| 3586 |
\tl_remove_once:Nn\l__tag_tmpa_tl{[} |
| 3587 |
\tl_remove_once:Nn\l__tag_tmpa_tl{]} |
| 3588 |
\__tag_prop_gput:cne { g__tag_struct_#1_prop } |
| 3589 |
{ A } |
| 3590 |
{ |
| 3591 |
[ \l__tag_tmpa_tl \c_space_tl \pdf_object_ref_last: ] |
| 3592 |
} |
| 3593 |
} |
| 3594 |
{ |
| 3595 |
\__tag_prop_gput:cne { g__tag_struct_#1_prop } |
| 3596 |
{ A } |
| 3597 |
{ \pdf_object_ref_last: } |
| 3598 |
} |
| 3599 |
} |
| 3600 |
\cs_new_protected:Npn \tag_struct_insert_annot:nn #1 #2 %#1 should be an object reference |
| 3601 |
%#2 struct parent num |
| 3602 |
{ |
| 3603 |
\__tag_check_if_active_struct:T |
| 3604 |
{ |
| 3605 |
\__tag_struct_insert_annot:nn {#1}{#2} |
| 3606 |
} |
| 3607 |
} |
| 3608 |
|
| 3609 |
\cs_generate_variant:Nn \tag_struct_insert_annot:nn {xx,ee} |
| 3610 |
\cs_new:Npn \tag_struct_parent_int: {\int_use:c { c@g__tag_parenttree_obj_int }} |
| 3611 |
|
| 3612 |
|
| 3613 |
\prop_new:N \g__tag_attr_entries_prop |
| 3614 |
\prop_new_linked:N \g__tag_attr_class_used_prop |
| 3615 |
\tl_new:N \l__tag_attr_value_tl |
| 3616 |
\prop_new:N \g__tag_attr_objref_prop %will contain obj num of used attributes |
| 3617 |
\seq_new:N\g__tag_attr_class_used_seq |
| 3618 |
\cs_new_protected:Npn \__tag_attr_new_entry:nn #1 #2 %#1:name, #2: content |
| 3619 |
{ |
| 3620 |
\prop_gput:Nen \g__tag_attr_entries_prop |
| 3621 |
{\pdf_name_from_unicode_e:n{#1}}{#2} |
| 3622 |
} |
| 3623 |
|
| 3624 |
\cs_generate_variant:Nn \__tag_attr_new_entry:nn {ee} |
| 3625 |
\keys_define:nn { __tag / setup } |
| 3626 |
{ |
| 3627 |
role/new-attribute .code:n = |
| 3628 |
{ |
| 3629 |
\__tag_attr_new_entry:nn #1 |
| 3630 |
} |
| 3631 |
,newattribute .code:n = |
| 3632 |
{ |
| 3633 |
\__tag_attr_new_entry:nn #1 |
| 3634 |
}, |
| 3635 |
} |
| 3636 |
\keys_define:nn { __tag / struct } |
| 3637 |
{ |
| 3638 |
attribute-class .code:n = |
| 3639 |
{ |
| 3640 |
\clist_set:Ne \l__tag_tmpa_clist { #1 } |
| 3641 |
\seq_set_from_clist:NN \l__tag_tmpb_seq \l__tag_tmpa_clist |
| 3642 |
\seq_set_map_e:NNn \l__tag_tmpa_seq \l__tag_tmpb_seq |
| 3643 |
{ |
| 3644 |
\pdf_name_from_unicode_e:n {##1} |
| 3645 |
} |
| 3646 |
\seq_map_inline:Nn \l__tag_tmpa_seq |
| 3647 |
{ |
| 3648 |
\prop_get:NnNF \g__tag_attr_entries_prop {##1}\l__tag_tmpa_tl |
| 3649 |
{ |
| 3650 |
\msg_error:nnn { tag } { attr-unknown } { ##1 } |
| 3651 |
} |
| 3652 |
\prop_gput:Nnn\g__tag_attr_class_used_prop { ##1} {} |
| 3653 |
} |
| 3654 |
\tl_set:Ne \l__tag_tmpa_tl |
| 3655 |
{ |
| 3656 |
\int_compare:nT { \seq_count:N \l__tag_tmpa_seq > 1 }{[} |
| 3657 |
\seq_use:Nn \l__tag_tmpa_seq { \c_space_tl } |
| 3658 |
\int_compare:nT { \seq_count:N \l__tag_tmpa_seq > 1 }{]} |
| 3659 |
} |
| 3660 |
\int_compare:nT { \seq_count:N \l__tag_tmpa_seq > 0 } |
| 3661 |
{ |
| 3662 |
\__tag_struct_prop_gput:nne |
| 3663 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3664 |
{ C } |
| 3665 |
{ \l__tag_tmpa_tl } |
| 3666 |
%\prop_show:c { g__tag_struct_\int_eval:n {\c@g__tag_struct_abs_int}_prop } |
| 3667 |
} |
| 3668 |
} |
| 3669 |
} |
| 3670 |
\keys_define:nn { __tag / struct } |
| 3671 |
{ |
| 3672 |
attribute .code:n = % A property (attribute, value currently a dictionary) |
| 3673 |
{ |
| 3674 |
\clist_set:Ne \l__tag_tmpa_clist { #1 } |
| 3675 |
\clist_if_empty:NF \l__tag_tmpa_clist |
| 3676 |
{ |
| 3677 |
\seq_set_from_clist:NN \l__tag_tmpb_seq \l__tag_tmpa_clist |
| 3678 |
\seq_set_map_e:NNn \l__tag_tmpa_seq \l__tag_tmpb_seq |
| 3679 |
{ |
| 3680 |
\pdf_name_from_unicode_e:n {##1} |
| 3681 |
} |
| 3682 |
\tl_set:Ne \l__tag_attr_value_tl |
| 3683 |
{ |
| 3684 |
\int_compare:nT { \seq_count:N \l__tag_tmpa_seq > 1 }{[}%] |
| 3685 |
} |
| 3686 |
\seq_map_inline:Nn \l__tag_tmpa_seq |
| 3687 |
{ |
| 3688 |
\prop_get:NnNF \g__tag_attr_entries_prop {##1}\l__tag_tmp_unused_tl |
| 3689 |
{ |
| 3690 |
\msg_error:nnn { tag } { attr-unknown } { ##1 } |
| 3691 |
} |
| 3692 |
\prop_get:NnNF \g__tag_attr_objref_prop {##1}\l__tag_tmpa_tl |
| 3693 |
{%\prop_show:N \g__tag_attr_entries_prop |
| 3694 |
\pdf_object_unnamed_write:ne |
| 3695 |
{ dict } |
| 3696 |
{ |
| 3697 |
\prop_item:Nn\g__tag_attr_entries_prop {##1} |
| 3698 |
} |
| 3699 |
\prop_gput:Nne \g__tag_attr_objref_prop {##1} {\pdf_object_ref_last:} |
| 3700 |
} |
| 3701 |
\tl_put_right:Ne \l__tag_attr_value_tl |
| 3702 |
{ |
| 3703 |
\c_space_tl |
| 3704 |
\prop_item:Nn \g__tag_attr_objref_prop {##1} |
| 3705 |
} |
| 3706 |
% \tl_show:N \l__tag_attr_value_tl |
| 3707 |
} |
| 3708 |
\tl_put_right:Ne \l__tag_attr_value_tl |
| 3709 |
{ %[ |
| 3710 |
\int_compare:nT { \seq_count:N \l__tag_tmpa_seq > 1 }{]}% |
| 3711 |
} |
| 3712 |
% \tl_show:N \l__tag_attr_value_tl |
| 3713 |
\__tag_struct_prop_gput:nne |
| 3714 |
{ \int_use:N \c@g__tag_struct_abs_int } |
| 3715 |
{ A } |
| 3716 |
{ \l__tag_attr_value_tl } |
| 3717 |
} |
| 3718 |
}, |
| 3719 |
} |
| 3720 |
%% File: tagpdf-space.dtx |
| 3721 |
\bool_new:N\l__tag_showspaces_bool |
| 3722 |
\keys_define:nn { __tag / setup } |
| 3723 |
{ |
| 3724 |
activate/spaces .choice:, |
| 3725 |
activate/spaces/true .code:n = |
| 3726 |
{ \msg_warning:nne {tag}{sys-no-interwordspace}{\c_sys_engine_str} }, |
| 3727 |
activate/spaces/false .code:n= |
| 3728 |
{ \msg_warning:nne {tag}{sys-no-interwordspace}{\c_sys_engine_str} }, |
| 3729 |
activate/spaces .default:n = true, |
| 3730 |
debug/show/spaces .code:n = {\bool_set_true:N \l__tag_showspaces_bool}, |
| 3731 |
debug/show/spacesOff .code:n = {\bool_set_false:N \l__tag_showspaces_bool}, |
| 3732 |
interwordspace .choices:nn = {true,on}{\keys_set:nn{__tag/setup}{activate/spaces={true}}}, |
| 3733 |
interwordspace .choices:nn = {false,off}{\keys_set:nn{__tag/setup}{activate/spaces={false}}}, |
| 3734 |
interwordspace .default:n = {true}, |
| 3735 |
show-spaces .choice:, |
| 3736 |
show-spaces/true .meta:n = {debug/show=spaces}, |
| 3737 |
show-spaces/false .meta:n = {debug/show=spacesOff}, |
| 3738 |
show-spaces .default:n = true |
| 3739 |
} |
| 3740 |
\sys_if_engine_pdftex:T |
| 3741 |
{ |
| 3742 |
\sys_if_output_pdf:TF |
| 3743 |
{ |
| 3744 |
\pdfglyphtounicode{space}{0020} |
| 3745 |
\AddToHook{shipout/firstpage}[tagpdf/space]{} |
| 3746 |
\keys_define:nn { __tag / setup } |
| 3747 |
{ |
| 3748 |
activate/spaces/true .code:n = { \AddToHook{shipout/firstpage}[tagpdf/space]{\pdfinterwordspaceon} }, |
| 3749 |
activate/spaces/false .code:n = { \RemoveFromHook{shipout/firstpage}[tagpdf/space] }, |
| 3750 |
activate/spaces .default:n = true, |
| 3751 |
} |
| 3752 |
} |
| 3753 |
{ |
| 3754 |
\keys_define:nn { __tag / setup } |
| 3755 |
{ |
| 3756 |
activate/spaces .choices:nn = { true, false } |
| 3757 |
{ \msg_warning:nnn {tag}{sys-no-interwordspace}{dvi} }, |
| 3758 |
activate/spaces .default:n = true, |
| 3759 |
} |
| 3760 |
} |
| 3761 |
} |
| 3762 |
|
| 3763 |
\sys_if_engine_luatex:T |
| 3764 |
{ |
| 3765 |
\keys_define:nn { __tag / setup } |
| 3766 |
{ |
| 3767 |
activate/spaces .choice:, |
| 3768 |
activate/spaces/true .code:n = |
| 3769 |
{ |
| 3770 |
\bool_gset_true:N \g__tag_active_space_bool |
| 3771 |
\lua_now:e{ltx.__tag.func.markspaceon()} |
| 3772 |
}, |
| 3773 |
activate/spaces/false .code:n = |
| 3774 |
{ |
| 3775 |
\bool_gset_false:N \g__tag_active_space_bool |
| 3776 |
\lua_now:e{ltx.__tag.func.markspaceoff()} |
| 3777 |
}, |
| 3778 |
activate/spaces .default:n = true, |
| 3779 |
debug/show/spaces .code:n = |
| 3780 |
{\lua_now:e{ltx.__tag.trace.showspaces=true}}, |
| 3781 |
debug/show/spacesOff .code:n = |
| 3782 |
{\lua_now:e{ltx.__tag.trace.showspaces=nil}}, |
| 3783 |
} |
| 3784 |
} |
| 3785 |
\sys_if_engine_luatex:T |
| 3786 |
{ |
| 3787 |
\cs_new_protected:Nn \__tag_fakespace: |
| 3788 |
{ |
| 3789 |
\group_begin: |
| 3790 |
\lua_now:e{ltx.__tag.func.fakespace()} |
| 3791 |
\skip_horizontal:n{\c_zero_skip} |
| 3792 |
\group_end: |
| 3793 |
} |
| 3794 |
} |
| 3795 |
\cs_new_protected:Npn \tag_spacechar_off: {} |
| 3796 |
\cs_new_protected:Npn \tag_spacechar_on: {} |
| 3797 |
|
| 3798 |
\sys_if_engine_luatex:T |
| 3799 |
{ |
| 3800 |
\cs_set_protected:Npn \tag_spacechar_off: |
| 3801 |
{ |
| 3802 |
\lua_now:e |
| 3803 |
{ |
| 3804 |
tex.setattribute |
| 3805 |
( |
| 3806 |
"global", |
| 3807 |
luatexbase.attributes.g__tag_interwordspaceOff_attr, |
| 3808 |
1 |
| 3809 |
) |
| 3810 |
} |
| 3811 |
} |
| 3812 |
\cs_set_protected:Npn \tag_spacechar_on: |
| 3813 |
{ |
| 3814 |
\lua_now:e |
| 3815 |
{ |
| 3816 |
tex.setattribute |
| 3817 |
( |
| 3818 |
"global", |
| 3819 |
luatexbase.attributes.g__tag_interwordspaceOff_attr, |
| 3820 |
-2147483647 |
| 3821 |
) |
| 3822 |
} |
| 3823 |
} |
| 3824 |
} |
| 3825 |
\sys_if_engine_pdftex:T |
| 3826 |
{ |
| 3827 |
\sys_if_output_pdf:T |
| 3828 |
{ |
| 3829 |
\cs_set_protected:Npn \tag_spacechar_off: |
| 3830 |
{ |
| 3831 |
\pdfinterwordspaceoff |
| 3832 |
} |
| 3833 |
\cs_set_protected:Npn \tag_spacechar_on: |
| 3834 |
{ |
| 3835 |
\pdfinterwordspaceon |
| 3836 |
} |
| 3837 |
} |
| 3838 |
} |
| 3839 |
%% File: tagpdf-user.dtx |
| 3840 |
|
| 3841 |
|
| 3842 |
\RenewDocumentCommand \tagpdfsetup { m } |
| 3843 |
{ |
| 3844 |
\keys_set:nn { __tag / setup } { #1 } |
| 3845 |
} |
| 3846 |
\cs_set_protected:Npn\tag_tool:n #1 |
| 3847 |
{ |
| 3848 |
\tag_if_active:T { \keys_set:nn {tag / tool}{#1} } |
| 3849 |
} |
| 3850 |
\cs_set_eq:NN\tagtool\tag_tool:n |
| 3851 |
|
| 3852 |
|
| 3853 |
\NewDocumentCommand \tagmcifinTF { m m } |
| 3854 |
{ |
| 3855 |
\tag_mc_if_in:TF { #1 } { #2 } |
| 3856 |
} |
| 3857 |
\cs_set_protected:Npn \tag_socket_use:n #1 |
| 3858 |
{ |
| 3859 |
\bool_if:NT \l__tag_active_socket_bool |
| 3860 |
{ \socket_use:n {tagsupport/#1} } |
| 3861 |
} |
| 3862 |
\cs_set_protected:Npn \tag_socket_use:nn #1#2 |
| 3863 |
{ |
| 3864 |
\bool_if:NT \l__tag_active_socket_bool |
| 3865 |
{ \socket_use:nn {tagsupport/#1} {#2} } |
| 3866 |
} |
| 3867 |
\cs_set_protected:Npn \tag_socket_use:nnn #1#2#3 |
| 3868 |
{ |
| 3869 |
\bool_if:NTF \l__tag_active_socket_bool |
| 3870 |
{ \socket_use:nnn {tagsupport/#1} {#2} {#3} } |
| 3871 |
{ #3 } |
| 3872 |
} |
| 3873 |
\cs_set:Npn \tag_socket_use_expandable:n #1 |
| 3874 |
{ |
| 3875 |
\bool_if:NT \l__tag_active_socket_bool |
| 3876 |
{ \socket_use_expandable:n {tagsupport/#1} } |
| 3877 |
} |
| 3878 |
\cs_set_protected:Npn \UseTaggingSocket #1 |
| 3879 |
{ |
| 3880 |
\bool_if:NTF \l__tag_active_socket_bool |
| 3881 |
{ \socket_use:nw {tagsupport/#1} } |
| 3882 |
{ |
| 3883 |
\int_case:nnF |
| 3884 |
{ \int_use:c { c__socket_tagsupport/#1_args_int } } |
| 3885 |
{ |
| 3886 |
0 \prg_do_nothing: |
| 3887 |
1 \use_none:n |
| 3888 |
2 \use_ii:nn |
| 3889 |
} |
| 3890 |
\ERRORusetaggingsocket |
| 3891 |
} |
| 3892 |
} |
| 3893 |
|
| 3894 |
\cs_set:Npn \UseExpandableTaggingSocket #1 |
| 3895 |
{ |
| 3896 |
\bool_if:NTF \l__tag_active_socket_bool |
| 3897 |
{ \socket_use_expandable:nw {tagsupport/#1} } |
| 3898 |
{ |
| 3899 |
\int_case:nnF |
| 3900 |
{ \int_use:c { c__socket_tagsupport/#1_args_int } } |
| 3901 |
{ |
| 3902 |
0 \prg_do_nothing: |
| 3903 |
1 \use_none:n |
| 3904 |
2 \use_ii:nn |
| 3905 |
} |
| 3906 |
\ERRORusetaggingsocket |
| 3907 |
} |
| 3908 |
} |
| 3909 |
\NewDocumentCommand\ShowTagging { m } |
| 3910 |
{ |
| 3911 |
\keys_set:nn { __tag / show }{ #1} |
| 3912 |
|
| 3913 |
} |
| 3914 |
\keys_define:nn { __tag / show } |
| 3915 |
{ |
| 3916 |
mc-data .code:n = |
| 3917 |
{ |
| 3918 |
\bool_if:NT \g__tag_mode_lua_bool |
| 3919 |
{ |
| 3920 |
\lua_now:e{ltx.__tag.trace.show_all_mc_data(#1,\__tag_get_mc_abs_cnt:,0)} |
| 3921 |
} |
| 3922 |
} |
| 3923 |
,mc-data .default:n = 1 |
| 3924 |
} |
| 3925 |
|
| 3926 |
\keys_define:nn { __tag / show } |
| 3927 |
{ mc-current .code:n = |
| 3928 |
{ |
| 3929 |
\bool_if:NTF \g__tag_mode_lua_bool |
| 3930 |
{ |
| 3931 |
\int_compare:nNnTF |
| 3932 |
{ -2147483647 } |
| 3933 |
= |
| 3934 |
{ |
| 3935 |
\lua_now:e |
| 3936 |
{ |
| 3937 |
tex.print |
| 3938 |
(\int_use:N\c_document_cctab, |
| 3939 |
tex.getattribute |
| 3940 |
(luatexbase.attributes.g__tag_mc_cnt_attr)) |
| 3941 |
} |
| 3942 |
} |
| 3943 |
{ |
| 3944 |
\lua_now:e |
| 3945 |
{ |
| 3946 |
ltx.__tag.trace.log |
| 3947 |
( |
| 3948 |
"mc-current:~no~MC~open,~current~abscnt |
| 3949 |
=\__tag_get_mc_abs_cnt:" |
| 3950 |
,0 |
| 3951 |
) |
| 3952 |
texio.write_nl("") |
| 3953 |
} |
| 3954 |
} |
| 3955 |
{ |
| 3956 |
\lua_now:e |
| 3957 |
{ |
| 3958 |
ltx.__tag.trace.log |
| 3959 |
( |
| 3960 |
"mc-current:~abscnt=\__tag_get_mc_abs_cnt:==" |
| 3961 |
.. |
| 3962 |
tex.getattribute(luatexbase.attributes.g__tag_mc_cnt_attr) |
| 3963 |
.. |
| 3964 |
"~=>tag=" |
| 3965 |
.. |
| 3966 |
tostring |
| 3967 |
(ltx.__tag.func.get_tag_from |
| 3968 |
(tex.getattribute |
| 3969 |
(luatexbase.attributes.g__tag_mc_type_attr))) |
| 3970 |
.. |
| 3971 |
"=" |
| 3972 |
.. |
| 3973 |
tex.getattribute |
| 3974 |
(luatexbase.attributes.g__tag_mc_type_attr) |
| 3975 |
,0 |
| 3976 |
) |
| 3977 |
texio.write_nl("") |
| 3978 |
} |
| 3979 |
} |
| 3980 |
} |
| 3981 |
{ |
| 3982 |
\msg_note:nn{ tag }{ mc-current } |
| 3983 |
} |
| 3984 |
} |
| 3985 |
} |
| 3986 |
\keys_define:nn { __tag / show } |
| 3987 |
{ |
| 3988 |
mc-marks .choice: , |
| 3989 |
mc-marks / show .code:n = |
| 3990 |
{ |
| 3991 |
\__tag_mc_get_marks: |
| 3992 |
\__tag_check_if_mc_in_galley:TF |
| 3993 |
{ |
| 3994 |
\iow_term:n {Marks~from~this~page:~} |
| 3995 |
} |
| 3996 |
{ |
| 3997 |
\iow_term:n {Marks~from~a~previous~page:~} |
| 3998 |
} |
| 3999 |
\seq_show:N \l__tag_mc_firstmarks_seq |
| 4000 |
\seq_show:N \l__tag_mc_botmarks_seq |
| 4001 |
\__tag_check_if_mc_tmb_missing:T |
| 4002 |
{ |
| 4003 |
\iow_term:n {BDC~missing~on~this~page!} |
| 4004 |
} |
| 4005 |
\__tag_check_if_mc_tme_missing:T |
| 4006 |
{ |
| 4007 |
\iow_term:n {EMC~missing~on~this~page!} |
| 4008 |
} |
| 4009 |
}, |
| 4010 |
mc-marks / use .code:n = |
| 4011 |
{ |
| 4012 |
\__tag_mc_get_marks: |
| 4013 |
\__tag_check_if_mc_in_galley:TF |
| 4014 |
{ Marks~from~this~page:~} |
| 4015 |
{ Marks~from~a~previous~page:~} |
| 4016 |
\seq_use:Nn \l__tag_mc_firstmarks_seq {,~}\quad |
| 4017 |
\seq_use:Nn \l__tag_mc_botmarks_seq {,~}\quad |
| 4018 |
\__tag_check_if_mc_tmb_missing:T |
| 4019 |
{ |
| 4020 |
BDC~missing~ |
| 4021 |
} |
| 4022 |
\__tag_check_if_mc_tme_missing:T |
| 4023 |
{ |
| 4024 |
EMC~missing |
| 4025 |
} |
| 4026 |
}, |
| 4027 |
mc-marks .default:n = show |
| 4028 |
} |
| 4029 |
\keys_define:nn { __tag / show } |
| 4030 |
{ |
| 4031 |
struct-stack .choice: |
| 4032 |
,struct-stack / log .code:n = \seq_log:N \g__tag_struct_tag_stack_seq |
| 4033 |
,struct-stack / show .code:n = \seq_show:N \g__tag_struct_tag_stack_seq |
| 4034 |
,struct-stack .default:n = show |
| 4035 |
} |
| 4036 |
\tl_new:N\g__tag_root_default_tl |
| 4037 |
\tl_gset:Nn\g__tag_root_default_tl {Document} |
| 4038 |
|
| 4039 |
\hook_gput_code:nnn{begindocument}{tagpdf}{\tagstructbegin{tag=\g__tag_root_default_tl}} |
| 4040 |
\hook_gput_code:nnn{tagpdf/finish/before}{tagpdf}{\tagstructend} |
| 4041 |
|
| 4042 |
\keys_define:nn { __tag / setup} |
| 4043 |
{ |
| 4044 |
activate/socket .bool_set:N = \l__tag_active_socket_bool, |
| 4045 |
activate .code:n = |
| 4046 |
{ |
| 4047 |
\keys_set:nn { __tag / setup } |
| 4048 |
{ activate/mc,activate/tree,activate/struct,activate/socket } |
| 4049 |
\tl_gset:Nn\g__tag_root_default_tl {#1} |
| 4050 |
}, |
| 4051 |
activate .default:n = Document |
| 4052 |
} |
| 4053 |
|
| 4054 |
\AddToHook{begindocument/before} |
| 4055 |
{ |
| 4056 |
\bool_lazy_and:nnT |
| 4057 |
{ \g__tag_active_struct_dest_bool } |
| 4058 |
{ \g__tag_active_struct_bool } |
| 4059 |
{ |
| 4060 |
\tl_set:Nn \l_pdf_current_structure_destination_tl |
| 4061 |
{ {__tag/struct}{\g__tag_struct_stack_current_tl }} |
| 4062 |
\pdf_activate_indexed_structure_destination: |
| 4063 |
} |
| 4064 |
} |
| 4065 |
|
| 4066 |
\bool_if:NT \g__tag_mode_lua_bool |
| 4067 |
{ |
| 4068 |
\NewDocumentCommand\pdffakespace { } |
| 4069 |
{ |
| 4070 |
\__tag_fakespace: |
| 4071 |
} |
| 4072 |
} |
| 4073 |
\providecommand\pdffakespace{} |
| 4074 |
\int_new:N \g__tag_para_begin_int |
| 4075 |
\int_new:N \g__tag_para_end_int |
| 4076 |
\int_new:N \g__tag_para_main_begin_int |
| 4077 |
\int_new:N \g__tag_para_main_end_int |
| 4078 |
\tl_new:N \g__tag_para_main_struct_tl |
| 4079 |
\tl_gset:Nn \g__tag_para_main_struct_tl {1} |
| 4080 |
\tl_new:N \l__tag_para_tag_default_tl |
| 4081 |
\tl_new:N \l__tag_para_tag_tl |
| 4082 |
\tl_set:Nn \l__tag_para_tag_tl { \l__tag_para_tag_default_tl } |
| 4083 |
\tl_new:N \l__tag_para_main_tag_tl |
| 4084 |
\tl_set:Nn \l__tag_para_tag_default_tl { \UseStructureName {para/textblock} } |
| 4085 |
\tl_set:Nn \l__tag_para_main_tag_tl { \UseStructureName {para/semantic} } |
| 4086 |
\tl_new:N \l__tag_para_main_attr_class_tl |
| 4087 |
|
| 4088 |
\cs_new_protected:Npn \__tag_gincr_para_main_begin_int: |
| 4089 |
{ |
| 4090 |
\int_gincr:N \g__tag_para_main_begin_int |
| 4091 |
} |
| 4092 |
\cs_new_protected:Npn \__tag_gincr_para_begin_int: |
| 4093 |
{ |
| 4094 |
\int_gincr:N \g__tag_para_begin_int |
| 4095 |
} |
| 4096 |
\cs_new_protected:Npn \__tag_gincr_para_main_end_int: |
| 4097 |
{ |
| 4098 |
\int_gincr:N \g__tag_para_main_end_int |
| 4099 |
} |
| 4100 |
\cs_new_protected:Npn \__tag_gincr_para_end_int: |
| 4101 |
{ |
| 4102 |
\int_gincr:N \g__tag_para_end_int |
| 4103 |
} |
| 4104 |
\cs_new_protected:Npn \__tag_start_para_ints: |
| 4105 |
{ |
| 4106 |
\cs_set_protected:Npn \__tag_gincr_para_main_begin_int: |
| 4107 |
{ |
| 4108 |
\int_gincr:N \g__tag_para_main_begin_int |
| 4109 |
} |
| 4110 |
\cs_set_protected:Npn \__tag_gincr_para_begin_int: |
| 4111 |
{ |
| 4112 |
\int_gincr:N \g__tag_para_begin_int |
| 4113 |
} |
| 4114 |
\cs_set_protected:Npn \__tag_gincr_para_main_end_int: |
| 4115 |
{ |
| 4116 |
\int_gincr:N \g__tag_para_main_end_int |
| 4117 |
} |
| 4118 |
\cs_set_protected:Npn \__tag_gincr_para_end_int: |
| 4119 |
{ |
| 4120 |
\int_gincr:N \g__tag_para_end_int |
| 4121 |
} |
| 4122 |
} |
| 4123 |
\cs_new_protected:Npn \__tag_stop_para_ints: |
| 4124 |
{ |
| 4125 |
\cs_set_eq:NN \__tag_gincr_para_main_begin_int:\prg_do_nothing: |
| 4126 |
\cs_set_eq:NN \__tag_gincr_para_begin_int: \prg_do_nothing: |
| 4127 |
\cs_set_eq:NN \__tag_gincr_para_main_end_int: \prg_do_nothing: |
| 4128 |
\cs_set_eq:NN \__tag_gincr_para_end_int: \prg_do_nothing: |
| 4129 |
} |
| 4130 |
\cs_new:Npn \__tag_para_main_store_struct: |
| 4131 |
{ |
| 4132 |
\tl_gset:Ne \g__tag_para_main_struct_tl {\int_use:N \c@g__tag_struct_abs_int } |
| 4133 |
} |
| 4134 |
\keys_define:nn { __tag / setup } |
| 4135 |
{ |
| 4136 |
para/tagging .bool_set:N = \l__tag_para_bool, |
| 4137 |
debug/show/para .code:n = {\bool_set_true:N \l__tag_para_show_bool}, |
| 4138 |
debug/show/paraOff .code:n = {\bool_set_false:N \l__tag_para_show_bool}, |
| 4139 |
para/tag .tl_set:N = \l__tag_para_tag_tl, |
| 4140 |
para/maintag .tl_set:N = \l__tag_para_main_tag_tl, |
| 4141 |
para/flattened .bool_set:N = \l__tag_para_flattened_bool |
| 4142 |
} |
| 4143 |
\keys_define:nn { tag / tool} |
| 4144 |
{ |
| 4145 |
para/tagging .bool_set:N = \l__tag_para_bool, |
| 4146 |
para/tag .tl_set:N = \l__tag_para_tag_tl, |
| 4147 |
para/maintag .tl_set:N = \l__tag_para_main_tag_tl, |
| 4148 |
para/flattened .bool_set:N = \l__tag_para_flattened_bool |
| 4149 |
} |
| 4150 |
\keys_define:nn { __tag / setup } |
| 4151 |
{ |
| 4152 |
paratagging .bool_set:N = \l__tag_para_bool, |
| 4153 |
paratagging-show .bool_set:N = \l__tag_para_show_bool, |
| 4154 |
paratag .tl_set:N = \l__tag_para_tag_tl |
| 4155 |
} |
| 4156 |
\keys_define:nn { tag / tool} |
| 4157 |
{ |
| 4158 |
para .bool_set:N = \l__tag_para_bool, |
| 4159 |
paratag .tl_set:N = \l__tag_para_tag_tl, |
| 4160 |
unittag .tl_set:N = \l__tag_para_main_tag_tl, |
| 4161 |
para-flattened .bool_set:N = \l__tag_para_flattened_bool |
| 4162 |
} |
| 4163 |
\cs_new_protected:Npn \__tag_check_para_begin_show:nn #1 #2 |
| 4164 |
%#1 color, #2 prefix |
| 4165 |
{ |
| 4166 |
\bool_if:NT \l__tag_para_show_bool |
| 4167 |
{ |
| 4168 |
\tag_mc_begin:n{artifact} |
| 4169 |
\llap{\color_select:n{#1}\tiny#2\int_use:N\g__tag_para_begin_int\ } |
| 4170 |
\tag_mc_end: |
| 4171 |
} |
| 4172 |
} |
| 4173 |
|
| 4174 |
\cs_new_protected:Npn \__tag_check_para_end_show:nn #1 #2 |
| 4175 |
%#1 color, #2 prefix |
| 4176 |
{ |
| 4177 |
\bool_if:NT \l__tag_para_show_bool |
| 4178 |
{ |
| 4179 |
\tag_mc_begin:n{artifact} |
| 4180 |
\rlap{\color_select:n{#1}\tiny\ #2\int_use:N\g__tag_para_end_int} |
| 4181 |
\tag_mc_end: |
| 4182 |
} |
| 4183 |
} |
| 4184 |
\AddToHook{begindocument/before}[tagpdf/para] |
| 4185 |
{ |
| 4186 |
\AddToHook{para/begin}[tagpdf]{ \tag_socket_use:n { para/begin } } |
| 4187 |
\AddToHook{para/end} [tagpdf] { \tag_socket_use:n { para/end } } |
| 4188 |
} |
| 4189 |
\AddToHook{enddocument/info} |
| 4190 |
{ |
| 4191 |
\tag_if_active:F |
| 4192 |
{ |
| 4193 |
\msg_redirect_name:nnn { tag } { para-hook-count-wrong } { warning } |
| 4194 |
} |
| 4195 |
\int_compare:nNnF {\g__tag_para_main_begin_int}={\g__tag_para_main_end_int} |
| 4196 |
{ |
| 4197 |
\msg_error:nneee |
| 4198 |
{tag} |
| 4199 |
{para-hook-count-wrong} |
| 4200 |
{\int_use:N\g__tag_para_main_begin_int} |
| 4201 |
{\int_use:N\g__tag_para_main_end_int} |
| 4202 |
{text-unit} |
| 4203 |
} |
| 4204 |
\int_compare:nNnF {\g__tag_para_begin_int}={\g__tag_para_end_int} |
| 4205 |
{ |
| 4206 |
\msg_error:nneee |
| 4207 |
{tag} |
| 4208 |
{para-hook-count-wrong} |
| 4209 |
{\int_use:N\g__tag_para_begin_int} |
| 4210 |
{\int_use:N\g__tag_para_end_int} |
| 4211 |
{text} |
| 4212 |
} |
| 4213 |
} |
| 4214 |
\renewcommand\tagpdfparaOn {\bool_set_true:N \l__tag_para_bool} |
| 4215 |
\renewcommand\tagpdfparaOff{\bool_set_false:N \l__tag_para_bool} |
| 4216 |
\NewDocumentCommand\tagpdfsuppressmarks{m} |
| 4217 |
{{\use:c{__tag_mc_disable_marks:} #1}} |
| 4218 |
\keys_define:nn { __tag / setup } |
| 4219 |
{ |
| 4220 |
text / lang .tl_set:N = \l__tag_struct_lang_tl |
| 4221 |
} |
| 4222 |
\cs_new_protected:Npn\__tag_hook_kernel_before_head:{} |
| 4223 |
\cs_new_protected:Npn\__tag_hook_kernel_after_head:{} |
| 4224 |
\cs_new_protected:Npn\__tag_hook_kernel_before_foot:{} |
| 4225 |
\cs_new_protected:Npn\__tag_hook_kernel_after_foot:{} |
| 4226 |
\NewTaggingSocketPlug{build/page/header}{tagpdf} |
| 4227 |
{ |
| 4228 |
\__tag_hook_kernel_before_head: |
| 4229 |
#2 |
| 4230 |
\__tag_hook_kernel_after_head: |
| 4231 |
} |
| 4232 |
|
| 4233 |
\AssignTaggingSocketPlug{build/page/header}{tagpdf} |
| 4234 |
\NewTaggingSocketPlug{build/page/footer}{tagpdf} |
| 4235 |
{ |
| 4236 |
\__tag_hook_kernel_before_foot: |
| 4237 |
#2 |
| 4238 |
\__tag_hook_kernel_after_foot: |
| 4239 |
} |
| 4240 |
\AssignTaggingSocketPlug{build/page/footer}{tagpdf} |
| 4241 |
\bool_new:N \g__tag_saved_in_mc_bool |
| 4242 |
\cs_new_protected:Npn \__tag_exclude_headfoot_begin: |
| 4243 |
{ |
| 4244 |
\bool_set_false:N \l__tag_para_bool |
| 4245 |
\bool_if:NTF \g__tag_mode_lua_bool |
| 4246 |
{ |
| 4247 |
\tag_mc_end_push: |
| 4248 |
} |
| 4249 |
{ |
| 4250 |
\bool_gset_eq:NN \g__tag_saved_in_mc_bool \g__tag_in_mc_bool |
| 4251 |
\bool_gset_false:N \g__tag_in_mc_bool |
| 4252 |
} |
| 4253 |
\tag_mc_begin:n {artifact} |
| 4254 |
\tag_suspend:n{headfoot} |
| 4255 |
} |
| 4256 |
\cs_new_protected:Npn \__tag_exclude_headfoot_end: |
| 4257 |
{ |
| 4258 |
\tag_resume:n{headfoot} |
| 4259 |
\tag_mc_end: |
| 4260 |
\bool_if:NTF \g__tag_mode_lua_bool |
| 4261 |
{ |
| 4262 |
\tag_mc_begin_pop:n{} |
| 4263 |
} |
| 4264 |
{ |
| 4265 |
\bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_saved_in_mc_bool |
| 4266 |
} |
| 4267 |
} |
| 4268 |
\__tag_attr_new_entry:nn {__tag/attr/pagination}{/O/Artifact/Type/Pagination} |
| 4269 |
\cs_new_protected:Npn \__tag_exclude_struct_headfoot_begin:n #1 |
| 4270 |
{ |
| 4271 |
\bool_set_false:N \l__tag_para_bool |
| 4272 |
\bool_if:NTF \g__tag_mode_lua_bool |
| 4273 |
{ |
| 4274 |
\tag_mc_end_push: |
| 4275 |
} |
| 4276 |
{ |
| 4277 |
\bool_gset_eq:NN \g__tag_saved_in_mc_bool \g__tag_in_mc_bool |
| 4278 |
\bool_gset_false:N \g__tag_in_mc_bool |
| 4279 |
} |
| 4280 |
\tag_struct_begin:n{tag=Artifact,attribute-class=__tag/attr/#1} |
| 4281 |
\tag_mc_begin:n {artifact=#1} |
| 4282 |
\tag_suspend:n{headfoot} |
| 4283 |
} |
| 4284 |
|
| 4285 |
\cs_new_protected:Npn \__tag_exclude_struct_headfoot_end: |
| 4286 |
{ |
| 4287 |
\tag_resume:n{headfoot} |
| 4288 |
\tag_mc_end: |
| 4289 |
\tag_struct_end: |
| 4290 |
\bool_if:NTF \g__tag_mode_lua_bool |
| 4291 |
{ |
| 4292 |
\tag_mc_begin_pop:n{} |
| 4293 |
} |
| 4294 |
{ |
| 4295 |
\bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_saved_in_mc_bool |
| 4296 |
} |
| 4297 |
} |
| 4298 |
\keys_define:nn { __tag / setup } |
| 4299 |
{ |
| 4300 |
page/exclude-header-footer .choice:, |
| 4301 |
page/exclude-header-footer / true .code:n = |
| 4302 |
{ |
| 4303 |
\cs_set_eq:NN \__tag_hook_kernel_before_head: \__tag_exclude_headfoot_begin: |
| 4304 |
\cs_set_eq:NN \__tag_hook_kernel_before_foot: \__tag_exclude_headfoot_begin: |
| 4305 |
\cs_set_eq:NN \__tag_hook_kernel_after_head: \__tag_exclude_headfoot_end: |
| 4306 |
\cs_set_eq:NN \__tag_hook_kernel_after_foot: \__tag_exclude_headfoot_end: |
| 4307 |
}, |
| 4308 |
page/exclude-header-footer / pagination .code:n = |
| 4309 |
{ |
| 4310 |
\cs_set:Nn \__tag_hook_kernel_before_head: { \__tag_exclude_struct_headfoot_begin:n {pagination} } |
| 4311 |
\cs_set:Nn \__tag_hook_kernel_before_foot: { \__tag_exclude_struct_headfoot_begin:n {pagination} } |
| 4312 |
\cs_set_eq:NN \__tag_hook_kernel_after_head: \__tag_exclude_struct_headfoot_end: |
| 4313 |
\cs_set_eq:NN \__tag_hook_kernel_after_foot: \__tag_exclude_struct_headfoot_end: |
| 4314 |
}, |
| 4315 |
page/exclude-header-footer / false .code:n = |
| 4316 |
{ |
| 4317 |
\cs_set_eq:NN \__tag_hook_kernel_before_head: \prg_do_nothing: |
| 4318 |
\cs_set_eq:NN \__tag_hook_kernel_before_foot: \prg_do_nothing: |
| 4319 |
\cs_set_eq:NN \__tag_hook_kernel_after_head: \prg_do_nothing: |
| 4320 |
\cs_set_eq:NN \__tag_hook_kernel_after_foot: \prg_do_nothing: |
| 4321 |
}, |
| 4322 |
page/exclude-header-footer .default:n = true, |
| 4323 |
page/exclude-header-footer .initial:n = true, |
| 4324 |
exclude-header-footer .meta:n = { page/exclude-header-footer = {#1} } |
| 4325 |
} |
| 4326 |
\AtBeginDocument |
| 4327 |
{ |
| 4328 |
\NewTaggingSocketPlug{parbox/before}{tag/footer} |
| 4329 |
{ |
| 4330 |
\tag_struct_begin:n{tag=Span} |
| 4331 |
\tag_mc_begin:n{} |
| 4332 |
} |
| 4333 |
|
| 4334 |
\NewTaggingSocketPlug{parbox/after}{tag/footer} |
| 4335 |
{ |
| 4336 |
\tag_mc_end: |
| 4337 |
\tag_struct_end: |
| 4338 |
} |
| 4339 |
} |
| 4340 |
\cs_new_protected:Npn \__tag_headfoot_tagged_begin:n #1 |
| 4341 |
{ |
| 4342 |
\AssignTaggingSocketPlug{parbox/before}{tag/footer} |
| 4343 |
\AssignTaggingSocketPlug{parbox/after}{tag/footer} |
| 4344 |
\bool_set_false:N \l__tag_para_bool |
| 4345 |
\bool_if:NTF \g__tag_mode_lua_bool |
| 4346 |
{ |
| 4347 |
\tag_mc_end_push: |
| 4348 |
} |
| 4349 |
{ |
| 4350 |
\bool_gset_eq:NN \g__tag_saved_in_mc_bool \g__tag_in_mc_bool |
| 4351 |
\bool_gset_false:N \g__tag_in_mc_bool |
| 4352 |
} |
| 4353 |
\tag_struct_begin:n{tag=Artifact,attribute-class=__tag/attr/#1,parent=\tag_get:n{current_Sect}} |
| 4354 |
} |
| 4355 |
|
| 4356 |
\cs_new_protected:Npn \__tag_headfoot_tagged_end: |
| 4357 |
{ |
| 4358 |
\tag_struct_end: |
| 4359 |
\bool_if:NTF \g__tag_mode_lua_bool |
| 4360 |
{ |
| 4361 |
\tag_mc_begin_pop:n{} |
| 4362 |
} |
| 4363 |
{ |
| 4364 |
\bool_gset_eq:NN \g__tag_in_mc_bool\g__tag_saved_in_mc_bool |
| 4365 |
} |
| 4366 |
} |
| 4367 |
\keys_define:nn { __tag / setup } |
| 4368 |
{ |
| 4369 |
page/tag-header-footer .choice:, |
| 4370 |
page/tag-header-footer/artifact .code:n = |
| 4371 |
{ |
| 4372 |
\cs_set:Nn \__tag_hook_kernel_before_head: { \__tag_headfoot_tagged_begin:n {pagination}} |
| 4373 |
\cs_set:Nn \__tag_hook_kernel_before_foot: { \__tag_headfoot_tagged_begin:n {pagination}} |
| 4374 |
\cs_set_eq:NN \__tag_hook_kernel_after_head: \__tag_headfoot_tagged_end: |
| 4375 |
\cs_set_eq:NN \__tag_hook_kernel_after_foot: \__tag_headfoot_tagged_end: |
| 4376 |
}, |
| 4377 |
page/tag-header-footer .default:n = artifact, |
| 4378 |
} |
| 4379 |
\AddToHookNext{class/before} |
| 4380 |
{ |
| 4381 |
\cs_if_exist:NF \l__tag_name_link_tl |
| 4382 |
{ |
| 4383 |
\tl_new:N \l__tag_name_link_tl |
| 4384 |
\tl_set:Nn \l__tag_name_link_tl{Link} |
| 4385 |
} |
| 4386 |
} |
| 4387 |
\socket_if_exist:nF {tagsupport/link/before} |
| 4388 |
{ |
| 4389 |
\NewTaggingSocket{link/before}{1} |
| 4390 |
\NewTaggingSocket{link/after}{1} |
| 4391 |
} |
| 4392 |
\NewTaggingSocketPlug{link/before}{kernel} |
| 4393 |
{ |
| 4394 |
\mode_leave_vertical: |
| 4395 |
\tag_mc_end_push: |
| 4396 |
\tag_struct_begin:n { tag=\UseStructureName{link} } |
| 4397 |
\tag_mc_begin:n {} |
| 4398 |
#1 |
| 4399 |
} |
| 4400 |
\AssignTaggingSocketPlug{link/before}{kernel} |
| 4401 |
|
| 4402 |
\NewTaggingSocketPlug{link/after}{kernel} |
| 4403 |
{ |
| 4404 |
#1 |
| 4405 |
\tag_mc_end: |
| 4406 |
\tag_struct_end: |
| 4407 |
\tag_mc_begin_pop:n{} |
| 4408 |
} |
| 4409 |
\AssignTaggingSocketPlug{link/after}{kernel} |
| 4410 |
|
| 4411 |
\bool_lazy_and:nnTF |
| 4412 |
{ \sys_if_engine_luatex_p: } |
| 4413 |
{ |
| 4414 |
\tl_if_empty_p:e |
| 4415 |
{ |
| 4416 |
\lua_now:e |
| 4417 |
{ if~ luatexbase.in_callback('pre_shipout_filter','linksplit')~ |
| 4418 |
then~else~tex.print('1')~end |
| 4419 |
} |
| 4420 |
} |
| 4421 |
} |
| 4422 |
{ |
| 4423 |
\hook_gput_code:nnn |
| 4424 |
{pdfannot/link/URI/before} |
| 4425 |
{tagpdf} |
| 4426 |
{ |
| 4427 |
\UseTaggingSocket{link/before}{} |
| 4428 |
} |
| 4429 |
|
| 4430 |
\hook_gput_code:nnn |
| 4431 |
{pdfannot/link/URI/after} |
| 4432 |
{tagpdf} |
| 4433 |
{ |
| 4434 |
\UseTaggingSocket{link/after}{} |
| 4435 |
} |
| 4436 |
|
| 4437 |
\hook_gput_code:nnn |
| 4438 |
{pdfannot/link/GoTo/before} |
| 4439 |
{tagpdf} |
| 4440 |
{ |
| 4441 |
\UseTaggingSocket{link/before}{} |
| 4442 |
} |
| 4443 |
|
| 4444 |
\hook_gput_code:nnn |
| 4445 |
{pdfannot/link/GoTo/after} |
| 4446 |
{tagpdf} |
| 4447 |
{ |
| 4448 |
\UseTaggingSocket{link/after}{} |
| 4449 |
} |
| 4450 |
|
| 4451 |
\hook_gput_code:nnn |
| 4452 |
{pdfannot/link/GoToR/before} |
| 4453 |
{tagpdf} |
| 4454 |
{ |
| 4455 |
\UseTaggingSocket{link/before} |
| 4456 |
} |
| 4457 |
|
| 4458 |
\hook_gput_code:nnn |
| 4459 |
{pdfannot/link/GoToR/after} |
| 4460 |
{tagpdf} |
| 4461 |
{ |
| 4462 |
\UseTaggingSocket{link/after}{} |
| 4463 |
} |
| 4464 |
\hook_gput_code:nnn |
| 4465 |
{pdfannot/link/Launch/before} |
| 4466 |
{tagpdf} |
| 4467 |
{ |
| 4468 |
\UseTaggingSocket{link/before}{} |
| 4469 |
} |
| 4470 |
|
| 4471 |
\hook_gput_code:nnn |
| 4472 |
{pdfannot/link/Launch/after} |
| 4473 |
{tagpdf} |
| 4474 |
{ |
| 4475 |
\UseTaggingSocket{link/after}{} |
| 4476 |
} |
| 4477 |
\hook_gput_code:nnn |
| 4478 |
{pdfannot/link/Named/before} |
| 4479 |
{tagpdf} |
| 4480 |
{ |
| 4481 |
\UseTaggingSocket{link/before}{} |
| 4482 |
} |
| 4483 |
|
| 4484 |
\hook_gput_code:nnn |
| 4485 |
{pdfannot/link/Named/after} |
| 4486 |
{tagpdf} |
| 4487 |
{ |
| 4488 |
\UseTaggingSocket{link/after}{} |
| 4489 |
} |
| 4490 |
} |
| 4491 |
{ |
| 4492 |
\hook_gput_code:nnn |
| 4493 |
{pdfannot/link/URI/before} |
| 4494 |
{tagpdf} |
| 4495 |
{ |
| 4496 |
\UseTaggingSocket{link/before} |
| 4497 |
{ |
| 4498 |
\pdfannot_dict_put:nne |
| 4499 |
{ link/URI } |
| 4500 |
{ StructParent } |
| 4501 |
{ \tag_struct_parent_int: } |
| 4502 |
} |
| 4503 |
} |
| 4504 |
|
| 4505 |
\hook_gput_code:nnn |
| 4506 |
{pdfannot/link/URI/after} |
| 4507 |
{tagpdf} |
| 4508 |
{ |
| 4509 |
\UseTaggingSocket{link/after} |
| 4510 |
{ |
| 4511 |
\tag_struct_insert_annot:ee |
| 4512 |
{\pdfannot_link_ref_last:}{\tag_struct_parent_int:} |
| 4513 |
} |
| 4514 |
} |
| 4515 |
|
| 4516 |
\hook_gput_code:nnn |
| 4517 |
{pdfannot/link/GoTo/before} |
| 4518 |
{tagpdf} |
| 4519 |
{ |
| 4520 |
\UseTaggingSocket{link/before} |
| 4521 |
{ |
| 4522 |
\pdfannot_dict_put:nne |
| 4523 |
{ link/GoTo } |
| 4524 |
{ StructParent } |
| 4525 |
{ \tag_struct_parent_int: } |
| 4526 |
} |
| 4527 |
} |
| 4528 |
|
| 4529 |
\hook_gput_code:nnn |
| 4530 |
{pdfannot/link/GoTo/after} |
| 4531 |
{tagpdf} |
| 4532 |
{ |
| 4533 |
\UseTaggingSocket{link/after} |
| 4534 |
{ |
| 4535 |
\tag_struct_insert_annot:ee |
| 4536 |
{\pdfannot_link_ref_last:}{\tag_struct_parent_int:} |
| 4537 |
} |
| 4538 |
} |
| 4539 |
|
| 4540 |
\hook_gput_code:nnn |
| 4541 |
{pdfannot/link/GoToR/before} |
| 4542 |
{tagpdf} |
| 4543 |
{ |
| 4544 |
\UseTaggingSocket{link/before} |
| 4545 |
{ |
| 4546 |
\pdfannot_dict_put:nne |
| 4547 |
{ link/GoToR } |
| 4548 |
{ StructParent } |
| 4549 |
{ \tag_struct_parent_int: } |
| 4550 |
} |
| 4551 |
} |
| 4552 |
|
| 4553 |
\hook_gput_code:nnn |
| 4554 |
{pdfannot/link/GoToR/after} |
| 4555 |
{tagpdf} |
| 4556 |
{ |
| 4557 |
\UseTaggingSocket{link/after} |
| 4558 |
{ |
| 4559 |
\tag_struct_insert_annot:ee |
| 4560 |
{\pdfannot_link_ref_last:}{\tag_struct_parent_int:} |
| 4561 |
} |
| 4562 |
} |
| 4563 |
|
| 4564 |
\hook_gput_code:nnn |
| 4565 |
{pdfannot/link/Named/before} |
| 4566 |
{tagpdf} |
| 4567 |
{ |
| 4568 |
\UseTaggingSocket{link/before} |
| 4569 |
{ |
| 4570 |
\pdfannot_dict_put:nne |
| 4571 |
{ link/Named } |
| 4572 |
{ StructParent } |
| 4573 |
{ \tag_struct_parent_int: } |
| 4574 |
} |
| 4575 |
} |
| 4576 |
|
| 4577 |
\hook_gput_code:nnn |
| 4578 |
{pdfannot/link/Named/after} |
| 4579 |
{tagpdf} |
| 4580 |
{ |
| 4581 |
\UseTaggingSocket{link/after} |
| 4582 |
{ |
| 4583 |
\tag_struct_insert_annot:ee |
| 4584 |
{\pdfannot_link_ref_last:}{\tag_struct_parent_int:} |
| 4585 |
} |
| 4586 |
} |
| 4587 |
\hook_gput_code:nnn |
| 4588 |
{pdfannot/link/Launch/before} |
| 4589 |
{tagpdf} |
| 4590 |
{ |
| 4591 |
\UseTaggingSocket{link/before} |
| 4592 |
{ |
| 4593 |
\pdfannot_dict_put:nne |
| 4594 |
{ link/Launch } |
| 4595 |
{ StructParent } |
| 4596 |
{ \tag_struct_parent_int: } |
| 4597 |
} |
| 4598 |
} |
| 4599 |
|
| 4600 |
\hook_gput_code:nnn |
| 4601 |
{pdfannot/link/Launch/after} |
| 4602 |
{tagpdf} |
| 4603 |
{ |
| 4604 |
\UseTaggingSocket{link/after} |
| 4605 |
{ |
| 4606 |
\tag_struct_insert_annot:ee |
| 4607 |
{\pdfannot_link_ref_last:}{\tag_struct_parent_int:} |
| 4608 |
} |
| 4609 |
} |
| 4610 |
} |
| 4611 |
\prop_new:N \g__tag_css_prop |
| 4612 |
\prop_gset_from_keyval:Nn \g__tag_css_prop |
| 4613 |
{ |
| 4614 |
latex-list-css.html=true, |
| 4615 |
latex-align-css.html=true |
| 4616 |
} |
| 4617 |
|
| 4618 |
\bool_new:N \g__tag_css_bool |
| 4619 |
\bool_gset_true:N \g__tag_css_bool |
| 4620 |
\tl_gput_left:Nn \g__kernel_pdfmanagement_end_run_code_tl |
| 4621 |
{ |
| 4622 |
\bool_lazy_and:nnT { \g__tag_css_bool }{ \tag_if_active_p: } |
| 4623 |
{ |
| 4624 |
\prop_map_inline:Nn \g__tag_css_prop |
| 4625 |
{ |
| 4626 |
\keys_set:nn { __tag / setup }{ catalog-supplemental-file= {#1} } |
| 4627 |
} |
| 4628 |
} |
| 4629 |
} |
| 4630 |
|
| 4631 |
\keys_define:nn { __tag / setup } |
| 4632 |
{ |
| 4633 |
attach-css .bool_gset:N = \g__tag_css_bool, |
| 4634 |
css-list .code:n = |
| 4635 |
{ |
| 4636 |
\tl_if_empty:nTF{#1} |
| 4637 |
{\prop_gclear:N \g__tag_css_prop } |
| 4638 |
{\prop_gput:Nnn \g__tag_css_prop { #1 }{true}} |
| 4639 |
}, |
| 4640 |
css-list-add .code:n = { \prop_gput:Nnn \g__tag_css_prop { #1 }{true} }, |
| 4641 |
css-list-remove .code:n = { \prop_gremove:Nn \g__tag_css_prop { #1 } }, |
| 4642 |
} |
| 4643 |
%% |
| 4644 |
%% |
| 4645 |
%% End of file `tagpdf.sty'. |