From 9fc4fc7a3e0c2a085bf32447278e741e6667b206 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 23 Feb 2021 22:24:07 +0000 Subject: tagpdf (23feb21) git-svn-id: svn://tug.org/texlive/trunk@57857 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def | 273 +++++++-------------- 1 file changed, 89 insertions(+), 184 deletions(-) (limited to 'Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def') diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def index 5cb16c5216c..d1f772d4279 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def @@ -1,196 +1,101 @@ -\ProvidesExplFile {tagpdf-luatex.def} {2019/07/02} {0.61} +%% +%% This is file `tagpdf-luatex.def', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% tagpdf-backend.dtx (with options: `luatex') +%% +%% Copyright (C) 2019 Ulrike Fischer +%% +%% It may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License (LPPL), either version 1.3c of +%% this license or (at your option) any later version. The latest +%% version of this license is in the file: +%% +%% https://www.latex-project.org/lppl.txt +%% +%% This file is part of the "tagpdf bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% File: tagpdf-backend.dtx +\ProvidesExplFile {tagpdf-luatex.def} {2021/02/23} {0.80} {tagpdf~driver~for~luatex} -%\newattribute \g__uftag_mc_type_attr %the value represent the type -%\newattribute \g__uftag_mc_cnt_attr %will hold the \c@g__uftag_MCID_abs_int value +\newattribute \l__tag_mc_type_attr %the value represent the type +\newattribute \l__tag_mc_cnt_attr %will hold the \c@g__tag_MCID_abs_int value -\newattribute \l__uftag_mc_type_attr %the value represent the type -\newattribute \l__uftag_mc_cnt_attr %will hold the \c@g__uftag_MCID_abs_int value +\newattribute \g__tag_interwordspace_attr +\newattribute \g__tag_interwordfont_attr -\newattribute \g__uftag_interwordspace_attr -\newattribute \g__uftag_interwordfont_attr - -% The lua code -% ensure that 10pt font has been loaded: { - \fontencoding{TU}\fontfamily{lmr}\fontseries{m}\fontshape{n}\fontsize{10pt}{10pt}\selectfont + \fontencoding{TU}\fontfamily{lmr}\fontseries{m}\fontshape{n}\fontsize{10pt}{10pt}\selectfont } \directlua { tagpdf=require('tagpdf.lua') } %%%% driver (lualatex) commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% these should be in expl3!!! -\cs_new:Nn \__uftag_pdf_startlink:{ \pdfextension startlink } -\cs_new:Nn \__uftag_pdf_endlink: { \pdfextension endlink } -\cs_new_protected:Nn \__uftag_pdf_lastlink: { \numexpr\pdffeedback lastlink\relax } -\cs_new:Nn \__uftag_pdf_catalog: { \pdfextension catalog } - -% needed for \str_set_convert:Nnon -\tl_new:N \g__uftag_inputencoding_tl -\tl_gset:Nn \g__uftag_inputencoding_tl {} - - -% literals -\cs_new:Nn \__uftag_pdfliteral_page:n {\__uftag_tex_pdfextension:D literal~page {#1}} -\cs_new:Nn \__uftag_pdfcatalog:n {\__uftag_tex_pdfextension:D catalog {#1}} - -%reserve an object num -\cs_new:Nn \__uftag_pdfreserveobjnum:N - { - % #1 = macro name to be populated with object number - \__uftag_tex_pdfextension:D~obj~reserveobjnum - \tl_set:Nx #1 { \__uftag_tex_pdffeedback:D lastobj }% - } - -% use an object num -\cs_new:Nn \__uftag_pdfuseobjnum:Nn - { - % #1 = macro with object number to be populated - % #2 = object contents, as valid PDF - % should #2 be filtered through \pdfstringdef ??? - \__uftag_tex_immediate:D \__uftag_tex_pdfextension:D~obj~useobjnum~#1~{ #2 }% - } - -\cs_new:Nn \__uftag_pdfuseobjnum:nn - { - % #1 = a number - % #2 = object contents, as valid PDF - % should #2 be filtered through \pdfstringdef ??? - \__uftag_tex_immediate:D \__uftag_tex_pdfextension:D~obj~useobjnum~#1~{ #2 }% - } - -% obj num of the dictionary for a page: -% the page count starts by 1 -% pages can referenced before they are actually created -% no error if the page later doesn't exist - -\cs_new:Nn \__uftag_store_pdfpageref:Nn - { - % #1 = macro name to be populated with current page object number - % #2 = number or counter identifying the required page - \tl_set:Nx #1 { \__uftag_tex_pdffeedback:D pageref~#2 }% - } - -% a global version of the command -\cs_new:Nn \__uftag_gstore_pdfpageref:Nn - { - \tl_gset:Nx #1 { \__uftag_tex_pdffeedback:D pageref~#2 }% - } - -\cs_new:Nn \__uftag_pdfobj:Nn - { - % #1 = macro name to refer to this object - % #2 = object contents, as valid PDF - % should #2 be filtered through \pdfstringdef ??? - \__uftag_tex_immediate:D \__uftag_tex_pdfextension:D~obj~{ #2 } - \tl_set:Nx #1 { \__uftag_tex_pdffeedback:D~lastobj }% - } - -% pdfpage**s**attr: for all pages -%% is global needed? Yes. Without it the setting is lost if issued in a group -% -\cs_new:Nn \__uftag_gset_pdfpagesattr:n - { - \__uftag_tex_global:D \__uftag_tex_pdfvariable:D~pagesattr { #1 } - } - -\cs_new:Nn \__uftag_gadd_pdfpagesattr:n - { - \exp_args:No \__uftag_gset_pdfpagesattr:n { \__uftag_tex_the:D \__uftag_tex_pdfvariable:D~pagesattr #1} - } - -% pdfpageattr for one page -% do we need an immediate version?? -\cs_new:Nn \__uftag_gset_pdfpageattr:n - { - \__uftag_tex_global:D \__uftag_tex_pdfvariable:D~pageattr { #1 } - } - -\cs_new:Nn \__uftag_gadd_pdfpageattr:n - { - \exp_args:No \__uftag_gset_pdfpageattr:n { \__uftag_tex_the:D \__uftag_tex_pdfvariable:D~pageattr #1} - } - -\cs_new:Nn \__uftag_get_pdfpageattr:N - { - \tl_set:No #1 { \__uftag_tex_the:D \__uftag_tex_pdfvariable:D~pageattr } - } - - -% I probably want also lua tables -% I put them in the uftag.tables namespaces -% The tables will be named like the variables but without backslash -% To access such a table with a dynamical name create a string and then use -% uftag.tables[string] -% Old code, I'm not quite sure if this was a good idea. Now I have mix of table in -% utftag.tables and uftag.mc/struct. And a lot is probably not needed. - -\cs_new:Nn \__uftag_luatex_get_table_name:Nn - { - \tl_set_rescan:Nnn #1 { \char_set_catcode_ignore:N \\ } { #2 } - } - - -\cs_new:Nn \__uftag_prop_new:N - { - \prop_new:N #1 - \__uftag_luatex_get_table_name:Nn \l_tmpa_tl { #1 } - \directlua { uftag.tables.\l_tmpa_tl = {} } - } - - -\cs_new:Nn \__uftag_seq_new:N - { - \seq_new:N #1 - \__uftag_luatex_get_table_name:Nn \l_tmpa_tl { #1 } - \directlua { uftag.tables.\l_tmpa_tl = {} } - } - - -\cs_new:Nn \__uftag_prop_gput:Nnn - { - \prop_gput:Nnn #1 { #2 } { #3 } - \__uftag_luatex_get_table_name:Nn \l_tmpa_tl { #1 } - \directlua { uftag.tables.\l_tmpa_tl["#2"] = "#3" } - } - - -\cs_new:Nn \__uftag_seq_gput_right:Nn - { - \seq_gput_right:Nn #1 { #2 } - \__uftag_luatex_get_table_name:Nn \l_tmpa_tl { #1 } - \directlua { table.insert(uftag.tables.\l_tmpa_tl, "#2") } - } - -%Hm not quite sure about the naming - -\cs_new:Npn \__uftag_seq_item:cn #1 #2 - { - \directlua { tex.print(uftag.tables.#1[#2]) } - } - -\cs_new:Npn \__uftag_prop_item:cn #1 #2 - { - \directlua { tex.print(uftag.tables.#1["#2"]) } - } - -%for debugging commands that show both the seq/prop and the lua tables -\cs_new:Nn \__uftag_seq_show:N - { - \seq_show:N #1 - \__uftag_luatex_get_table_name:Nn \l_tmpa_tl { #1 } - \directlua { uftag.trace.log ("lua~sequence~array~\l_tmpa_tl",1) } - \directlua { uftag.trace.show_seq (uftag.tables.\l_tmpa_tl) } - } - -\cs_new:Nn \__uftag_prop_show:N - { - \prop_show:N #1 - \__uftag_luatex_get_table_name:Nn \l_tmpa_tl { #1 } - \directlua {uftag.trace.log ("lua~property~table~\l_tmpa_tl",1) } - \directlua {uftag.trace.show_prop (uftag.tables.\l_tmpa_tl) } - } - -\endinput +\cs_new:Nn \__tag_luatex_get_table_name:Nn + { + \tl_set_rescan:Nnn #1 { \char_set_catcode_ignore:N \\ } { #2 } + } + +\cs_new:Nn \__tag_prop_new:N + { + \prop_new:N #1 + \__tag_luatex_get_table_name:Nn \l_tmpa_tl { #1 } + \directlua { ltx.__tag.tables.\l_tmpa_tl = {} } + } + +\cs_new:Nn \__tag_seq_new:N + { + \seq_new:N #1 + \__tag_luatex_get_table_name:Nn \l_tmpa_tl { #1 } + \directlua { ltx.__tag.tables.\l_tmpa_tl = {} } + } + +\cs_new:Nn \__tag_prop_gput:Nnn + { + \prop_gput:Nnn #1 { #2 } { #3 } + \__tag_luatex_get_table_name:Nn \l_tmpa_tl { #1 } + \directlua { ltx.__tag.tables.\l_tmpa_tl["#2"] = "#3" } + } + +\cs_new:Nn \__tag_seq_gput_right:Nn + { + \seq_gput_right:Nn #1 { #2 } + \__tag_luatex_get_table_name:Nn \l_tmpa_tl { #1 } + \directlua { table.insert(ltx.__tag.tables.\l_tmpa_tl, "#2") } + } + + +\cs_new:Npn \__tag_seq_item:cn #1 #2 + { + \directlua { tex.print(ltx.__tag.tables.#1[#2]) } + } + +\cs_new:Npn \__tag_prop_item:cn #1 #2 + { + \directlua { tex.print(ltx.__tag.tables.#1["#2"]) } + } + +\cs_new:Nn \__tag_seq_show:N + { + \seq_show:N #1 + \__tag_luatex_get_table_name:Nn \l_tmpa_tl { #1 } + \directlua { ltx.__tag.trace.log ("lua~sequence~array~\l_tmpa_tl",1) } + \directlua { ltx.__tag.trace.show_seq (ltx.__tag.tables.\l_tmpa_tl) } + } + +\cs_new:Nn \__tag_prop_show:N + { + \prop_show:N #1 + \__tag_luatex_get_table_name:Nn \l_tmpa_tl { #1 } + \directlua {ltx.__tag.trace.log ("lua~property~table~\l_tmpa_tl",1) } + \directlua {ltx.__tag.trace.show_prop (ltx.__tag.tables.\l_tmpa_tl) } + } +%% +%% +%% End of file `tagpdf-luatex.def'. -- cgit v1.2.3