diff options
author | Karl Berry <karl@freefriends.org> | 2022-08-07 21:41:10 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-08-07 21:41:10 +0000 |
commit | bbb49faf7bc85d0ced66a0569a720854fb95c4f6 (patch) | |
tree | d2cc54ede15491b2aebe5f35f5b380a35dadda45 /Master/texmf-dist/source | |
parent | d59d5606e922a9c49072e4be7250eb81a4b919c5 (diff) |
tagpdf (7aug22)
git-svn-id: svn://tug.org/texlive/trunk@64070 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
12 files changed, 338 insertions, 85 deletions
diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx index 8e119517802..fe68e700887 100644 --- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx +++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-backend.dtx @@ -47,13 +47,13 @@ % }^^A % } % -% \date{Version 0.95, released 2022-05-29} +% \date{Version 0.96, released 2022-08-06} % \maketitle % \begin{implementation} % \begin{macrocode} %<@@=tag> %<*luatex> -\ProvidesExplFile {tagpdf-luatex.def} {2022-05-29} {0.95} +\ProvidesExplFile {tagpdf-luatex.def} {2022-08-06} {0.96} {tagpdf~driver~for~luatex} % \end{macrocode} % \section{Loading the lua} @@ -157,8 +157,8 @@ local ProvidesLuaModule = { name = "tagpdf", - version = "0.95", --TAGVERSION - date = "2022-05-29", --TAGDATE + version = "0.96", --TAGVERSION + date = "2022-08-06", --TAGDATE description = "tagpdf lua code", license = "The LATEX Project Public License 1.3c" } diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx index 120de5eb0f2..121e2216113 100644 --- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx +++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-checks.dtx @@ -48,7 +48,7 @@ % }^^A % } % -% \date{Version 0.95, released 2022-05-29} +% \date{Version 0.96, released 2022-08-06} % \maketitle % \begin{documentation} % \section{Commands} @@ -60,9 +60,10 @@ % \begin{syntax} % \cs{tag_get:n}\Arg{keyword} % \end{syntax} -% This is a generic command to retrieve data. Currently +% This is a generic command to retrieve data for the current structure or +% mc-chunk. Currently % the only sensible values for the argument \meta{keyword} -% are |mc_tag| and |struct_tag|. +% are |mc_tag| and |struct_tag| and |struct_num|. % \end{function} % % \section{Description of log messages} @@ -294,7 +295,7 @@ % \begin{macrocode} %<@@=tag> %<*header> -\ProvidesExplPackage {tagpdf-checks-code} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-checks-code} {2022-08-06} {0.96} {part of tagpdf - code related to checks, conditionals, debugging and messages} %</header> % \end{macrocode} @@ -355,7 +356,14 @@ } % \end{macrocode} % \end{macro} -% \subsection{Messages related to mc-chunks} +% \subsection{Messages related to structures} +% \begin{macro}{struct-unknown} +% if for example a parent key value points to structure that doesn't exist (yet) +% \begin{macrocode} +\msg_new:nnn { tag } {struct-unknown} + { structure~with~number~#1~doesn't~exist\\ #2 } +% \end{macrocode} +% \end{macro} % \begin{macro}{struct-no-objnum} % Should not happen \ldots % \begin{macrocode} @@ -463,7 +471,7 @@ % This retrieves some data. % This is a generic command to retrieve data. Currently % the only sensible values for the argument are |mc_tag|, |struct_tag| -% and |struct-num|. +% and |struct_num|. % \begin{macrocode} %<base>\cs_new:Npn \tag_get:n #1 { \use:c {@@_get_data_#1: } } % \end{macrocode} @@ -883,7 +891,7 @@ % \begin{macrocode} \msg_new:nnn { tag / debug } {struct-begin} { - Struct~begin~#1~with~options:~\tl_to_str:n{#2}~[\msg_line_context:] + Struct~\tag_get:n{struct_num}~begin~#1~with~options:~\tl_to_str:n{#2}~[\msg_line_context:] } \msg_new:nnn { tag / debug } {struct-end} { diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx index 003c2a2748c..7881210a409 100644 --- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx +++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-generic.dtx @@ -46,7 +46,7 @@ % }^^A % } % -% \date{Version 0.95, released 2022-05-29} +% \date{Version 0.96, released 2022-08-06} % \maketitle % \begin{documentation} % \end{documentation} @@ -55,11 +55,11 @@ % \begin{macrocode} %<@@=tag> %<*generic> -\ProvidesExplPackage {tagpdf-mc-code-generic} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-mc-code-generic} {2022-08-06} {0.96} {part of tagpdf - code related to marking chunks - generic mode} %</generic> %<*debug> -\ProvidesExplPackage {tagpdf-debug-generic} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-debug-generic} {2022-08-06} {0.96} {part of tagpdf - debugging code related to marking chunks - generic mode} %</debug> % \end{macrocode} @@ -353,7 +353,7 @@ % for boxes produced for columns in that environment. Other streams % may follow over time. % \begin{macrocode} -\cs_new:Npn\@@_add_missing_mcs:Nn #1 #2 { +\cs_new_protected:Npn\@@_add_missing_mcs:Nn #1 #2 { \vbadness \@M \vfuzz \c_max_dim \vbox_set_to_ht:Nnn #1 { \box_ht:N #1 } { @@ -752,7 +752,7 @@ % { % tag (mc-key), % raw (mc-key), -% alttext (mc-key), +% alt (mc-key), % actualtext (mc-key), % label (mc-key), % artifact (mc-key) @@ -770,7 +770,7 @@ { \tl_put_right:Nx \l_@@_mc_key_properties_tl { #1 } }, - alttext .code:n = % Alt property + alt .code:n = % Alt property { \str_set_convert:Noon \l_@@_tmpa_str @@ -780,6 +780,7 @@ \tl_put_right:Nn \l_@@_mc_key_properties_tl { /Alt~< } \tl_put_right:No \l_@@_mc_key_properties_tl { \l_@@_tmpa_str>~ } }, + alttext .meta:n = {alt=#1}, actualtext .code:n = % ActualText property { \str_set_convert:Noon diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx index 6d5e568e96b..e001a4837a8 100644 --- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx +++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-luacode.dtx @@ -46,7 +46,7 @@ % }^^A % } % -% \date{Version 0.95, released 2022-05-29} +% \date{Version 0.96, released 2022-08-06} % \maketitle % \begin{implementation} % The code is splitted into three parts: code shared by all engines, @@ -86,7 +86,7 @@ % \begin{macrocode} %<@@=tag> %<*luamode> -\ProvidesExplPackage {tagpdf-mc-code-lua} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-mc-code-lua} {2022-08-06} {0.96} {tagpdf - mc code only for the luamode } %</luamode> % \end{macrocode} @@ -355,7 +355,7 @@ % { % tag (mc-key), % raw (mc-key), -% alttext (mc-key), +% alt (mc-key), % actualtext (mc-key), % label (mc-key), % artifact (mc-key) @@ -381,7 +381,7 @@ ltx.@@.func.store_mc_data(\@@_get_mc_abs_cnt:,"raw","#1") } }, - alttext .code:n = % Alt property + alt .code:n = % Alt property { \str_set_convert:Noon \l_@@_tmpa_str @@ -398,6 +398,7 @@ ) } }, + alttext .meta:n = {alt=#1}, actualtext .code:n = % Alt property { \str_set_convert:Noon diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx index 3ac4696ad02..0c6857c22a9 100644 --- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx +++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-mc-shared.dtx @@ -46,7 +46,7 @@ % }^^A % } % -% \date{Version 0.95, released 2022-05-29} +% \date{Version 0.96, released 2022-08-06} % \maketitle % \begin{documentation} % \section{Public Commands} @@ -101,7 +101,7 @@ % If there is no open chunk, it puts $-1$ on the stack (for debugging) % \cs{tag_mc_begin_pop:n} removes a value from the stack. If it is different from % $-1$ it opens a tag with it. -% The reopened mc chunk looses info like the alttext for now. +% The reopened mc chunk looses info like the alt text for now. % \end{function} % % \begin{function}[pTF, EXP]{\tag_mc_if_in:} @@ -141,7 +141,7 @@ % \verb+raw=/Alt (Hello)+ will insert an alternative Text. % \end{function} % -% \begin{function}{alttext (mc-key)} +% \begin{function}{alt (mc-key)} % This key inserts an \texttt{/Alt} value in the property dictionary of the BDC operator. % The value is handled as verbatim string, commands are not expanded. % The value will be expanded first once. @@ -174,7 +174,7 @@ % \begin{macrocode} %<@@=tag> %<*header> -\ProvidesExplPackage {tagpdf-mc-code-shared} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-mc-code-shared} {2022-08-06} {0.96} {part of tagpdf - code related to marking chunks - code shared by generic and luamode } %</header> diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx index 40122ccfb89..15c389e6764 100644 --- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx +++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-roles.dtx @@ -46,7 +46,7 @@ % }^^A % } % -% \date{Version 0.95, released 2022-05-29} +% \date{Version 0.96, released 2022-08-06} % \maketitle % \begin{documentation} % \begin{function} @@ -87,7 +87,7 @@ % \begin{macrocode} %<@@=tag> %<*header> -\ProvidesExplPackage {tagpdf-roles-code} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-roles-code} {2022-08-06} {0.96} {part of tagpdf - code related to roles and structure names} %</header> % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx index 7b6a75d8ead..8da502c7091 100644 --- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx +++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-space.dtx @@ -46,7 +46,7 @@ % }^^A % } % -% \date{Version 0.95, released 2022-05-29} +% \date{Version 0.96, released 2022-08-06} % \maketitle % \begin{documentation} % \begin{function}{interwordspace (setup-key)} @@ -64,7 +64,7 @@ % \begin{macrocode} %<@@=tag> %<*header> -\ProvidesExplPackage {tagpdf-space-code} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-space-code} {2022-08-06} {0.96} {part of tagpdf - code related to real space chars} %</header> % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx index 103e337e9d5..a476e3cf865 100644 --- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx +++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-struct.dtx @@ -46,7 +46,7 @@ % }^^A % } % -% \date{Version 0.95, released 2022-05-29} +% \date{Version 0.96, released 2022-08-06} % \maketitle % \begin{documentation} % \section{Public Commands} @@ -67,6 +67,18 @@ % A structure should be used only once, % if the structure already has a parent a warning is issued. % \end{function} +% \begin{function}{\tag_struct_object_ref:n,\tag_struct_object_ref:e} +% \begin{syntax} +% \cs{tag_struct_object_ref:n}\Arg{struct number} +% \end{syntax} +% This is a small wrapper around |\pdf_object_ref:n| to retrieve the +% object reference of the structure with the number \meta{struct number}. +% This number can be retrieved and stored for the current structure +% for example with \cs{tag_get:n}\Arg{struct_num}. Be aware that it can only +% be used if the structure has already been created and that it doesn't check +% if the object actually exists! +% \end{function} +% % The following two functions are used to add annotations. They must be used % together and with care to get the same numbers. Perhaps some improvements are needed % here. @@ -109,8 +121,21 @@ % \end{function} % \begin{function}{label (struct-key)} % This key sets a label by which -% one can use the structure later in another structure. -% Internally the label name will start with \texttt{tagpdfstruct-}. +% one can refer to the structure. It is e.g. +% used by \cs{tag_struct_use:n} (where a real label is actually not +% needed as you can only use structures already defined), and by the +% |ref| key (which can refer to future structures). +% Internally the label name will start with \texttt{tagpdfstruct-} and it stores +% the two attributs |tagstruct| (the structure number) and |tagstructobj| (the +% object reference). +% \end{function} +% \begin{function}{parent (struct-key)} +% By default a structure is added as kid to the currently active structure. +% With the parent key one can choose another parent. The value is a structure number which +% must refer to an already existing, previously created structure. Such a structure +% number can for example be have been stored with \cs{tag_get:n}, but one can also use +% a label on the parent structure and then use +% \cs{ref_value:nn}|{tagpdfstruct-label}{tagstruct}| to retrieve it. % \end{function} % \begin{function}{title (struct-key),title-o (struct-key)} % This keys allows to set the dictionary entry @@ -119,7 +144,7 @@ % Commands are not expanded. |title-o| will expand the value once. % \end{function} % -% \begin{function}{alttext (struct-key)} +% \begin{function}{alt (struct-key)} % This key inserts an \texttt{/Alt} value in the dictionary of structure object. % The value is handled as verbatim string and hex encoded. % The value will be expanded first once. @@ -217,7 +242,7 @@ % \begin{macrocode} %<@@=tag> %<*header> -\ProvidesExplPackage {tagpdf-struct-code} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-struct-code} {2022-08-06} {0.96} {part of tagpdf - code related to storing structure} %</header> % \end{macrocode} @@ -274,10 +299,14 @@ % \end{variable} % % \begin{variable}{\g_@@_struct_stack_current_tl,\l_@@_struct_stack_parent_tmpa_tl} -% The global variable will hold the current structure number. +% The global variable will hold the current structure number. It is already +% defined in \texttt{tagpdf-base}. % The local temporary variable will hold the parent when we fetch it from the stack. % \begin{macrocode} -\tl_new:N \g_@@_struct_stack_current_tl +%</package> +%<base>\tl_new:N \g_@@_struct_stack_current_tl +%<base>\tl_gset:Nn \g_@@_struct_stack_current_tl {\int_use:N\c@g_@@_struct_abs_int} +%<*package> \tl_new:N \l_@@_struct_stack_parent_tmpa_tl % \end{macrocode} % \end{variable} @@ -617,6 +646,7 @@ % \end{macrocode} % \end{macro} +% \subsection{Output of the object} % \begin{macro}{\@@_struct_get_dict_content:nN} % This maps the dictionary content of a structure into a tl-var. % Basically it does what |\pdfdict_use:n| does. @@ -639,13 +669,32 @@ { g_@@_struct_#1_prop } { ##1 } { - \c_space_tl/##1~\prop_item:cn{ g_@@_struct_#1_prop } { ##1 } + \c_space_tl/##1~ +% \end{macrocode} +% Some keys needs the option to format the key, e.g. add brackets for an +% array +% \begin{macrocode} + \cs_if_exist_use:cTF {@@_struct_format_##1:e} + { + { \prop_item:cn{ g_@@_struct_#1_prop } { ##1 } } + } + { + \prop_item:cn{ g_@@_struct_#1_prop } { ##1 } + } } } } } % \end{macrocode} % \end{macro} +% \begin{macro}{\@@_struct_format_Ref:n} +% Ref is an array, we store only the content to be able to extend it +% so the formatting command adds the brackets: +% \begin{macrocode} +\cs_new:Nn\__tag_struct_format_Ref:n{[#1]} +\cs_generate_variant:Nn\__tag_struct_format_Ref:n{e} +% \end{macrocode} +% \end{macro} % \begin{macro}{\@@_struct_write_obj:n} % This writes out the structure object. % This is done in the finish code, in the tree module and @@ -658,7 +707,7 @@ \@@_struct_fill_kid_key:n { #1 } \@@_struct_get_dict_content:nN { #1 } \l_@@_tmpa_tl \exp_args:Nx - \pdf_object_write:nx + \pdf_object_write_dict:nx { @@/struct/#1 } { \l_@@_tmpa_tl @@ -744,7 +793,7 @@ \exp_args:Ne \tl_tail:n { - \prop_item:cn {g_@@_struct_\g__tag_struct_stack_current_tl _prop}{S} + \prop_item:cn {g_@@_struct_\g_@@_struct_stack_current_tl _prop}{S} } } %</package> @@ -758,7 +807,7 @@ %<*base> \cs_new:Npn \@@_get_data_struct_num: { - \int_use:N\c@g_@@_struct_abs_int + \g_@@_struct_stack_current_tl } %</base> % \end{macrocode} @@ -772,10 +821,11 @@ % { % label (struct-key), % stash (struct-key), +% parent (struct-key), % tag (struct-key), % title (struct-key), % title-o (struct-key), -% alttext (struct-key), +% alt (struct-key), % actualtext (struct-key), % lang (struct-key), % ref (struct-key), @@ -787,9 +837,26 @@ { label .tl_set:N = \l_@@_struct_key_label_tl, stash .bool_set:N = \l_@@_struct_elem_stash_bool, + parent .code:n = + { + \bool_lazy_and:nnTF + { + \prop_if_exist_p:c { g_@@_struct_\int_eval:n {#1}_prop } + } + { + \int_compare_p:nNn {#1}<{\c@g_@@_struct_abs_int} + } + { \tl_set:Nx \l_@@_struct_stack_parent_tmpa_tl { \int_eval:n {#1} } } + { + \msg_warning:nnxx { tag } { struct-unknown } + { \int_eval:n {#1} } + { parent~key~ignored } + } + }, + parent .default:n = {-1}, tag .code:n = % S property { - \seq_set_split:Nne \l_@@_tmpa_seq { / } {#1/\prop_item:Nn\g__tag_role_tags_NS_prop{#1}} + \seq_set_split:Nne \l_@@_tmpa_seq { / } {#1/\prop_item:No\g__tag_role_tags_NS_prop{#1}} \tl_gset:Nx \g_@@_struct_tag_tl { \seq_item:Nn\l_@@_tmpa_seq {1} } \tl_gset:Nx \g_@@_struct_tag_NS_tl { \seq_item:Nn\l_@@_tmpa_seq {2} } \@@_check_structure_tag:N \g_@@_struct_tag_tl @@ -829,7 +896,7 @@ { T } { <\l_@@_tmpa_str> } }, - alttext .code:n = % Alt property + alt .code:n = % Alt property { \str_set_convert:Noon \l_@@_tmpa_str @@ -841,6 +908,7 @@ { Alt } { <\l_@@_tmpa_str> } }, + alttext .meta:n = {alt=#1}, actualtext .code:n = % ActualText property { \str_set_convert:Noon @@ -860,18 +928,18 @@ { Lang } { (#1) } }, - ref .code:n = % Lang property +% \end{macrocode} +% Ref is an array, the brackets are added through the formatting command. +% \begin{macrocode} + ref .code:n = % ref property { \tl_clear:N\l_@@_tmpa_tl - \clist_map_inline:nn {#1} + \clist_map_inline:on {#1} { \tl_put_right:Nx \l_@@_tmpa_tl {~\ref_value:nn{tagpdfstruct-##1}{tagstructobj} } } - \@@_prop_gput:cnx - { g_@@_struct_\int_eval:n {\c@g_@@_struct_abs_int}_prop } - { Ref } - { [\l_@@_tmpa_tl] } + \@@_struct_gput_data_ref:ee { \int_eval:n {\c@g_@@_struct_abs_int} } {\l_@@_tmpa_tl} }, E .code:n = % E property { @@ -1044,6 +1112,7 @@ { g_@@_struct_\int_eval:n { \c@g_@@_struct_abs_int }_prop } { Type } { /StructElem } + \tl_set:Nn \l_@@_struct_stack_parent_tmpa_tl {-1} \keys_set:nn { @@ / struct} { #1 } \@@_check_structure_has_tag:n { \int_eval:n {\c@g_@@_struct_abs_int} } \tl_if_empty:NF @@ -1051,13 +1120,19 @@ { \@@_ref_label:en{tagpdfstruct-\l_@@_struct_key_label_tl}{struct} } - %get the potential parent from the stack: - \seq_get:NNF - \g_@@_struct_stack_seq - \l_@@_struct_stack_parent_tmpa_tl +% \end{macrocode} +% The structure number of the parent is either taken from the stack or +% has been set with the parent key. +% \begin{macrocode} + \int_compare:nNnT { \l_@@_struct_stack_parent_tmpa_tl } = { -1 } { - \msg_error:nn { tag } { struct-faulty-nesting } - } + \seq_get:NNF + \g_@@_struct_stack_seq + \l_@@_struct_stack_parent_tmpa_tl + { + \msg_error:nn { tag } { struct-faulty-nesting } + } + } \seq_gpush:NV \g_@@_struct_stack_seq \c@g_@@_struct_abs_int \seq_gpush:NV \g_@@_struct_tag_stack_seq \g_@@_struct_tag_tl \tl_gset:NV \g_@@_struct_stack_current_tl \c@g_@@_struct_abs_int @@ -1151,9 +1226,61 @@ } } } +%</package> +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[EXP]{\tag_struct_object_ref:n} +% This is a command that allows to reference a structure. The argument is the +% number which can be get for the current structure with |\tag_get:n{struct_num}| +% TODO check if it should be in base too. +% \begin{macrocode} +%<*package> +\cs_new:Npn \tag_struct_object_ref:n #1 + { + \pdf_object_ref:n {@@/struct/#1} + } +\cs_generate_variant:Nn \tag_struct_object_ref:n {e} % \end{macrocode} +% % \end{macro} % +% \begin{macro}{\tag_struct_gput:nnn} +% This is a command that allows to update the data of a structure. +% The first argument is the +% number of the structure, the second a keyword referring to a function, +% the third the value. Currently the only keyword is \texttt{ref} +% \begin{macrocode} +\cs_new_protected:Npn \tag_struct_gput:nnn #1 #2 #3 + { + \cs_if_exist_use:cF {@@_struct_gput_data_#2:nn} + { %warning?? + \use_none:nn + } + {#1}{#3} + } +\cs_generate_variant:Nn \tag_struct_gput:nnn {ene,nne} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_struct_gput_data_ref:nn} +% \begin{macrocode} +\cs_new_protected:Npn \@@_struct_gput_data_ref:nn #1 #2 + % #1 receiving struct num, #2 list of object ref + { + \prop_get:cnN + { g_@@_struct_#1_prop } + {Ref} + \l_@@_tmpb_tl + \@@_prop_gput:cnx + { g_@@_struct_#1_prop } + { Ref } + { \quark_if_no_value:NF\l_@@_tmpb_tl { \l_@@_tmpb_tl\c_space_tl }#2 } + } +\cs_generate_variant:Nn \@@_struct_gput_data_ref:nn {ee} +% \end{macrocode} +% \end{macro} + % \begin{macro} % { % \tag_struct_insert_annot:nn, @@ -1192,7 +1319,7 @@ % \section{Attributes and attribute classes} % \begin{macrocode} %<*header> -\ProvidesExplPackage {tagpdf-attr-code} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-attr-code} {2022-08-06} {0.96} {part of tagpdf - code related to attributes and attribute classes} %</header> % \end{macrocode} diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx index a8ea5b9b001..26124a3afd6 100644 --- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx +++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-tree.dtx @@ -47,13 +47,13 @@ % }^^A % } % -% \date{Version 0.95, released 2022-05-29} +% \date{Version 0.96, released 2022-08-06} % \maketitle % \begin{implementation} % \begin{macrocode} %<@@=tag> %<*header> -\ProvidesExplPackage {tagpdf-tree-code} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-tree-code} {2022-08-06} {0.96} {part of tagpdf - code related to writing trees and dictionaries to the pdf} %</header> % \end{macrocode} @@ -285,7 +285,7 @@ \@@_tree_fill_parenttree: } \tl_put_right:NV \l_@@_parenttree_content_tl\g_@@_parenttree_objr_tl - \pdf_object_write:nx { @@/tree/parenttree } + \pdf_object_write_dict:nx { @@/tree/parenttree } { /Nums\c_space_tl [\l_@@_parenttree_content_tl] } @@ -310,7 +310,7 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_tree_write_rolemap: { - \pdf_object_write:nx { @@/tree/rolemap } + \pdf_object_write_dict:nx { @@/tree/rolemap } { \pdfdict_use:n{g_@@_role/RoleMap_dict} } @@ -346,7 +346,7 @@ \l_@@_tmpa_tl { \pdf_object_new:nn { @@/tree/classmap }{ dict } - \pdf_object_write:nx + \pdf_object_write_dict:nx { @@/tree/classmap } { \l_@@_tmpa_tl } \@@_prop_gput:cnx @@ -373,19 +373,19 @@ { \pdfdict_if_empty:nF {g_@@_role/RoleMapNS_##1_dict} { - \pdf_object_write:nx {@@/RoleMapNS/##1} + \pdf_object_write_dict:nx {@@/RoleMapNS/##1} { \pdfdict_use:n {g_@@_role/RoleMapNS_##1_dict} } \pdfdict_gput:nnx{g_@@_role/Namespace_##1_dict} {RoleMapNS}{\pdf_object_ref:n {@@/RoleMapNS/##1}} } - \pdf_object_write:nx{tag/NS/##1} + \pdf_object_write_dict:nx{tag/NS/##1} { \pdfdict_use:n {g_@@_role/Namespace_##1_dict} } } - \pdf_object_write:nx {@@/tree/namespaces} + \pdf_object_write:nx {@@/tree/namespaces} %array { \prop_map_tokens:Nn \g_@@_role_NS_prop{\use_ii:nn} } diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx index 30f5abc3b4d..607e949eed2 100644 --- a/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx +++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf-user.dtx @@ -46,7 +46,7 @@ % }^^A % } % -% \date{Version 0.95, released 2022-05-29} +% \date{Version 0.96, released 2022-08-06} % \maketitle % \begin{documentation} % \section{Setup commands} @@ -246,18 +246,20 @@ % \begin{macrocode} %<@@=tag> %<*header> -\ProvidesExplPackage {tagpdf-user} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-user} {2022-08-06} {0.96} {tagpdf - user commands} %</header> % \end{macrocode} % \section{Setup and preamble commands} % \begin{macro}{\tagpdfsetup} % \begin{macrocode} +%<base>\NewDocumentCommand \tagpdfsetup { m }{} %<*package> -\NewDocumentCommand \tagpdfsetup { m } +\RenewDocumentCommand \tagpdfsetup { m } { \keys_set:nn { @@ / setup } { #1 } } +%</package> % \end{macrocode} % \end{macro} % @@ -265,15 +267,15 @@ % \section{Commands for the mc-chunks} % \begin{macro}{\tagmcbegin,\tagmcend,\tagmcuse } % \begin{macrocode} +%<*base> \NewDocumentCommand \tagmcbegin { m } { - \tag_mc_begin:n {#1}%\ignorespaces + \tag_mc_begin:n {#1} } \NewDocumentCommand \tagmcend { } { - %\if_mode_horizontal: \unskip \fi: % \tag_mc_end: } @@ -281,7 +283,7 @@ { \tag_mc_use:n {#1} } - +%</base> % \end{macrocode} % \end{macro} @@ -290,10 +292,12 @@ % importance for pdflatex as lualatex doesn't mind much if a mc tag is not % correctly closed. Unlike the expl3 command it is not expandable. % \begin{macrocode} +%<*package> \NewDocumentCommand \tagmcifinTF { m m } { \tag_mc_if_in:TF { #1 } { #2 } } +%</package> % \end{macrocode} % \end{macro} % @@ -303,6 +307,7 @@ % These are structure related user commands. There are direct wrapper around the % expl3 variants. % \begin{macrocode} +%<*base> \NewDocumentCommand \tagstructbegin { m } { \tag_struct_begin:n {#1} @@ -317,6 +322,7 @@ { \tag_struct_use:n {#1} } +%</base> % \end{macrocode} % \end{macro} % @@ -327,6 +333,7 @@ % This is a generic command for various show commands. % It takes a keyval list, the various keys are implemented below. % \begin{macrocode} +%<*package> \NewDocumentCommand\ShowTagging { m } { \keys_set:nn { @@ / show }{ #1} @@ -559,6 +566,8 @@ \bool_new:N \l_@@_para_show_bool \int_new:N \g_@@_para_begin_int \int_new:N \g_@@_para_end_int +\tl_new:N \l_@@_para_tag_tl +\tl_set:Nn \l_@@_para_tag_tl { P } % \end{macrocode} % \end{macro} % @@ -576,6 +585,7 @@ { paratagging .bool_set:N = \l_@@_para_bool, paratagging-show .bool_set:N = \l_@@_para_show_bool, + paratag .tl_set:N = \l_@@_para_tag_tl } % \end{macrocode} @@ -587,13 +597,13 @@ \bool_if:NT \l_@@_para_bool { \int_gincr:N \g_@@_para_begin_int - \tag_struct_begin:n {tag=P} + \tag_struct_begin:n {tag=\l_@@_para_tag_tl} \bool_if:NT \l_@@_para_show_bool { \tag_mc_begin:n{artifact} \llap{\color_select:n{red}\tiny\int_use:N\g_@@_para_begin_int\ } \tag_mc_end: } - \tag_mc_begin:n {tag=P} + \tag_mc_begin:n {tag=\l_@@_para_tag_tl} } } \AddToHook{para/end} @@ -649,6 +659,7 @@ } } } +%</package> % \end{macrocode} % \begin{macro} % { @@ -658,8 +669,11 @@ % This two command switch para mode on and off. |\tagpdfsetup| could be used % too but is longer. % \begin{macrocode} -\newcommand\tagpdfparaOn {\bool_set_true:N \l_@@_para_bool} -\newcommand\tagpdfparaOff{\bool_set_false:N \l_@@_para_bool} +%<base>\newcommand\tagpdfparaOn {} +%<base>\newcommand\tagpdfparaOff{} +%<*package> +\renewcommand\tagpdfparaOn {\bool_set_true:N \l_@@_para_bool} +\renewcommand\tagpdfparaOff{\bool_set_false:N \l_@@_para_bool} % \end{macrocode} % \end{macro} % diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx b/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx index 32b41001635..51d67e2ae9f 100644 --- a/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx +++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf.dtx @@ -33,12 +33,23 @@ % \end{syntax} % \end{function} % -% \begin{function}{ \tag_stop_group_begin:, \tag_stop_group_end:, \tag_stop: } -% We need a command to stop tagging in some places. -% This simply switches the two local booleans. The grouping commands +% \begin{function}{ \tag_stop_group_begin:, \tag_stop_group_end:, +% \tag_stop:, \tag_start:, \tag_stop:n, \tag_start:n } +% We need commands to stop tagging in some places. +% There simply switches the two local booleans. The grouping commands % can be used to group the effect. % \end{function} % +% \begin{function}{\tag_stop:n, \tag_start:n }% +% \begin{syntax} +% \cs{tag_stop:n}\Arg{label} +% \cs{tag_start:n}\Arg{label}\\ +% \end{syntax} +% This commands are intended as a pair. The start command +% will only restart tagging if the previous stop command +% with the same label actually stopped tagging. +% \end{function} +% % \begin{function}{activate-space (setup-key)} % |activate-space| activates the additional parsing needed for % interword spaces. It is not documented, the parsing is currently @@ -81,7 +92,7 @@ % \begin{macrocode} %<@@=tag> %<*package> -\ProvidesExplPackage {tagpdf} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf} {2022-08-06} {0.96} { A package to experiment with pdf tagging } \bool_if:nF @@ -107,10 +118,10 @@ % \end{macrocode} %<*debug> % \begin{macrocode} -\ProvidesExplPackage {tagpdf-debug} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-debug} {2022-08-06} {0.96} { debug code for tagpdf } \@ifpackageloaded{tagpdf}{}{\PackageWarning{tagpdf-debug}{tagpdf~not~loaded,~quitting}\endinput} - \end{macrocode} +% \end{macrocode} %</debug> % We map the internal module name \enquote{tag} to \enquote{tagpdf} in messages. % \begin{macrocode} @@ -148,7 +159,7 @@ % \end{macrocode} % \begin{macrocode} %<*base> -\ProvidesExplPackage {tagpdf-base} {2022-05-29} {0.95} +\ProvidesExplPackage {tagpdf-base} {2022-08-06} {0.96} {part of tagpdf - provide base, no-op versions of the user commands } %</base> % \end{macrocode} @@ -171,6 +182,50 @@ % \end{macrocode} % \section{Temporary code} % This is code which will be removed when proper support exists in LaTeX +% \subsection{Faster object writing} +% +% \begin{macrocode} +%<*package> +\cs_if_free:NT \pdf_object_write_dict:nn + { + \cs_set_eq:NN \pdf_object_write_dict:nn \pdf_object_write:nn + } +\cs_generate_variant:Nn \pdf_object_write_dict:nn {nx} + +\str_if_eq:VnT \c_sys_backend_str {pdftex} + { + \cs_if_free:NT \__pdf_backend_object_write_dict:nn + { + \cs_new_protected:Npn \__pdf_backend_object_write_dict:nn #1#2 + { + \tex_immediate:D \tex_pdfobj:D + useobjnum ~ + \int_use:c + { c__pdf_backend_object_ \tl_to_str:n {#1} _int } + { << ~ \exp_not:n {#2} ~ >> } + } + \cs_set_eq:NN \pdf_object_write_dict:nn \__pdf_backend_object_write_dict:nn + } + } + +\str_if_eq:VnT \c_sys_backend_str {luatex} + { + \cs_if_free:NT \__pdf_backend_object_write_dict:nn + { + \cs_new_protected:Npn \__pdf_backend_object_write_dict:nn #1#2 + { + \tex_immediate:D \tex_pdfextension:D obj ~ + useobjnum ~ + \int_use:c + { c__pdf_backend_object_ \tl_to_str:n {#1} _int } + { << ~ \exp_not:n {#2} ~ >> } + } + \cs_set_eq:NN \pdf_object_write_dict:nn \__pdf_backend_object_write_dict:nn + } + } +%</package> +% \end{macrocode} + % \subsection{a LastPage label} % See also issue \#2 in Accessible-xref % \begin{macro}{\@@_lastpagelabel:} @@ -225,6 +280,7 @@ % \begin{variable} % { % \l_@@_tmpa_tl, +% \l_@@_tmpb_tl % \l_@@_tmpa_str, % \l_@@_tmpa_prop, % \l_@@_tmpa_seq, @@ -237,6 +293,7 @@ % A few temporary variables % \begin{macrocode} \tl_new:N \l_@@_tmpa_tl +\tl_new:N \l_@@_tmpb_tl \str_new:N \l_@@_tmpa_str \prop_new:N \l_@@_tmpa_prop \seq_new:N \l_@@_tmpa_seq @@ -333,9 +390,11 @@ \cs_generate_variant:Nn \pdffile_embed_stream:nnn {nxx,oxx} \cs_generate_variant:Nn \prop_gput:Nnn {Nxx,Nen} \cs_generate_variant:Nn \prop_put:Nnn {Nxx} +\cs_generate_variant:Nn \prop_item:Nn {No} \cs_generate_variant:Nn \ref_label:nn { nv } \cs_generate_variant:Nn \seq_set_split:Nnn{Nne} \cs_generate_variant:Nn \str_set_convert:Nnnn {Nonn, Noon, Nnon } +\cs_generate_variant:Nn \clist_map_inline:nn {on} % \end{macrocode} % \section{Setup label attributes} @@ -444,10 +503,16 @@ % \end{macro} % % \section{General tagging commands} - -% \begin{macro}{ \tag_stop_group_begin:, \tag_stop_group_end: } -% We need a command to stop tagging in some places. +% +% \begin{macro}{\tag_stop_group_begin:, +% \tag_stop_group_end:, +% \tag_stop:,\tag_start:, +% \tag_stop:n,\tag_start:n} +% We need commands to stop tagging in some places. % This simply switches the two local booleans. +% In some cases tagging should only restart, if +% it actually was stopped before. For this it is possible +% to label a stop. % \begin{macrocode} \cs_new_protected:Npn \tag_stop_group_begin: { @@ -456,14 +521,49 @@ \bool_set_false:N \l_@@_active_mc_bool } \cs_set_eq:NN \tag_stop_group_end: \group_end: -\cs_new_protected:Npn \tag_stop: +\cs_set_protected:Npn \tag_stop: { \bool_set_false:N \l_@@_active_struct_bool \bool_set_false:N \l_@@_active_mc_bool } +\cs_set_protected:Npn \tag_start: + { + \bool_set_true:N \l_@@_active_struct_bool + \bool_set_true:N \l_@@_active_mc_bool + } +\prop_new:N\g_@@_state_prop +\cs_set_protected:Npn \tag_stop:n #1 + { + \tag_if_active:TF + { + \bool_set_false:N \l_@@_active_struct_bool + \bool_set_false:N \l_@@_active_mc_bool + \prop_gput:Nnn \g_@@_state_prop { #1 }{ 1 } + } + { + \prop_gremove:Nn \g_@@_state_prop { #1 } + } + } +\cs_set_protected:Npn \tag_start:n #1 + { + \prop_gpop:NnN \g_@@_state_prop {#1}\l_@@_tmpa_tl + \quark_if_no_value:NF \l_@@_tmpa_tl + { + \bool_set_true:N \l_@@_active_struct_bool + \bool_set_true:N \l_@@_active_mc_bool + } + } +%</package> +%<*base> +\cs_new_protected:Npn \tag_stop:{} +\cs_new_protected:Npn \tag_start:{} +\cs_new_protected:Npn \tag_stop:n{} +\cs_new_protected:Npn \tag_start:n{} +%</base> % \end{macrocode} % \end{macro} % +% % \section{Keys for tagpdfsetup} % TODO: the log-levels must be sorted @@ -484,6 +584,7 @@ % perhaps move to some other place, now that it is better separated. % |no-struct-dest| allows to suppress structure destinations. % \begin{macrocode} +%<*package> \keys_define:nn { @@ / setup } { activate-space .bool_gset:N = \g_@@_active_space_bool, diff --git a/Master/texmf-dist/source/latex/tagpdf/tagpdf.ins b/Master/texmf-dist/source/latex/tagpdf/tagpdf.ins index 54809f67c10..60c0803cbf2 100644 --- a/Master/texmf-dist/source/latex/tagpdf/tagpdf.ins +++ b/Master/texmf-dist/source/latex/tagpdf/tagpdf.ins @@ -77,6 +77,7 @@ and all files in that bundle must be distributed together. \from{tagpdf-mc-shared.dtx}{base} \from{tagpdf-struct.dtx}{base} \from{tagpdf-checks.dtx}{base} + \from{tagpdf-user.dtx}{base} } } |