summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/repltext
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-09-26 03:03:17 +0000
committerNorbert Preining <norbert@preining.info>2020-09-26 03:03:17 +0000
commit66ebd4914b367eb00a52ce5d5bb51f695101931b (patch)
treee5e4a5148bbf213f7ecc242d333bbde165d41e3b /macros/latex/contrib/repltext
parent56c9134f4aa02292ed17e726efd8e493b90e6011 (diff)
CTAN sync 202009260303
Diffstat (limited to 'macros/latex/contrib/repltext')
-rw-r--r--macros/latex/contrib/repltext/README2
-rw-r--r--macros/latex/contrib/repltext/repltext.dtx82
-rw-r--r--macros/latex/contrib/repltext/repltext.ins8
-rw-r--r--macros/latex/contrib/repltext/repltext.pdfbin303469 -> 437502 bytes
4 files changed, 71 insertions, 21 deletions
diff --git a/macros/latex/contrib/repltext/README b/macros/latex/contrib/repltext/README
index 54ba09bd33..3d5b0c1a76 100644
--- a/macros/latex/contrib/repltext/README
+++ b/macros/latex/contrib/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/macros/latex/contrib/repltext/repltext.dtx b/macros/latex/contrib/repltext/repltext.dtx
index 3cc1e9fcf9..9a116df516 100644
--- a/macros/latex/contrib/repltext/repltext.dtx
+++ b/macros/latex/contrib/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,7 +47,7 @@
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},
@@ -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/macros/latex/contrib/repltext/repltext.ins b/macros/latex/contrib/repltext/repltext.ins
index 1e637b10c4..b876b5535c 100644
--- a/macros/latex/contrib/repltext/repltext.ins
+++ b/macros/latex/contrib/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/macros/latex/contrib/repltext/repltext.pdf b/macros/latex/contrib/repltext/repltext.pdf
index 42ed086531..b34575b92b 100644
--- a/macros/latex/contrib/repltext/repltext.pdf
+++ b/macros/latex/contrib/repltext/repltext.pdf
Binary files differ