[latex3-commits] [git/LaTeX3-latex3-pdfresources] splitting: moved convert functions to pdftools (0b2b1d8)

Ulrike Fischer fischer at troubleshooting-tex.de
Sun Jul 5 00:27:30 CEST 2020


Repository : https://github.com/latex3/pdfresources
On branch  : splitting
Link       : https://github.com/latex3/pdfresources/commit/0b2b1d844fd9425971855d3235bfc3201f06ab5d

>---------------------------------------------------------------

commit 0b2b1d844fd9425971855d3235bfc3201f06ab5d
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sun Jul 5 00:27:30 2020 +0200

    moved convert functions to pdftools


>---------------------------------------------------------------

0b2b1d844fd9425971855d3235bfc3201f06ab5d
 l3pdftools.dtx                                     | 265 +++++++++++++++++++++
 l3pdfdict.ins => l3pdftools.ins                    |   6 +-
 ...-properties.pvt => bdc-properties-inactive.pvt} |   0
 testfiles/text-convert.luatex.tlg                  |  74 ++++++
 testfiles/text-convert.lvt                         |  22 ++
 testfiles/text-convert.tlg                         |  69 ++++++
 testfiles/text-convert.xetex.tlg                   |  45 ++++
 7 files changed, 478 insertions(+), 3 deletions(-)

