[latex3-commits] [git/LaTeX3-latex3-pdfresources] develop, master: simplify and unify zref/l3xref handling (b664dea)
Ulrike Fischer
fischer at troubleshooting-tex.de
Thu Dec 3 19:20:38 CET 2020
Repository : https://github.com/latex3/pdfresources
On branches: develop,master
Link : https://github.com/latex3/pdfresources/commit/b664deaa8754afaf9af1ee776186f21c363a9df4
>---------------------------------------------------------------
commit b664deaa8754afaf9af1ee776186f21c363a9df4
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Thu Dec 3 19:20:38 2020 +0100
simplify and unify zref/l3xref handling
>---------------------------------------------------------------
b664deaa8754afaf9af1ee776186f21c363a9df4
hgeneric-experimental.def | 98 ++++++++++++++++++++++++++++++++++++++++-------
l3backend-pdf-extra.dtx | 38 ++++++++----------
2 files changed, 101 insertions(+), 35 deletions(-)
diff --git a/hgeneric-experimental.def b/hgeneric-experimental.def
index 8b56687..c9c039f 100644
--- a/hgeneric-experimental.def
+++ b/hgeneric-experimental.def
@@ -38,13 +38,89 @@
%% \Hy at EXPsetbordercolor
%% \hypupdateattribute
\ProvidesFile{hgeneric-experimental.def}
- [2020/05/17 v0.6 %
+ [2020/12/03 v0.7 %
Hyperref driver for luaTeX]
\RequirePackage{xparse,etoolbox,l3color}
\chardef\Hy at VersionChecked=1 %don't check the version!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ExplSyntaxOn
+%% zref/l3xref switch
+% one of both must have been loaded as pdfmanagement is a requirement
+% this is not perfect but should work only xref is there for good.
+
+\cs_if_exist:NTF \xref_value:nn
+ {
+ \cs_new_protected:Npn \__hyp_ref_label:nn #1 #2 %label/attributes
+ {
+ \@bsphack
+ \xref_label:nn{#1}{#2}
+ \@esphack
+ }
+ \cs_generate_variant:Nn \__hyp_ref_label:nn {en}
+ \cs_new_protected:Npn \__hyp_ref_check:nn #1 #2 %label/attribute
+ {
+ \tl_if_exist:cF { g__xref_label_ \tl_to_str:n {#1} _ \tl_to_str:n {#2} _tl }
+ {
+ \protect\G at refundefinedtrue
+ \@latex at warning
+ {
+ Reference~`\tl_to_str:n {#1}'~with~attribute~`\tl_to_str:n {#2}'~
+ on~page~\thepage~\space undefined
+ }
+ }
+ }
+ \cs_generate_variant:Nn \__hyp_ref_check:nn {en}
+ \prg_new_conditional:Npnn \__hyp_ref_if_exist:nn #1#2 { p , T , TF } % #1 #2 %label/attribute
+ {
+ \tl_if_exist:cTF { g__xref_label_ \tl_to_str:n {#1} _ \tl_to_str:n {#2} _tl }
+ {
+ \prg_return_true:
+ }
+ {
+ \prg_return_false:
+ }
+ }
+ \prg_generate_conditional_variant:Nnn \__hyp_ref_if_exist:nn {en} { p , T , TF }
+ \cs_new:Npn \__hyp_ref_value:nn #1 #2
+ {
+ \xref_value:nn{#1}{#2}
+ }
+ \cs_generate_variant:Nn \__hyp_ref_value:nn {en}
+ }
+ { %zref
+ \RequirePackage{zref-abspage} %move to backend ...
+ \cs_new_protected:Npn \__hyp_ref_label:nn #1 #2 %label/attributes
+ {
+ \zref at labelbyprops{\tl_to_str:n {#1}}{#2}
+ }
+ \cs_generate_variant:Nn \__hyp_ref_label:nn {en}
+ \cs_new_protected:Npn \__hyp_ref_check:nn #1 #2
+ {
+ \zref at refused {\exp_not:n{#1}}
+ }
+ \cs_generate_variant:Nn \__hyp_ref_check:nn {en}
+ \prg_new_conditional:Npnn \__hyp_ref_if_exist:nn #1#2 { p , T , TF } % #1 #2 %label/attribute
+ {
+ \zref at ifrefundefined{\tl_to_str:n {#1}}
+ {\prg_return_false:}
+ {
+ \zref at ifrefcontainsprop{\tl_to_str:n {#1}}{\tl_to_str:n {#2}}
+ {
+ \prg_return_true:
+ }
+ {
+ \prg_return_false:
+ }
+ }
+ }
+ \prg_generate_conditional_variant:Nnn \__hyp_ref_if_exist:nn {en} { p , T , TF }
+ \cs_new:Npn \__hyp_ref_value:nn #1 #2
+ {
+ \zref at extract{\tl_to_str:n {#1}}{\tl_to_str:n {#2}}
+ }
+ \cs_generate_variant:Nn \__hyp_ref_value:nn {en}
+ }
%% messages, should later (with more drivers) go somewhere more generic ...
\prop_gput:Nnn \g_msg_module_name_prop { hyp }{ hyperref }
@@ -1918,25 +1994,21 @@
{
\global\advance\HyAnn at Count by\ltx at one
%\zref at labelbyprops{HyAnn@\the\HyAnn at Count}{abspage}%
- \zref at labelbylist {HyAnn@\the\HyAnn at Count} {l3pdf}
- \zref at refused{HyAnn@\the\HyAnn at Count}%
+ %\zref at labelbylist {HyAnn@\the\HyAnn at Count} {l3pdf}
+ %\zref at refused{HyAnn@\the\HyAnn at Count}%
+ \__hyp_ref_label:en {HyAnn@\the\HyAnn at Count}{abspage}
+ \__hyp_ref_check:en {HyAnn@\the\HyAnn at Count}{abspage}
}%
\def\Fld at pageobjref
{
- \zref at ifrefundefined{HyAnn@\the\HyAnn at Count}
- {}
+ \__hyp_ref_if_exist:enT {HyAnn@\the\HyAnn at Count}{abspage}
{
- \zref at ifrefcontainsprop{HyAnn@\the\HyAnn at Count}{pdf at abspage}
+ /P~\pdf_object_pageref:n
{
- /P~\pdf_object_pageref:n
- {
- \zref at extractdefault{HyAnn@\the\HyAnn at Count}{pdf at abspage}{1} %
- }
+ \__hyp_ref_value:en{HyAnn@\the\HyAnn at Count}{abspage}
}
- {}
- }
+ }
}
-
\ExplSyntaxOff
\ExplSyntaxOn
%% check if the attr should be set through
diff --git a/l3backend-pdf-extra.dtx b/l3backend-pdf-extra.dtx
index 57ea49d..9c2362a 100644
--- a/l3backend-pdf-extra.dtx
+++ b/l3backend-pdf-extra.dtx
@@ -69,36 +69,30 @@
\RequirePackage{l3xref}
\cs_generate_variant:Nn \xref_label:nn {en}
\cs_generate_variant:Nn \xref_value:nn {en}
- \cs_new_protected:Npn \@@_backend_abspage_label:n #1
+ \cs_new_protected:Npn \@@_backend_ref_label:nn #1 #2
{
\@bsphack
\xref_label:nn{#1}{abspage}
\@esphack
}
- \cs_new:Npn \@@_backend_abspage_value:n #1
+ \cs_new:Npn \@@_backend_ref_value:nn #1 #2
{
- \xref_value:nn{#1}{abspage}
+ \xref_value:nn{#1}{#2}
}
}
{
- \RequirePackage{zref-base}
- \zref at newlist { l3pdf }
- \zref at newprop* { pdf at abspage } [0] { \int_use:N \g_shipout_readonly_int }
- \zref at addprop { l3pdf } { pdf at abspage }
- \cs_new_protected:Npn \@@_backend_abspage_label:n #1
+ \RequirePackage{zref-abspage}
+ \cs_new_protected:Npn \@@_backend_ref_label:nn #1 #2
{
- \zref at labelbylist {#1} {l3pdf}
+ \zref at labelbyprops {\tl_to_str:n {#1}} {#2}
}
- \cs_new:Npn \@@_backend_abspage_value:n #1
+ \cs_new:Npn \@@_backend_ref_value:nn #1 #2
{
- \zref at extractdefault
- {#1}
- {pdf at abspage}
- {0}
+ \zref at extract {\tl_to_str:n {#1}}{\tl_to_str:n {#2}}
}
}
-\cs_generate_variant:Nn \@@_backend_abspage_label:n {e}
-\cs_generate_variant:Nn \@@_backend_abspage_value:n {e}
+\cs_generate_variant:Nn \@@_backend_ref_label:nn {en}
+\cs_generate_variant:Nn \@@_backend_ref_value:nn {en}
%</drivers>
% \end{macrocode}
% \begin{macrocode}
@@ -304,7 +298,7 @@
\int_gincr:N\g_@@_backend_resourceid_int
%\zref at labelbylist {l3pdf\int_use:N\g_@@_backend_resourceid_int} {l3pdf}
%\xref_label:en{l3pdf\int_use:N\g_@@_backend_resourceid_int}{abspage}
- \@@_backend_abspage_label:e { l3pdf\int_use:N\g_@@_backend_resourceid_int }
+ \@@_backend_ref_label:en { l3pdf\int_use:N\g_@@_backend_resourceid_int }{abspage}
\tl_set:Nx \l_@@_tmpa_tl
{
%\zref at extractdefault
@@ -312,7 +306,7 @@
% {pdf at abspage}
% {0}
% \xref_value:en{l3pdf\int_use:N\g_@@_backend_resourceid_int}{abspage}
- \@@_backend_abspage_value:e {l3pdf\int_use:N\g_@@_backend_resourceid_int}
+ \@@_backend_ref_value:en {l3pdf\int_use:N\g_@@_backend_resourceid_int}{abspage}
}
\pdfdict_if_exist:nnF { g } {Core/backend_Page\l_@@_tmpa_tl}
{
@@ -903,7 +897,7 @@
% { l3pdf\int_use:N\g_@@_backend_resourceid_int }
% { l3pdf }
% \xref_label:en{l3pdf\int_use:N\g_@@_backend_resourceid_int}{abspage}
- \@@_backend_abspage_label:e{l3pdf\int_use:N\g_@@_backend_resourceid_int}
+ \@@_backend_ref_label:en{l3pdf\int_use:N\g_@@_backend_resourceid_int}{abspage}
\tl_set:Nx \l_@@_tmpa_tl
{
%\zref at extractdefault
@@ -911,7 +905,7 @@
% {pdf at abspage}
% {0}
%\xref_value:en{l3pdf\int_use:N\g_@@_backend_resourceid_int}{abspage}
- \@@_backend_abspage_value:e{l3pdf\int_use:N\g_@@_backend_resourceid_int}
+ \@@_backend_ref_value:en{l3pdf\int_use:N\g_@@_backend_resourceid_int}{abspage}
}
\pdfdict_if_exist:nnF { g } { Core/backend_Page\l_@@_tmpa_tl/Resources/Properties }
{
@@ -942,7 +936,7 @@
% { l3pdf\int_use:N\g_@@_backend_resourceid_int }
% { l3pdf }
%\xref_label:en{l3pdf\int_use:N\g_@@_backend_resourceid_int}{abspage}
- \@@_backend_abspage_label:e{l3pdf\int_use:N\g_@@_backend_resourceid_int}
+ \@@_backend_ref_label:en{l3pdf\int_use:N\g_@@_backend_resourceid_int}{abspage}
\tl_set:Nx \l_@@_tmpa_tl
{
%\zref at extractdefault
@@ -950,7 +944,7 @@
% {pdf at abspage}
% {0}
% \xref_value:en{l3pdf\int_use:N\g_@@_backend_resourceid_int}{abspage}
- \@@_backend_abspage_value:e{l3pdf\int_use:N\g_@@_backend_resourceid_int}
+ \@@_backend_ref_value:en{l3pdf\int_use:N\g_@@_backend_resourceid_int}{abspage}
}
\pdfdict_if_exist:nnF { g } { Core/backend_Page\l_@@_tmpa_tl/Resources/Properties }
{
More information about the latex3-commits
mailing list.