diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty new file mode 100644 index 00000000000..b1959acc42e --- /dev/null +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty @@ -0,0 +1,177 @@ +\ProvidesExplPackage {tagpdf-checks-code} {2018/07/04} {0.1} + {part of tagpdf - code related to checks and messages} + + +%messages + +% mc +\msg_new:nnn { tagpdf } { mc-nested } { nested~marked~content~found~-~mcid~#1 } +\msg_new:nnn { tagpdf } { mc-tag-missing } { required~tag~missing~-~mcid~#1 } +\msg_new:nnn { tagpdf } { mc-label-unknown }{ label~#1~unknown~-~rerun } +\msg_new:nnn { tagpdf } { mc-used-twice } { mc~#1~has~been~already~used } +\msg_new:nnn { tagpdf } { mc-not-open } { there~is~no~mc~to~end~at~#1 } + +% structures +\msg_new:nnn { tagpdf } { struct-no-objnum } { objnum~missing~for~structure~#1 } +\msg_new:nnn { tagpdf } { struct-faulty-nesting } { there~is~no~open~structure~on~the~stack } +\msg_new:nnn { tagpdf } { struct-missing-tag } { a~structure~must~have~a~tag! } +\msg_new:nnn { tagpdf } { struct-show-closing } { closing~structure~#1~tagged~\prop_item:cn{g__uftag_struct_#1_prop}{S} } +\msg_new:nnn { tagpdf } { struct-used-twice} { structure~with~label~#1~has~already~been~used} +\msg_new:nnn { tagpdf } { struct-label-unknown} { structure~with~label~#1~is~unknown~rerun} + + +%Roles +\msg_new:nnn { tagpdf } { role-missing } { tag~#1~has~no~role~assigned } +\msg_new:nnn { tagpdf } { role-unknown } { role~#1~is~not~known } +\msg_new:nnn { tagpdf } { role-unknown-tag } { tag~#1~is~not~known } +\msg_new:nnn { tagpdf } { role-new-tag } { adding~new~tag~#1~mapped~to~role~#2 } + + +% trees +\msg_new:nnn { tagpdf } {tree-mcid-index-wrong } {something~is~wrong~with~the~mcid} + +% obj +\msg_new:nnn { tagpdf } {obj-write-num } {write~obj~#1~to~pdf} + + +%checks +%structures + +\cs_new:Nn \__uftag_check_structure_has_tag:n %#1 struct num + { + \prop_if_in:cnF { g__uftag_struct_#1_prop } + {S} + { + \msg_error:nn { tagpdf }{ struct-missing-tag } + } + } + +\cs_new:Nn \__uftag_check_info_closing_struct:n %#1 struct num + { + \msg_info:nnn {tagpdf}{struct-show-closing}{#1} + } + +\cs_generate_variant:Nn \__uftag_check_info_closing_struct:n {o,x} + +\cs_new:Nn \__uftag_check_no_open_struck: + { + \msg_error:nn {tagpdf}{ struct-faulty-nesting } + } + +\cs_new:Nn \__uftag_check_struct_used:n %#1 label + { + \prop_get:cnNT + {g__uftag_struct_\zref@extractdefault{tagpdfstruct-#1}{tagstruct}{unknown}_prop} + {P} + \l_tmpa_tl + {\msg_warning:nnn {tagpdf}{struct-used-twice}{#1}} + } + +%roles + +\cs_new:Nn \__uftag_check_add_tag_role:nn %#1 tag, #2 role + { + \tl_if_empty:nTF { #2 } + { + \msg_warning:nnn { tagpdf }{ role-missing } { #1 } + } + { + \prop_get:NnNF \g__uftag_role_tags_prop { #2 } \l_tmpa_tl + { + \msg_warning:nnn { tagpdf }{ role-unknown } { #2 } + } + { + \msg_info:nnnn { tagpdf }{ role-new-tag } { #1 }{ #2 } + } + } + } + +%mc +\cs_new:Nn \__uftag_check_mc_if_nested: + { + \_uftag_mc_if_in:T + { + \msg_warning:nnx {tagpdf}{mc-nested}{ \__uftag_get_mc_abs_cnt: } + } + } + +\cs_new:Nn \__uftag_check_mc_if_open: + { + \_uftag_mc_if_in:F + { + \msg_warning:nnx {tagpdf}{mc-not-open}{ \__uftag_get_mc_abs_cnt: } + } + } + +\cs_new:Nn \__uftag_check_mc_tag:N + { + \tl_if_empty:NT #1 + { + \msg_error:nnx {tagpdf}{mc-tag-missing}{ \__uftag_get_mc_abs_cnt: } + } + \prop_if_in:NoF \g__uftag_role_tags_prop { #1 } + { + \msg_warning:nnx {tagpdf}{role-unknown-tag} { #1 } + } + } + +\seq_new:N \g__uftag_check_mc_used_seq +\cs_new:Nn \__uftag_check_mc_used:n + { + \seq_if_in:NnTF \g__uftag_check_mc_used_seq { #1 } + { + \msg_warning:nnn {tagpdf}{mc-used-twice}{ #1 } + } + { + \seq_gput_right:Nx\g__uftag_check_mc_used_seq { #1 } + } + } + + + +\cs_new:Nn \__uftag_check_show_MCID_by_page: + { + \tl_set:Nx \l__uftag_tmpa_tl + { + \zref@extractdefault + {LastPage} {abspage} {-1} + } + \int_step_inline:nnnn {1}{1} + { + \l__uftag_tmpa_tl + } + { + \seq_clear:N \l_tmpa_seq + \int_step_inline:nnnn {1}{1} + { + \zref@extractdefault + {LastPage} {tagmcabs} {-1} + } + { + \int_compare:nT + { + \zref@extractdefault + {mcid-####1} {tagabspage} {-1} + = ##1 + } + { + \seq_gput_right:Nx \l_tmpa_seq + { + Page##1-####1-\zref@extractdefault + {mcid-####1} {tagmcid} {-1} + } + } + } + \seq_show:N \l_tmpa_seq + } + } + +\cs_new:Nn\__uftag_check_record_pdfobj_num:n + { + \int_compare:nT {\l__uftag_loglevel_int >= 3 } + { + \msg_info:nnx { tagpdf }{obj-write-num}{#1} + } + } + +\endinput |