summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/tagpdf.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-10-28 03:01:16 +0000
committerNorbert Preining <norbert@preining.info>2023-10-28 03:01:16 +0000
commit27f547140ee908fb4ce9e4b8297af7d5bf8d7ff9 (patch)
treee369cbac6d7ab890e1139cd73f5034e45af74b8b /macros/latex/contrib/tagpdf/tagpdf.dtx
parente7c703c953f148411c70d5ca86dc1c1023d73806 (diff)
CTAN sync 202310280301
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdf.dtx')
-rw-r--r--macros/latex/contrib/tagpdf/tagpdf.dtx258
1 files changed, 157 insertions, 101 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdf.dtx b/macros/latex/contrib/tagpdf/tagpdf.dtx
index be94a64070..668d085169 100644
--- a/macros/latex/contrib/tagpdf/tagpdf.dtx
+++ b/macros/latex/contrib/tagpdf/tagpdf.dtx
@@ -25,9 +25,9 @@
% \fi
% \begin{documentation}
% \begin{function}{\ref_value:nnn}
-% This is a temporary definition which will have to
-% move to l3ref. It allows to locally set a default value if the label or the attribute
-% doesn't exist. See issue \#4 in Accessible-xref.
+% This is a temporary definition which will be removed once properties have been
+% released. It allows to locally set a default value if the label or the attribute
+% doesn't exist.
% \begin{syntax}
% \cs{ref_value:nnn}\Arg{label}\Arg{attribute}\Arg{fallback default}
% \end{syntax}
@@ -93,7 +93,7 @@
% \begin{macrocode}
%<@@=tag>
%<*package>
-\ProvidesExplPackage {tagpdf} {2023-08-30} {0.98l}
+\ProvidesExplPackage {tagpdf} {2023-10-27} {0.98m}
{ A package to experiment with pdf tagging }
\bool_if:nF
@@ -119,7 +119,7 @@
% \end{macrocode}
%<*debug>
% \begin{macrocode}
-\ProvidesExplPackage {tagpdf-debug} {2023-08-30} {0.98l}
+\ProvidesExplPackage {tagpdf-debug} {2023-10-27} {0.98m}
{ debug code for tagpdf }
\@ifpackageloaded{tagpdf}{}{\PackageWarning{tagpdf-debug}{tagpdf~not~loaded,~quitting}\endinput}
% \end{macrocode}
@@ -142,7 +142,7 @@
% we define a base package with dummy functions
% \begin{macrocode}
%<*base>
-\ProvidesExplPackage {tagpdf-base} {2023-08-30} {0.98l}
+\ProvidesExplPackage {tagpdf-base} {2023-10-27} {0.98m}
{part of tagpdf - provide base, no-op versions of the user commands }
%</base>
% \end{macrocode}
@@ -200,52 +200,48 @@
% \begin{macro}{\@@_lastpagelabel:}
% \begin{macrocode}
%<*package>
- \cs_new_protected:Npn \@@_lastpagelabel:
- {
- \legacy_if:nT { @filesw }
- {
- \exp_args:NNnx \exp_args:NNx\iow_now:Nn \@auxout
- {
- \token_to_str:N \newlabeldata
- {@@_LastPage}
- {
- {abspage} { \int_use:N \g_shipout_readonly_int}
- {tagmcabs}{ \int_use:N \c@g_@@_MCID_abs_int }
- {tagstruct}{\int_use:N \c@g_@@_struct_abs_int }
- }
- }
- }
- }
-
+\cs_if_exist:NTF \property_new:nnnn
+ {
+ \cs_new_protected:Npn \@@_lastpagelabel:
+ {
+ \legacy_if:nT { @filesw }
+ {
+ \exp_args:NNnx \exp_args:NNx\iow_now:Nn \@auxout
+ {
+ \token_to_str:N \new@label@record
+ {@tag@LastPage}
+ {
+ {abspage} { \int_use:N \g_shipout_readonly_int}
+ {tagmcabs}{ \int_use:N \c@g_@@_MCID_abs_int }
+ {tagstruct}{\int_use:N \c@g_@@_struct_abs_int }
+ }
+ }
+ }
+ }
+ }
+ {
+ \cs_new_protected:Npn \@@_lastpagelabel:
+ {
+ \legacy_if:nT { @filesw }
+ {
+ \exp_args:NNnx \exp_args:NNx\iow_now:Nn \@auxout
+ {
+ \token_to_str:N \newlabeldata
+ {@tag@LastPage}
+ {
+ {abspage} { \int_use:N \g_shipout_readonly_int}
+ {tagmcabs}{ \int_use:N \c@g_@@_MCID_abs_int }
+ {tagstruct}{\int_use:N \c@g_@@_struct_abs_int }
+ }
+ }
+ }
+ }
+ }
\AddToHook{enddocument/afterlastpage}
{\@@_lastpagelabel:}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\ref_value:nnn}
-% This allows to locally set a default value if the label or the attribute
-% doesn't exist.
-% \begin{macrocode}
- \cs_if_exist:NF \ref_value:nnn
- {
- \cs_new:Npn \ref_value:nnn #1#2#3
- {
- \exp_args:Nee
- \__ref_value:nnn
- { \tl_to_str:n {#1} } { \tl_to_str:n {#2} } {#3}
- }
- \cs_new:Npn \__ref_value:nnn #1#2#3
- {
- \tl_if_exist:cTF { g__ref_label_ #1 _ #2 _tl }
- { \tl_use:c { g__ref_label_ #1 _ #2 _tl } }
- {
- #3
- }
- }
- }
-% \end{macrocode}
-% \end{macro}
-
% \section{Variables}
% \begin{variable}
% {
@@ -282,10 +278,10 @@
% \end{variable}
% Attribute lists for the label command. We have a list for
% mc-related labels, and one for structures.
-% \begin{macro}{\c_@@_refmc_clist,\c_@@_refstruct_clist}
+% \begin{macro}{\c_@@_property_mc_clist,\c_@@_property_struct_clist}
% \begin{macrocode}
-\clist_const:Nn \c_@@_refmc_clist {tagabspage,tagmcabs,tagmcid}
-\clist_const:Nn \c_@@_refstruct_clist {tagstruct,tagstructobj}
+\clist_const:Nn \c_@@_property_mc_clist {tagabspage,tagmcabs,tagmcid}
+\clist_const:Nn \c_@@_property_struct_clist {tagstruct,tagstructobj}
% \end{macrocode}
% \end{macro}
%
@@ -367,11 +363,110 @@
\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,Ne}
-\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{Label and Reference commands}
+% To ease transition to properties we setup internal definition. They can be replaced
+% by the property definitions once that is released.
+% \begin{macro}{\@@_property_new:nnnn,\@@_property_gset:nnnn,\@@_property_ref:nnn}
+% \begin{macrocode}
+\cs_if_exist:NTF \property_new:nnnn
+ {
+% \end{macrocode}
+% At first a command to define new properties
+% \begin{macrocode}
+ \cs_new_eq:NN \@@_property_new:nnnn \property_new:nnnn
+% \end{macrocode}
+% For the non-shipout code we need also the option to reset property
+% \begin{macrocode}
+ \cs_new_eq:NN \@@_property_gset:nnnn \property_gset:nnnn
+% \end{macrocode}
+% The command to reference while giving a local default.
+% \begin{macrocode}
+ \cs_new_eq:NN \@@_property_ref:nnn \property_ref:nnn
+ \cs_new_eq:NN \@@_property_ref:nn \property_ref:nn
+% \end{macrocode}
+% The command to record
+% \begin{macrocode}
+ \cs_new_protected:Npn \@@_property_record:nn #1#2
+ {
+ \@bsphack
+ \property_record:nn{#1}{#2}
+ \@esphack
+ }
+ }
+% \end{macrocode}
+% now the same with l3ref-tmp
+% \begin{macrocode}
+ {
+ \cs_new_protected:Npn \@@_property_new:nnnn #1 #2 #3 #4
+ {
+ \ref_attribute_gset:nnnn {#1}{#3}{#2}{#4}
+ }
+ \cs_new_protected:Npn \@@_property_gset:nnnn #1 #2 #3 #4
+ {
+ \ref_attribute_gset:nnnn {#1}{#3}{#2}{#4}
+ }
+ \cs_new:Npn \@@_property_ref:nnn #1#2#3
+ {
+ \exp_args:Nee
+ \__ref_value:nnn
+ { \tl_to_str:n {#1} } { \tl_to_str:n {#2} } {#3}
+ }
+ \cs_new:Npn \__ref_value:nnn #1#2#3
+ {
+ \tl_if_exist:cTF { g__ref_label_ #1 _ #2 _tl }
+ { \tl_use:c { g__ref_label_ #1 _ #2 _tl } }
+ {
+ #3
+ }
+ }
+ \cs_new_eq:NN \@@_property_ref:nn \ref_value:nn
+ \cs_new_protected:Npn \@@_property_record:nn #1#2
+ {
+ \@bsphack
+ \ref_label:nn {#1}{#2}
+ \@esphack
+ }
+% \end{macrocode}
+% to provide problems when switching between main and dev format:
+% \begin{macrocode}
+ \providecommand\new@label@record[2]{}
+ }
+% \end{macrocode}
+% And a few variants
+% \begin{macrocode}
+\cs_generate_variant:Nn \@@_property_ref:nnn {enn}
+\cs_generate_variant:Nn \@@_property_ref:nn {en}
+\cs_generate_variant:Nn \@@_property_record:nn {en,eV}
+% \end{macrocode}
+% The graphic code in latex-lab uses an internal tagpdf command, so until the next
+% release we need to provide it
+% \begin{macrocode}
+\cs_new:Npn \@@_ref_value:enn #1#2#3
+ {
+ \tl_if_exist:cTF { g__ref_label_ #1 _ #2 _tl }
+ { \tl_use:c { g__ref_label_ #1 _ #2 _tl } }
+ {
+ #3
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_property_ref_lastpage:nn}
+% A command to retrieve the lastpage label, this will be adapted when there
+% is a proper, kernel lastpage label.
+% \begin{macrocode}
+\cs_new:Npn \@@_property_ref_lastpage:nn #1 #2
+ {
+ \@@_property_ref:nnn {@tag@LastPage}{#1}{#2}
+ }
+% \end{macrocode}
+%\end{macro}
% \section{Setup label attributes}
% \begin{macro}{tagstruct,tagstructobj,tagabspage,tagmcabs,tagmcid}
@@ -385,68 +480,29 @@
% With mc-chunks we store the absolute page number |tagabspage|,
% the absolute id |tagmcabc|, and the id on the page |tagmcid|.
% \begin{macrocode}
-\ref_attribute_gset:nnnn { tagstruct } {0} { now }
- { \int_use:N \c@g_@@_struct_abs_int }
-\ref_attribute_gset:nnnn { tagstructobj } {} { now }
+\@@_property_new:nnnn
+ { tagstruct } { now }
+ {0} { \int_use:N \c@g_@@_struct_abs_int }
+\@@_property_new:nnnn { tagstructobj } { now } {}
{
\pdf_object_if_exist:eT {@@/struct/\int_use:N \c@g__tag_struct_abs_int}
{
\pdf_object_ref:e{@@/struct/\int_use:N \c@g_@@_struct_abs_int}
}
}
-\ref_attribute_gset:nnnn { tagabspage } {0} { shipout }
- { \int_use:N \g_shipout_readonly_int }
-\ref_attribute_gset:nnnn { tagmcabs } {0} { now }
- { \int_use:N \c@g_@@_MCID_abs_int }
+\@@_property_new:nnnn
+ { tagabspage } { shipout }
+ {0} { \int_use:N \g_shipout_readonly_int }
+\@@_property_new:nnnn { tagmcabs } { now }
+ {0} { \int_use:N \c@g_@@_MCID_abs_int }
\flag_new:n { @@/mcid }
-\ref_attribute_gset:nnnn {tagmcid } {0} { shipout }
- { \flag_height:n { @@/mcid } }
+\@@_property_new:nnnn {tagmcid } { shipout }
+ {0} { \flag_height:n { @@/mcid } }
% \end{macrocode}
% \end{macro}
%
-% \section{Label commands}
-% \begin{macro}{\@@_ref_label:nn}
-% A version of |\ref_label:nn| to set a label
-% which takes a keyword |mc| or |struct| to
-% call the relevant lists.
-% TODO: check if |\@bsphack| and |\@esphack| make sense here.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_ref_label:nn #1 #2 %#1 label, #2 name of list mc or struct
- {
- \@bsphack
- \ref_label:nv {#1}{c_@@_ref#2_clist}
- \@esphack
- }
-\cs_generate_variant:Nn \@@_ref_label:nn {en}
-% \end{macrocode}
-% \end{macro}
-% \begin{macro}{\@@_ref_value:nnn}
-% A local version to retrieve the value. It is a direct wrapper,
-% but to keep naming consistent \ldots. It uses the variant defined temporarly
-% above.
-% \begin{macrocode}
-\cs_new:Npn \@@_ref_value:nnn #1 #2 #3 %#1 label, #2 attribute, #3 default
- {
- \ref_value:nnn {#1}{#2}{#3}
- }
-\cs_generate_variant:Nn \@@_ref_value:nnn {enn}
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_ref_value_lastpage:nn}
-% A command to retrieve the lastpage label, this will be adapted when there
-% is a proper, kernel lastpage label.
-% \begin{macrocode}
-\cs_new:Npn \@@_ref_value_lastpage:nn #1 #2
- {
- \ref_value:nnn {@@_LastPage}{#1}{#2}
- }
-% \end{macrocode}
-%\end{macro}
-
-
%\section{Commands to fill seq and prop}
% With most engines these are simply copies of the expl3 commands,