diff --git a/l3pdftools.dtx b/l3pdftools.dtx
new file mode 100644
index 0000000..ee81132
--- /dev/null
+++ b/l3pdftools.dtx
@@ -0,0 +1,265 @@
+% \iffalse meta-comment
+%
+%% File: l3pdftools.dtx
+%
+% Copyright (C) 2018-2020 The LaTeX3 Project
+%
+% 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
+%
+%    http://www.latex-project.org/lppl.txt
+%
+% This file is part of the "(experimental) pdfresources bundle" (The Work in LPPL)
+% and all files in that bundle must be distributed together.
+%
+% -----------------------------------------------------------------------
+%
+% The development version of the bundle can be found at
+%
+%    https://github.com/latex3/pdfresources
+%
+% for those people who are interested.
+%
+%<*driver>
+\RequirePackage{expl3}
+\documentclass[full]{l3doc}
+\providecommand\potentialclash{\noindent\llap{\dbend\ }}
+\begin{document}
+  \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \title{^^A
+%   The \pkg{l3pdftools} package\\ collection of pdf related commands ^^A
+% }
+%
+% \author{^^A
+%  The \LaTeX3 Project\thanks
+%    {^^A
+%      E-mail:
+%        \href{mailto:latex-team at latex-project.org}
+%          {latex-team at latex-project.org}^^A
+%    }^^A
+% }
+%
+% \date{Released XXXX-XX-XX}
+%
+% \maketitle
+% \begin{documentation}
+%
+% \section{\pkg{l3pdftools} documentation}
+%
+% This module collects a number of commands of the tool type which haven't found
+% another home yet ... Probably this module will disappear again at some time.
+%
+% \begin{function}[EXP,added=2020-07-04]
+%   {\pdf_text_convert:nn}
+%  \begin{syntax}
+%   \cs{pdf_text_convert:nn}  \Arg{format}  \Arg{content}
+%  \end{syntax}
+%  This converts \Arg{content} following the rules defined by \Arg{format}.
+%  Non-ascii input should be utf8 encoded.
+%  Currently the following formats exist:
+%  \begin{description}
+%     \item[name] This will first expand the content with \cs{text_expand:n} and
+%      then escape it in the way needed in a PDF Name with
+%      \cs{str_convert_pdfname:e}.
+%     \item[name-print] This does the same as the \texttt{name} format, but also
+%     adds a slash before, so |\pdf_text_convert:nn{name-print}{abc}| will
+%     output \texttt{/abc}.
+%   \end{description}
+% \end{function}
+% \begin{function}[added=2020-07-04]
+%   {\pdf_text_convert:nnN}
+%  \begin{syntax}
+%   \cs{pdf_text_convert:nn}  \Arg{format}  \Arg{content} \Arg{tlvar}
+%  \end{syntax}
+%  This converts \Arg{content} following the rules defined by \Arg{format} and stores
+%  the result in \Arg{tlvar}. The assignment is done locally.
+%  Non-ascii input should be utf8 encoded.
+%  Currently the following formats exist:
+%  \begin{description}
+%     \item[name] see above
+%     \item[name-print] see above
+%     \item[string-lit]
+%      this converts with \cs{\str_set_convert:Nnnn} into utf16/string.
+%     \item[string-lit-print]
+%      this converts into utf16/string and add parentheses around.
+%     \item[string-hex]
+%      this converts into utf16/hex
+%     \item[string-hex-print]
+%     this converts into utf16/hex and add bracket around.
+%   \end{description}
+% \end{function}
+% \end{documentation}
+%
+% \begin{implementation}
+%
+% \section{\pkg{l3pdftools} implementation}
+%
+%    \begin{macrocode}
+%<*package>
+\ProvidesExplPackage {l3pdftools} {2020-07-04} {0.1}
+  {various PDF tools}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+%<@@=pdf>
+%    \end{macrocode}
+% \subsection{Conversions}
+% \begin{macro}{\pdf_text_convert:nn}
+% \begin{macro}{\pdf_text_convert:nnN}
+% \begin{macro}{\@@_text_convert_name:n}
+% \begin{macro}{\@@_text_convert_name:nN}
+% \begin{macro}{\@@_text_convert_name-print:n}
+% \begin{macro}{\@@_text_convert_name-print:n}
+%    \begin{macrocode}
+
+\cs_new:Npn \pdf_text_convert:nn #1 #2
+  {
+    \cs_if_exist_use:cF { @@_text_convert_#1:n }
+      {
+        \__kernel_msg_error:nnn { pdf } { unknown-exp-convert } {#1}
+        \use_none:n
+      }
+    { #2 }
+  }
+\cs_generate_variant:Nn \pdf_text_convert:nn {nV}
+
+\cs_new:Npn \pdf_text_convert:nnN #1 #2 #3
+  {
+    \cs_if_exist_use:cF { @@_text_convert_#1:nN }
+      {
+        \__kernel_msg_error:nnn { pdf } { unknown-convert } {#1}
+        \use_none:nn
+      }
+    { #2 } #3
+  }
+%% tool command escape name
+%% commands in the argument are expanded if possible
+%% with \text_expand:n
+%% name: only name,
+%% name_print: with / before, see also string naming
+
+\cs_generate_variant:Nn \str_convert_pdfname:n { e }
+
+\cs_new:Npn \@@_text_convert_name:n #1
+  {
+    \str_convert_pdfname:e { \text_expand:n { #1 } }
+  }
+
+\cs_new_protected:Npn \@@_text_convert_name:nN #1 #2
+  {
+    \tl_set:Nx #2 {\@@_text_convert_name:n {#1} }
+  }
+
+\cs_new:cpn { @@_text_convert_name-print:n } #1
+  {
+    / \str_convert_pdfname:e { \text_expand:n { #1 } }
+  }
+
+\cs_new_protected:cpn { @@_text_convert_name-print:nN } #1 #2
+  {
+    \tl_set:Nx #2 {\use:c { @@_text_convert_name-print:n } {#1} }
+  }
+
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{ \@@_text_convert_string-lit:nN }
+% \begin{macro}{ \@@_text_convert_string-lit-print:nN }
+% \begin{macro}{ @@_text_convert_string-hex:nN }
+% \begin{macro}{ @@_text_convert_string-hex-print:nN }
+%    \begin{macrocode}
+%% string conversions and printing
+%% we assume here that the text purify step has been done. The input is
+%% a list of (utf8) chars.
+%% str convert, not expandable.
+%  filespec (attachment view)  tests:
+%  utf8:  gr\303\274\303\237e.txt                    %doesn't work, umlaut wrong,
+%  utf8 with BOM \357\273\277gr\303\274\303\237e.txt %doesn't work, umlaut wrong, bom visible
+%  utf16 with BE: (FEFF)  \376\377\000g\000r\000\374\000\337\000e\000.\000t\000x\000t %works
+%                xetex converts to <feff0067007200fc00df0065002e007400780074>
+%  utf16 with BE / HEX: <FEFF0067007200FC00DF0065002E007400780074> works
+
+% bookmarks: as pdfoutline uses () currently only utf16 with BE is usable.
+% check if one can use HEX too when directly writing the object
+
+% "input" is utf8 for pdftex, empty (native) for unicode engine
+% commands to output literal strings  (...)
+\sys_if_engine_pdftex:TF
+  {
+    \cs_new_protected:cpn { @@_text_convert_string-lit:nN }  #1 #2
+      {
+         \str_set_convert:Nnnn #2 { #1 }{ utf8 } {utf16/string}
+      }
+
+    \cs_new_protected:cpn { @@_text_convert_string-lit-print:nN } #1 #2
+      {
+         \str_set_convert:Nnnn #2 { #1 }{ utf8 } {utf16/string}
+         \str_put_left:Nn #2  {(}
+         \str_put_right:Nn #2 {)}
+      }
+  }
+  {
+     \cs_new_protected:cpn { @@_text_convert_string-lit:nN } #1 #2
+      {
+        \str_set_convert:Nnnn #2 { #1 }{  } {utf16/string}
+      }
+
+    \cs_new_protected:cpn { @@_text_convert_string-lit-print:nN } #1 #2
+      {
+        \str_set_convert:Nnnn #2 { #1 }{  } {utf16/string}
+        \str_put_left:Nn #2  {(}
+        \str_put_right:Nn #2 {)}
+      }
+  }
+% commands to output hex strings  (...)
+
+\sys_if_engine_pdftex:TF
+  {
+    \cs_new:cpn { @@_text_convert_string-hex:nN } #1 #2
+      {
+         \str_set_convert:Nnnn #2 { #1 }{ utf8 } {utf16/hex}
+      }
+    \cs_new:cpn { @@_text_convert_string-hex-print:nN } #1 #2
+      {
+         \str_set_convert:Nnnn #2 { #1 }{ utf8 } {utf16/hex}
+         \str_put_left:Nn #2  {<}
+         \str_put_right:Nn #2 {>}
+      }
+  }
+  {
+    \cs_new:cpn { @@_text_convert_string-hex:nN } #1 #2
+      {
+        \str_set_convert:Nnnn #2 { #1 }{  } {utf16/hex}
+      }
+
+    \cs_new:cpn { @@_text_convert_string-hex-print:nN } #1 #2
+      {
+        \str_set_convert:Nnnn #2 { #1 }{  } {utf16/hex}
+         \str_put_left:Nn #2  {<}
+         \str_put_right:Nn #2 {>}
+      }
+  }
+
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%    \begin{macrocode}
+%</package>
+%    \end{macrocode}
+%
+% \end{implementation}
+%
+% \PrintIndex
diff --git a/l3pdfdict.ins b/l3pdftools.ins
similarity index 93%
copy from l3pdfdict.ins
copy to l3pdftools.ins
index 425c75b..526c3c6 100644
--- a/l3pdfdict.ins
+++ b/l3pdftools.ins
@@ -1,6 +1,6 @@
 \iffalse meta-comment
 
-File: l3pdfdict.ins
+File: l3pdftools.ins
 
 Copyright (C) 2018-2020 The LaTeX3 Project
 
@@ -53,9 +53,9 @@ and all files in that bundle must be distributed together.
 
 \keepsilent
 
-\generate{\file{l3pdfdict.sty}
+\generate{\file{l3pdftools.sty}
   {
-    \from{l3pdfdict.dtx}            {package}
+    \from{l3pdftools.dtx}            {package}
   }
 }
 
diff --git a/testfiles-dvips/bdc-properties.pvt b/testfiles-dvips/bdc-properties-inactive.pvt
similarity index 100%
copy from testfiles-dvips/bdc-properties.pvt
copy to testfiles-dvips/bdc-properties-inactive.pvt
diff --git a/testfiles/text-convert.luatex.tlg b/testfiles/text-convert.luatex.tlg
new file mode 100644
index 0000000..bf64b4a
--- /dev/null
+++ b/testfiles/text-convert.luatex.tlg
@@ -0,0 +1,74 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+> \x=macro:
+->/abc#2Fabc.
+l. ...\show\x
+> \x=macro:
+->\376\377\000a\000b\000c\000/\000a\000b\000c.
+l. ...\show\x
+> \x=macro:
+->(\376\377\000a\000b\000c\000/\000a\000b\000c).
+l. ...\show\x
+> \x=macro:
+->FEFF006100620063002F006100620063.
+l. ...\show\x
+> \x=macro:
+-><FEFF006100620063002F006100620063>.
+l. ...\show\x
+Completed box being shipped out [1]
+\vbox(633.0+0.0)x407.0, direction TLT
+.\glue 16.0
+.\vbox(617.0+0.0)x345.0, shifted 62.0, direction TLT
+..\vbox(12.0+0.0)x345.0, glue set 12.0fil, direction TLT
+...\glue 0.0 plus 1.0fil
+...\hbox(0.0+0.0)x345.0, direction TLT
+..\glue 25.0
+..\glue(\lineskip) 0.0
+..\vbox(550.0+0.0)x345.0, glue set 539.94232fil, direction TLT
+...\write-{}
+...\glue(\topskip) 2.5
+...\hbox(7.5+2.5)x345.0, glue set 225.82fil, direction TLT
+....\localpar
+.....\localinterlinepenalty=0
+.....\localbrokenpenalty=0
+.....\localleftbox=null
+.....\localrightbox=null
+....\hbox(0.0+0.0)x15.0, direction TLT
+....\TU/lmr/m/n/10 a
+....\TU/lmr/m/n/10 b
+....\kern0.28 (font)
+....\TU/lmr/m/n/10 c
+....\TU/lmr/m/n/10 #
+....\TU/lmr/m/n/10 2
+....\TU/lmr/m/n/10 F
+....\kern-0.83 (font)
+....\TU/lmr/m/n/10 a
+....\TU/lmr/m/n/10 b
+....\kern0.28 (font)
+....\TU/lmr/m/n/10 c
+....\TU/lmr/m/n/10 /
+....\TU/lmr/m/n/10 a
+....\TU/lmr/m/n/10 b
+....\kern0.28 (font)
+....\TU/lmr/m/n/10 c
+....\TU/lmr/m/n/10 #
+....\TU/lmr/m/n/10 2
+....\TU/lmr/m/n/10 F
+....\kern-0.83 (font)
+....\TU/lmr/m/n/10 a
+....\TU/lmr/m/n/10 b
+....\kern0.28 (font)
+....\TU/lmr/m/n/10 c
+....\penalty 10000
+....\glue(\parfillskip) 0.0 plus 1.0fil
+....\glue(\rightskip) 0.0
+...\glue -2.5
+...\glue 0.0 plus 1.0fil
+...\glue 0.0
+...\glue 0.0 plus 0.0001fil
+..\glue(\baselineskip) 23.34
+..\hbox(6.66+0.0)x345.0, glue set 170.0fil, direction TLT
+...\glue 0.0 plus 1.0fil
+...\TU/lmr/m/n/10 1
+...\glue 0.0 plus 1.0fil
+(text-convert.aux)
diff --git a/testfiles/text-convert.lvt b/testfiles/text-convert.lvt
new file mode 100644
index 0000000..d766fc6
--- /dev/null
+++ b/testfiles/text-convert.lvt
@@ -0,0 +1,22 @@
+\input{regression-test}
+\documentclass{article}
+
+\usepackage{l3pdftools}
+
+\begin{document}
+\START \showoutput
+\ExplSyntaxOn
+\pdf_text_convert:nn{name}{abc/abc}
+\pdf_text_convert:nn{name-print}{abc/abc}
+\pdf_text_convert:nnN{name-print}{abc/abc}\x
+\show\x
+\pdf_text_convert:nnN{string-lit}{abc/abc}\x
+\show\x
+\pdf_text_convert:nnN{string-lit-print}{abc/abc}\x
+\show\x
+\pdf_text_convert:nnN{string-hex}{abc/abc}\x
+\show\x
+\pdf_text_convert:nnN{string-hex-print}{abc/abc}\x
+\show\x
+\ExplSyntaxOff
+\end{document}
\ No newline at end of file
diff --git a/testfiles/text-convert.tlg b/testfiles/text-convert.tlg
new file mode 100644
index 0000000..e3bfb70
--- /dev/null
+++ b/testfiles/text-convert.tlg
@@ -0,0 +1,69 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+> \x=macro:
+->/abc#2Fabc.
+l. ...\show\x
+> \x=macro:
+->\376\377\000a\000b\000c\000/\000a\000b\000c.
+l. ...\show\x
+> \x=macro:
+->(\376\377\000a\000b\000c\000/\000a\000b\000c).
+l. ...\show\x
+> \x=macro:
+->FEFF006100620063002F006100620063.
+l. ...\show\x
+> \x=macro:
+-><FEFF006100620063002F006100620063>.
+l. ...\show\x
+Completed box being shipped out [1]
+\vbox(633.0+0.0)x407.0
+.\glue 16.0
+.\vbox(617.0+0.0)x345.0, shifted 62.0
+..\vbox(12.0+0.0)x345.0, glue set 12.0fil
+...\glue 0.0 plus 1.0fil
+...\hbox(0.0+0.0)x345.0
+..\glue 25.0
+..\glue(\lineskip) 0.0
+..\vbox(550.0+0.0)x345.0, glue set 539.94232fil
+...\write-{}
+...\glue(\topskip) 2.5
+...\hbox(7.5+2.5)x345.0, glue set 225.83305fil
+....\hbox(0.0+0.0)x15.0
+....\OT1/cmr/m/n/10 a
+....\OT1/cmr/m/n/10 b
+....\kern0.27779
+....\OT1/cmr/m/n/10 c
+....\OT1/cmr/m/n/10 #
+....\OT1/cmr/m/n/10 2
+....\OT1/cmr/m/n/10 F
+....\kern-0.83334
+....\OT1/cmr/m/n/10 a
+....\OT1/cmr/m/n/10 b
+....\kern0.27779
+....\OT1/cmr/m/n/10 c
+....\OT1/cmr/m/n/10 /
+....\OT1/cmr/m/n/10 a
+....\OT1/cmr/m/n/10 b
+....\kern0.27779
+....\OT1/cmr/m/n/10 c
+....\OT1/cmr/m/n/10 #
+....\OT1/cmr/m/n/10 2
+....\OT1/cmr/m/n/10 F
+....\kern-0.83334
+....\OT1/cmr/m/n/10 a
+....\OT1/cmr/m/n/10 b
+....\kern0.27779
+....\OT1/cmr/m/n/10 c
+....\penalty 10000
+....\glue(\parfillskip) 0.0 plus 1.0fil
+....\glue(\rightskip) 0.0
+...\glue -2.5
+...\glue 0.0 plus 1.0fil
+...\glue 0.0
+...\glue 0.0 plus 0.0001fil
+..\glue(\baselineskip) 23.55556
+..\hbox(6.44444+0.0)x345.0, glue set 170.0fil
+...\glue 0.0 plus 1.0fil
+...\OT1/cmr/m/n/10 1
+...\glue 0.0 plus 1.0fil
+(text-convert.aux)
diff --git a/testfiles/text-convert.xetex.tlg b/testfiles/text-convert.xetex.tlg
new file mode 100644
index 0000000..b1672e2
--- /dev/null
+++ b/testfiles/text-convert.xetex.tlg
@@ -0,0 +1,45 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+> \x=macro:
+->/abc#2Fabc.
+l. ...\show\x
+> \x=macro:
+->\376\377\000a\000b\000c\000/\000a\000b\000c.
+l. ...\show\x
+> \x=macro:
+->(\376\377\000a\000b\000c\000/\000a\000b\000c).
+l. ...\show\x
+> \x=macro:
+->FEFF006100620063002F006100620063.
+l. ...\show\x
+> \x=macro:
+-><FEFF006100620063002F006100620063>.
+l. ...\show\x
+Completed box being shipped out [1]
+\vbox(633.0+0.0)x407.0
+.\glue 16.0
+.\vbox(617.0+0.0)x345.0, shifted 62.0
+..\vbox(12.0+0.0)x345.0, glue set 12.0fil
+...\glue 0.0 plus 1.0fil
+...\hbox(0.0+0.0)x345.0
+..\glue 25.0
+..\glue(\lineskip) 0.0
+..\vbox(550.0+0.0)x345.0, glue set 539.94232fil
+...\write-{}
+...\glue(\topskip) 2.5
+...\hbox(7.5+2.49998)x345.0, glue set 225.81999fil
+....\hbox(0.0+0.0)x15.0
+....\TU/lmr/m/n/10 abc#2Fabc/abc#2Fabc
+....\penalty 10000
+....\glue(\parfillskip) 0.0 plus 1.0fil
+....\glue(\rightskip) 0.0
+...\glue -2.49998
+...\glue 0.0 plus 1.0fil
+...\glue 0.0
+...\glue 0.0 plus 0.0001fil
+..\glue(\baselineskip) 23.34
+..\hbox(6.66+0.0)x345.0, glue set 170.0fil
+...\glue 0.0 plus 1.0fil
+...\TU/lmr/m/n/10 1
+...\glue 0.0 plus 1.0fil
+(text-convert.aux)





More information about the latex3-commits mailing list.