[latex3-commits] [git/LaTeX3-latex3-pdfresources] develop: add expl3 functions to retrieve document properties (54cf79f)
Ulrike Fischer
fischer at troubleshooting-tex.de
Sun Oct 9 12:10:27 CEST 2022
Repository : https://github.com/latex3/pdfresources
On branch : develop
Link : https://github.com/latex3/pdfresources/commit/54cf79f3f5bbb74f7208e4885dbaa970ef47a1cd
>---------------------------------------------------------------
commit 54cf79f3f5bbb74f7208e4885dbaa970ef47a1cd
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sun Oct 9 12:10:27 2022 +0200
add expl3 functions to retrieve document properties
>---------------------------------------------------------------
54cf79f3f5bbb74f7208e4885dbaa970ef47a1cd
CHANGELOG.md | 5 +++++
ltdocinit.dtx | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e6406ca..ace36e8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,11 @@ first release 0.95a, 2021-02-23 will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
this project uses date-based 'snapshot' version identifiers.
+## [Unreleased]
+
+### Added
+ - ltdocinit: expl3 functions to retrieve values from the document properties.
+
## [2022-09-26]
### Added
diff --git a/ltdocinit.dtx b/ltdocinit.dtx
index 2087bef..59afaf3 100644
--- a/ltdocinit.dtx
+++ b/ltdocinit.dtx
@@ -195,9 +195,10 @@
% using the container. The label |document| is reserved.
% \end{function}
%
-% \begin{function}{\GetDocumentProperties}
+% \begin{function}[updated=2022-10-09]{\GetDocumentProperties,\pdfmanagement_get_documentproperties:n}
% \begin{syntax}
-% \cs{GetDocumentProperties}\Arg{label/property}
+% \cs{GetDocumentProperties}\Arg{label/property}\\
+% \cs{pdfmanagement_get_documentproperties:n}\Arg{label/property}
% \end{syntax}
% Expands to the \meta{value} corresponding to \meta{label/property}
% in the container. If \meta{label/property} is missing,
@@ -207,6 +208,22 @@
% when appearing in an x-type argument expansion.
% \end{function}
%
+% \begin{function}[added=2022-10-09,TF]{\pdfmanagement_get_documentproperties:nN}
+% \begin{syntax}
+% \cs{pdfmanagement_get_documentproperties:nNTF}\Arg{label/property} \meta{token list variable}\\
+% ~~~~ \Arg{true code} \Arg{false code}
+% \end{syntax}
+% If the \meta{label/property} is not present in the document properties
+% container, leaves the \meta{false code} in the input stream.
+% The value of the
+% \meta{token list variable} is not defined in this case and should
+% not be relied upon. If the \meta{label/property} is present in the
+% container, stores the corresponding \meta{value} in the
+% \meta{token list variable} without removing it from the
+% container, then leaves the \meta{true code} in the input
+% stream. The \meta{token list variable} is assigned locally.
+% \end{function}
+%
% \begin{function}{\ShowDocumentProperties}
% \begin{syntax}
% \cs{ShowDocumentProperties}
@@ -528,6 +545,33 @@
}
% \end{macrocode}
% \end{macro}
+% For uses in modules (e.g. l3pdfmeta)
+% we provide an expl3 version without the xparse overhead:
+%
+% \begin{macro}[EXP]{\pdfmanagement_get_documentproperties:n}
+% \begin{macrocode}
+\cs_new:Npn\pdfmanagement_get_documentproperties:n #1
+ {
+ \prop_item:Nn \g_@@_documentproperties_prop {#1}
+ }
+% \end{macrocode}
+% \end{macro}
+% The following allows to retrieve the values with branching.
+% \begin{macro}[added=2022-10-09]{\pdfmanagement_get_documentproperties:nNTF}
+% \begin{macrocode}
+\prg_new_protected_conditional:Npnn
+ \pdfmanagement_get_documentproperties:nN #1#2 { T , F , TF }
+ {
+ \prop_get:NnNTF \g_@@_documentproperties_prop {#1} #2
+ {
+ \prg_return_true:
+ }
+ {
+ \prg_return_false:
+ }
+ }
+% \end{macrocode}
+% \end{macro}
% \begin{macro}{\ShowDocumentProperties}
% \begin{macrocode}
\msg_new:nnn { pdfmanagement } { show-properties }
More information about the latex3-commits
mailing list.