texlive[56433] Master/texmf-dist: repltext (25sep20)

commits+karl at tug.org commits+karl at tug.org
Fri Sep 25 22:57:56 CEST 2020


Revision: 56433
          http://tug.org/svn/texlive?view=revision&revision=56433
Author:   karl
Date:     2020-09-25 22:57:56 +0200 (Fri, 25 Sep 2020)
Log Message:
-----------
repltext (25sep20)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/repltext/README
    trunk/Master/texmf-dist/doc/latex/repltext/repltext.pdf
    trunk/Master/texmf-dist/source/latex/repltext/repltext.dtx
    trunk/Master/texmf-dist/source/latex/repltext/repltext.ins
    trunk/Master/texmf-dist/tex/latex/repltext/repltext.sty

Modified: trunk/Master/texmf-dist/doc/latex/repltext/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/repltext/README	2020-09-25 20:57:39 UTC (rev 56432)
+++ trunk/Master/texmf-dist/doc/latex/repltext/README	2020-09-25 20:57:56 UTC (rev 56433)
@@ -25,7 +25,7 @@
 Copyright and license
 =====================
 
-Copyright (C) 2014 by Scott Pakin <scott+repl at pakin.org>
+Copyright (C) 2014-2020 Scott Pakin <scott+repl at pakin.org>
 
 This file may be distributed and/or modified under the conditions of
 the LaTeX Project Public License, either version 1.3c of this license

Modified: trunk/Master/texmf-dist/doc/latex/repltext/repltext.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/repltext/repltext.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/repltext/repltext.dtx	2020-09-25 20:57:39 UTC (rev 56432)
+++ trunk/Master/texmf-dist/source/latex/repltext/repltext.dtx	2020-09-25 20:57:56 UTC (rev 56433)
@@ -1,7 +1,7 @@
 % \iffalse meta-comment
 %
-% Copyright (C) 2014 by Scott Pakin <scott+repl at pakin.org>
-% ---------------------------------------------------------
+% Copyright (C) 2014-2020 Scott Pakin <scott+repl at pakin.org>
+% ----------------------------------------------------------
 %
 % This file may be distributed and/or modified under the conditions of
 % the LaTeX Project Public License, either version 1.3c of this license
@@ -22,11 +22,12 @@
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{repltext}
 %<*package>
-    [2014/04/11 v1.0 PDF replacement text]
+    [2020/09/25 v1.1 PDF replacement text]
 %</package>
 %
 %<*driver>
 \documentclass{ltxdoc}
+\usepackage[T1]{fontenc}
 \usepackage{repltext}
 \usepackage{graphicx}
 \usepackage{color}
@@ -46,13 +47,13 @@
   pdfauthor={Scott Pakin},
   pdfsubject={LaTeX package for PDF replacement text},
   pdfkeywords={LaTeX, PDF, replacement text, ActualText, copy and paste},
