summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-09-25 20:57:56 +0000
committerKarl Berry <karl@freefriends.org>2020-09-25 20:57:56 +0000
commit3c2b78a2680317a1a3a1d73e8ca3b39a46a21299 (patch)
tree568f7db0174929faad84dfe73971999e6a36db63
parentbb1b3f8e561d48962c52f7d5aa057cd674520007 (diff)
repltext (25sep20)
git-svn-id: svn://tug.org/texlive/trunk@56433 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/repltext/README2
-rw-r--r--Master/texmf-dist/doc/latex/repltext/repltext.pdfbin303469 -> 437502 bytes
-rw-r--r--Master/texmf-dist/source/latex/repltext/repltext.dtx84
-rw-r--r--Master/texmf-dist/source/latex/repltext/repltext.ins8
-rw-r--r--Master/texmf-dist/tex/latex/repltext/repltext.sty29
5 files changed, 95 insertions, 28 deletions
diff --git a/Master/texmf-dist/doc/latex/repltext/README b/Master/texmf-dist/doc/latex/repltext/README
index 54ba09bd330..3d5b0c1a763 100644
--- a/Master/texmf-dist/doc/latex/repltext/README
+++ b/Master/texmf-dist/doc/latex/repltext/README
@@ -25,7 +25,7 @@ the filename database, if necessary, using mktexlsr or a similar tool.
Copyright and license
=====================
-Copyright (C) 2014 by Scott Pakin <scott+repl@pakin.org>
+Copyright (C) 2014-2020 Scott Pakin <scott+repl@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
diff --git a/Master/texmf-dist/doc/latex/repltext/repltext.pdf b/Master/texmf-dist/doc/latex/repltext/repltext.pdf
index 42ed0865316..b34575b92b0 100644
--- a/Master/texmf-dist/doc/latex/repltext/repltext.pdf
+++ b/Master/texmf-dist/doc/latex/repltext/repltext.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/repltext/repltext.dtx b/Master/texmf-dist/source/latex/repltext/repltext.dtx
index b75a3c1b8fe..9a116df516a 100644
--- a/Master/texmf-dist/source/latex/repltext/repltext.dtx
+++ b/Master/texmf-dist/source/latex/repltext/repltext.dtx
@@ -1,7 +1,7 @@
% \iffalse meta-comment
%
-% Copyright (C) 2014 by Scott Pakin <scott+repl@pakin.org>
-% ---------------------------------------------------------
+% Copyright (C) 2014-2020 Scott Pakin <scott+repl@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@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,13 +324,58 @@
%
% \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@literal}
+% \pkgname{repltext} needs a mechanism to insert literal PDF code. This
+% varies by \TeX\ engine so we have to define \cs{repl@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@literal=\pdfliteral
+}{%
+ \@ifdefined{pdfextension}{%
+% \end{macrocode}
+% \latex[Lua]
+% \begin{macrocode}
+ \protected\def\repl@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@pstringdef},
+% which provides similar functionality.
+% \begin{macrocode}
+\RequirePackage{etoolbox}
+\AtEndPreamble{%
+ \@ifpackageloaded{hyperref}{}{\RequirePackage{hyperref}}%
+}
% \end{macrocode}
%
% The \cs{repl@text@ii} macro invokes \cs{scalebox}, which is defined by
@@ -381,6 +428,7 @@
% \end{macro}
%
% \begin{macro}{\repl@text@ii}
+% \begin{macro}{\repl@escaped}
% \cs{repl@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@text@ii}'s |#1|~argument).
% \begin{macrocode}
\newcommand{\repl@text@ii}[1]{%
- \pdfliteral{
- /Span << /ActualText (\pdfescapestring{\the\repl@text@toks}) >>
+ \Hy@pstringdef\repl@escaped{\the\repl@text@toks}%
+ \repl@literal{
+ /Span << /ActualText (\repl@escaped) >>
BDC
}%
#1%
@@ -402,10 +451,11 @@
% without being noticeable.
% \begin{macrocode}
\scalebox{0.000001}{-}%
- \pdfliteral{EMC}%
+ \repl@literal{EMC}%
}
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\prevrepl}
% For the author's convenience we define \cs{prevrepl} to refer to the
diff --git a/Master/texmf-dist/source/latex/repltext/repltext.ins b/Master/texmf-dist/source/latex/repltext/repltext.ins
index 1e637b10c44..b876b5535cf 100644
--- a/Master/texmf-dist/source/latex/repltext/repltext.ins
+++ b/Master/texmf-dist/source/latex/repltext/repltext.ins
@@ -1,13 +1,13 @@
%%
-%% Copyright (C) 2014 by Scott Pakin <scott+repl@pakin.org>
+%% Copyright (C) 2014-2020 by Scott Pakin <scott+repl@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@pakin.org>
+Copyright (C) 2014-2020 by Scott Pakin <scott+repl@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
diff --git a/Master/texmf-dist/tex/latex/repltext/repltext.sty b/Master/texmf-dist/tex/latex/repltext/repltext.sty
index 227473fd27f..fa39894411b 100644
--- a/Master/texmf-dist/tex/latex/repltext/repltext.sty
+++ b/Master/texmf-dist/tex/latex/repltext/repltext.sty
@@ -6,7 +6,7 @@
%%
%% repltext.dtx (with options: `package')
%%
-%% Copyright (C) 2014 by Scott Pakin <scott+repl@pakin.org>
+%% Copyright (C) 2014-2020 by Scott Pakin <scott+repl@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@literal=\pdfliteral
+}{%
+ \@ifdefined{pdfextension}{%
+ \protected\def\repl@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@text@toks
\newcommand{\repltext}{%
@@ -38,13 +54,14 @@
\repl@text@ii
}
\newcommand{\repl@text@ii}[1]{%
- \pdfliteral{
- /Span << /ActualText (\pdfescapestring{\the\repl@text@toks}) >>
+ \Hy@pstringdef\repl@escaped{\the\repl@text@toks}%
+ \repl@literal{
+ /Span << /ActualText (\repl@escaped) >>
BDC
}%
#1%
\scalebox{0.000001}{-}%
- \pdfliteral{EMC}%
+ \repl@literal{EMC}%
}
\newcommand{\prevrepl}{%
\expandafter\scantokens\expandafter{\the\repl@text@toks}%