-  pdfcopyright={Copyright (C) 2014, Scott Pakin},
+  pdfcopyright={Copyright (C) 2014-2020 Scott Pakin},
   pdflicenseurl={http://www.latex-project.org/lppl/},
   pdfcaptionwriter={Scott Pakin},
   pdfcontactemail={scott+repl at pakin.org},
   pdfcontacturl={http://www.pakin.org/\xmptilde scott/},
   pdflang={en-US},
-  baseurl={http://www.ctan.org/tex-archive/macros/latex/contrib/repltext/repltext.pdf},
+  baseurl={http://mirror.ctan.org/macros/latex/contrib/repltext/repltext.pdf},
 %
   colorlinks=false,
   pdfstartview=Fit
@@ -60,13 +61,13 @@
 
 \begin{document}
   \DocInput{repltext.dtx}
-%  \PrintChanges
+  \PrintChanges
   \PrintIndex
 \end{document}
 %</driver>
 % \fi
 %
-% \CheckSum{38}
+% \CheckSum{59}
 %
 % \CharacterTable
 %  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -86,11 +87,12 @@
 %
 %
 % \changes{v1.0}{2014/04/11}{Initial version}
+% \changes{v1.1}{2020/09/25}{Support modern Lua\protect\LaTeX\ versions}
 %
 % \GetFileInfo{repltext.dtx}
 %
-% \DoNotIndex{\bgroup,\catcode,\egroup,\expandafter,\global,\let}
-% \DoNotIndex{\newcommand,\newenvironment,\the}
+% \DoNotIndex{\{,\},\bgroup,\catcode,\def,\egroup,\expandafter,\global,\let}
+% \DoNotIndex{\newcommand,\newenvironment,\protected,\providecommand,\the}
 %
 % ^^A  Define some logical styles.
 % \newcommand{\pkgname}[1]{^^A
@@ -322,15 +324,60 @@
 %
 % \section{Implementation}
 %
-% \pkgname{repltext} relies on the \cs{pdfliteral} and
-% \cs{pdfescapestring} primitives, which are defined only by
-% pdf\LaTeX\ and Lua\LaTeX\@.  We use the \pkgname{ifpdf} package to
-% test for one of those two \tex\ engines.
+% This section presents the documented source code for
+% \pkgname{repltext}.  Most users can ignore this section.
 %
+% \begin{macro}{\@ifdefined}
+% I find \cs{@ifdefined} a more natural construct than \cs{@ifundefined}.
 %    \begin{macrocode}
-\RequirePackage{ifpdf}
+\providecommand{\@ifdefined}[3]{\@ifundefined{#1}{#3}{#2}}
 %    \end{macrocode}
+% \end{macro}
 %
+% \begin{macro}{\repl at literal}
+% \pkgname{repltext} needs a mechanism to insert literal PDF code.  This
+% varies by \TeX\ engine so we have to define \cs{repl at literal} on an
+% engine-by-engine basis.
+% \changes{v1.1}{2020/09/25}{Add this macro}
+%    \begin{macrocode}
+\@ifdefined{pdfliteral}{%
+%    \end{macrocode}
+% \latex[pdf]
+%    \begin{macrocode}
+  \let\repl at literal=\pdfliteral
+}{%
+  \@ifdefined{pdfextension}{%
+%    \end{macrocode}
+% \latex[Lua]
+%    \begin{macrocode}
+    \protected\def\repl at literal{\pdfextension literal}%
+  }{%
+%    \end{macrocode}
+% Other
+%    \begin{macrocode}
+    \PackageError{repltext}{Unrecognized TeX engine}{%
+      The repltext package currently works only with pdfLaTeX and\MessageBreak
+      LuaLaTeX.\space\space Please use of those engines to build your document.%
+    }%
+  }%
+}%
+%    \end{macrocode}
+% \end{macro}
+%
+% \pkgname{repltext} additionally needs a mechanism to escape
+% backslashes and parentheses in a string to make it usable as a PDF
+% string.  This is easy in pdf\LaTeX, which provides
+% \cs{pdfescapestring}.  Unfortunately, to my knowledge, no other
+% \TeX\ engine provides equivalent functionality.  Rather than write our
+% own function, we leverage \pkgname{hyperref}'s \cs{Hy at pstringdef},
+% which provides similar functionality.
+%    \begin{macrocode}
+\RequirePackage{etoolbox}
+\AtEndPreamble{%
+  \@ifpackageloaded{hyperref}{}{\RequirePackage{hyperref}}%
+}
+%    \end{macrocode}
+%
 % The \cs{repl at text@ii} macro invokes \cs{scalebox}, which is defined by
 % the \pkgname{graphicx} package.
 %    \begin{macrocode}
@@ -381,6 +428,7 @@
 % \end{macro}
 %
 % \begin{macro}{\repl at text@ii}
+% \begin{macro}{\repl at escaped}
 % \cs{repl at text@ii} is the macro that finally outputs something.  It
 % takes ordinary \LaTeX\ code as its argument and writes a PDF
 % marked-content sequence that uses an \pdfname{ActualText} entry to
@@ -389,8 +437,9 @@
 % second argument (\cs{repl at text@ii}'s |#1|~argument).
 %    \begin{macrocode}
 \newcommand{\repl at text@ii}[1]{%
-  \pdfliteral{
-    /Span << /ActualText (\pdfescapestring{\the\repl at text@toks}) >>
+  \Hy at pstringdef\repl at escaped{\the\repl at text@toks}%
+  \repl at literal{
+    /Span << /ActualText (\repl at escaped) >>
     BDC
   }%
   #1%
@@ -402,10 +451,11 @@
 % without being noticeable.
 %    \begin{macrocode}
   \scalebox{0.000001}{-}%
-  \pdfliteral{EMC}%
+  \repl at literal{EMC}%
 }
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\prevrepl}
 % For the author's convenience we define \cs{prevrepl} to refer to the

Modified: trunk/Master/texmf-dist/source/latex/repltext/repltext.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/repltext/repltext.ins	2020-09-25 20:57:39 UTC (rev 56432)
+++ trunk/Master/texmf-dist/source/latex/repltext/repltext.ins	2020-09-25 20:57:56 UTC (rev 56433)
@@ -1,13 +1,13 @@
 %%
-%% Copyright (C) 2014 by Scott Pakin <scott+repl at pakin.org>
+%% Copyright (C) 2014-2020 by Scott Pakin <scott+repl at pakin.org>
 %%
 %% This file may be distributed and/or modified under the conditions of
 %% the LaTeX Project Public License, either version 1.3c of this license
 %% or (at your option) any later version.  The latest version of this
 %% license is in:
-%% 
+%%
 %%    http://www.latex-project.org/lppl.txt
-%% 
+%%
 %% and version 1.3c or later is part of all distributions of LaTeX version
 %% 2006/05/20 or later.
 %%
@@ -19,7 +19,7 @@
 
 \preamble
 
-Copyright (C) 2014 by Scott Pakin <scott+repl at pakin.org>
+Copyright (C) 2014-2020 by Scott Pakin <scott+repl at pakin.org>
 
 This file may be distributed and/or modified under the conditions of
 the LaTeX Project Public License, either version 1.3c of this license

Modified: trunk/Master/texmf-dist/tex/latex/repltext/repltext.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/repltext/repltext.sty	2020-09-25 20:57:39 UTC (rev 56432)
+++ trunk/Master/texmf-dist/tex/latex/repltext/repltext.sty	2020-09-25 20:57:56 UTC (rev 56433)
@@ -6,7 +6,7 @@
 %%
 %% repltext.dtx  (with options: `package')
 %% 
-%% Copyright (C) 2014 by Scott Pakin <scott+repl at pakin.org>
+%% Copyright (C) 2014-2020 by Scott Pakin <scott+repl at pakin.org>
 %% 
 %% This file may be distributed and/or modified under the conditions of
 %% the LaTeX Project Public License, either version 1.3c of this license
@@ -20,8 +20,24 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{repltext}
-    [2014/04/11 v1.0 PDF replacement text]
-\RequirePackage{ifpdf}
+    [2020/09/25 v1.1 PDF replacement text]
+\providecommand{\@ifdefined}[3]{\@ifundefined{#1}{#3}{#2}}
+\@ifdefined{pdfliteral}{%
+  \let\repl at literal=\pdfliteral
+}{%
+  \@ifdefined{pdfextension}{%
+    \protected\def\repl at literal{\pdfextension literal}%
+  }{%
+    \PackageError{repltext}{Unrecognized TeX engine}{%
+      The repltext package currently works only with pdfLaTeX and\MessageBreak
+      LuaLaTeX.\space\space Please use of those engines to build your document.%
+    }%
+  }%
+}%
+\RequirePackage{etoolbox}
+\AtEndPreamble{%
+  \@ifpackageloaded{hyperref}{}{\RequirePackage{hyperref}}%
+}
 \RequirePackage{graphicx}
 \newtoks\repl at text@toks
 \newcommand{\repltext}{%
@@ -38,13 +54,14 @@
   \repl at text@ii
 }
 \newcommand{\repl at text@ii}[1]{%
-  \pdfliteral{
-    /Span << /ActualText (\pdfescapestring{\the\repl at text@toks}) >>
+  \Hy at pstringdef\repl at escaped{\the\repl at text@toks}%
+  \repl at literal{
+    /Span << /ActualText (\repl at escaped) >>
     BDC
   }%
   #1%
   \scalebox{0.000001}{-}%
-  \pdfliteral{EMC}%
+  \repl at literal{EMC}%
 }
 \newcommand{\prevrepl}{%
   \expandafter\scantokens\expandafter{\the\repl at text@toks}%



More information about the tex-live-commits mailing list.