summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-07-15 21:13:25 +0000
committerKarl Berry <karl@freefriends.org>2006-07-15 21:13:25 +0000
commita75519ac49fb11f564759ef2e7e984e064f18913 (patch)
treef90f761bbb7d5874ca2368d89f29cfa093e81047
parent92087ec9254485f45be7ef05102d78aca4030ab3 (diff)
new package randtext replaces switcheml (21mar06)
git-svn-id: svn://tug.org/texlive/trunk@1853 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/randtext/README11
-rw-r--r--Master/texmf-dist/doc/latex/switcheml/README4
-rw-r--r--Master/texmf-dist/tex/latex/randtext/randtext.sty143
-rw-r--r--Master/texmf-dist/tex/latex/switcheml/switcheml.sty90
-rw-r--r--Master/texmf-dist/tpm/randtext.tpm22
-rw-r--r--Master/texmf-dist/tpm/switcheml.tpm29
-rw-r--r--Master/texmf/lists/randtext6
-rw-r--r--Master/texmf/tpm/collection-latexextra.tpm2
8 files changed, 183 insertions, 124 deletions
diff --git a/Master/texmf-dist/doc/latex/randtext/README b/Master/texmf-dist/doc/latex/randtext/README
new file mode 100644
index 00000000000..3dbdc501dfe
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/randtext/README
@@ -0,0 +1,11 @@
+The package "randtext.sty", which supersedes "switcheml.sty", provides a
+single macro \randomize{TEXT} that typesets the characters of TEXT in
+random order, such that the resulting output appears correct, but most
+automated attempts to read the file will misunderstand it.
+
+This function allows one to include an email address on a TeX document
+and publish it online without fear of email address harvesters or
+spammers easily picking up the address.
+
+For more information, please read the comments at the top of the package
+file.
diff --git a/Master/texmf-dist/doc/latex/switcheml/README b/Master/texmf-dist/doc/latex/switcheml/README
deleted file mode 100644
index 71c09c3e94d..00000000000
--- a/Master/texmf-dist/doc/latex/switcheml/README
+++ /dev/null
@@ -1,4 +0,0 @@
-switcheml provides one main command, "\switcheml{EMAIL}", that obfuscates
-an email address EMAIL by rearranging it so that, while it prints correctly
-on the page, it is unreadable by email address harvesters (typically used
-by spammers).
diff --git a/Master/texmf-dist/tex/latex/randtext/randtext.sty b/Master/texmf-dist/tex/latex/randtext/randtext.sty
new file mode 100644
index 00000000000..0274642c878
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/randtext/randtext.sty
@@ -0,0 +1,143 @@
+%
+% randtext.sty
+%
+% Charles Duan (2004/12/20)
+%
+% Provides one useful macro, \randomize{TEXT}. Result is a typeset box that
+% looks, on paper, like TEXT, but whose letters have in fact been placed in
+% random order so that they are not copiable from the file directly.
+%
+% In other words, typing:
+%
+% This is a \randomize{random-text} test.
+%
+% would produce output that looks like:
+%
+% This is a random-text test.
+%
+% but if you tried to copy-paste it from the output file, you would probably get
+%
+% This is a mdoxt-etnra test.
+%
+% The function of this odd macro is to obfuscate e-mail addresses, say on a PDF
+% document put online, so that the human reader sees the address as expected,
+% but e-mail address harvesters and spambots cannot determine the address. Since
+% this macro is done entirely using TeX typesetting commands, it requires no
+% external image generation or anything, and the typeset result is just as
+% high-quality as if no obfuscation had taken place.
+%
+% This macro does take into account kerning between character pairs, but it does
+% not account for ligatures. To make appropriate ligatures, surround the
+% ligature characters with braces.
+%
+% This package supersedes "switcheml.sty", written by the same author. (That is
+% the reason that the internal macros begin with "se@".
+%
+% Requires the file "random.tex", by Donald Arseneau. I believe that this file
+% comes as part of a standard TeX distribution.
+%
+%
+\ProvidesPackage{randtext}[2004/12/20 Obfuscate text]
+%
+% We use the random package to pick random numbers.
+\input random
+%
+% \se@count stores the number of letters/groups to typeset. For instance,
+% \randomize{abc{de}fg{hij}kl}
+% contains 9 letters/groups.
+\newcount\se@count
+%
+% \se@random is a random number register.
+\newcount\se@random
+%
+% \se@pos is used to store the width of each section of the randomized text.
+\newdimen\se@pos
+%
+% Randomize the text of the argument.
+\def\randomize#1{%
+ % Do nothing for empty argument.
+ \def\se@tmp{#1}\ifx\se@tmp\@empty\else
+ % Make our work local
+ \begingroup
+ % In case this is the first thing in the paragraph, go to horizontal
+ % mode
+ \leavevmode
+ % Initialize \se@count=1, \se@pos=0pt
+ \se@count\@ne
+ \se@pos\z@
+ % Now iterate over the argument text. The \relax is put at the end
+ % as an untypeset token.
+ \se@randomize#1\relax\@stop
+ \endgroup
+ \fi
+}
+%
+% Iterator function for \randomize. Essentially, this function will be executed
+% once for each token in the list.
+\def\se@randomize#1#2#3\@stop{%
+ % Define a macro \pos@[\se@count]. Essentially, this makes a unique,
+ % numbered macro for each letter/group.
+ \expandafter\edef\csname pos@\the\se@count\endcsname{%
+ % The macro produces a zero-width box that jumps forward \se@pos and
+ % then typesets the letter/group. Note the \the\se@pos, to force current
+ % evaluation of the distance to move forward.
+ \noexpand\rlap{\hskip\the\se@pos\relax#1}%
+ }%
+ % Advance \se@pos forward by the width of the first group and the
+ % immediately subsequent group, and then backward by the width of the second
+ % group. The effect is to advance \se@pos by the first group and the kern
+ % between the first and second groups.
+ \setbox\z@\hbox{#1#2}\advance\se@pos\wd\z@
+ \setbox\z@\hbox{#2}\advance\se@pos-\wd\z@
+ %
+ % If there's nothing left to iterate over, then:
+ % \se@pos is the width of the whole text
+ % \se@count is the number of letters/groups, or the highest \pos@[number]
+ % so we make a box of width \se@pos, place our random letters in it with
+ % \se@rand@place, and fill up the box for good measure.
+ %
+ % Otherwise, increment \se@count and run the function again.
+ %
+ % Note two things:
+ % 1. We put braces around #2 but not #3. Since there's an extra \relax at
+ % the end of #3 at all times, we don't have the problem of TeX stripping any
+ % braces from it.
+ % 2. The other reason we needed that \relax was that, since we read
+ % letters/groups in pairs, the last letter/group would only be read if there
+ % was an extra token at the end (i.e., the \relax).
+ \def\se@tmp{#3}\ifx\se@tmp\@empty \expandafter\@firstoftwo
+ \else \expandafter\@secondoftwo \fi
+ {\hb@xt@\se@pos{\se@rand@place\hfill}}%
+ {\advance\se@count\@ne\se@randomize{#2}#3\@stop}%
+}
+%
+% Now all of our \pos@[number] functions are set, and we just need to randomly
+% select and place.
+\def\se@rand@place{%
+ %
+ % Pick a random number between one and \se@num. (If \se@num>3, then ensure
+ % that the number is over three. This way, the first two elements will
+ % always be typeset last, guaranteeing at least some contortion.)
+ \ifnum\se@count>\z@
+ \ifnum\se@count>\thr@@
+ \setrannum\se@random\thr@@\se@count
+ \else
+ \setrannum\se@random\@ne\se@count
+ \fi
+ % Execute \pos@[\se@random].
+ \csname pos@\the\se@random\endcsname
+ % Now replace \pos@[\se@random] with \pos@[\se@count] and decrement
+ % \se@count. This way, the next random number will be guaranteed to
+ % typeset an unselected value.
+ \ifnum\se@random=\se@count\else
+ \edef\reserved@a{%
+ \let\expandafter\noexpand\csname pos@\the\se@random\endcsname
+ \expandafter\noexpand\csname pos@\the\se@count\endcsname
+ }\reserved@a
+ \fi
+ \advance\se@count\m@ne
+ % Repeat
+ \expandafter\se@rand@place
+ \fi
+}
+\endinput
diff --git a/Master/texmf-dist/tex/latex/switcheml/switcheml.sty b/Master/texmf-dist/tex/latex/switcheml/switcheml.sty
deleted file mode 100644
index fb409929a0d..00000000000
--- a/Master/texmf-dist/tex/latex/switcheml/switcheml.sty
+++ /dev/null
@@ -1,90 +0,0 @@
-%
-% switcheml.sty
-%
-% Charles Duan (2004/02/10)
-%
-% Obfuscates an e-mail address so that it is unreadable by automated document
-% crawlers but appears correct when displayed.
-%
-% Commands provided by this package are:
-%
-% \switchemail{EMAIL}
-% Obfuscates EMAIL by reversing on the @ and . symbols, so
-% some@one.place.com
-% will be written to the document as:
-% com place. one. some@
-% but it will appear properly on the document page.
-%
-% \switch{DELIM}{TEXT}
-% Obfuscates TEXT by reversing values around DELIM, so
-% \switch{,}{abc,def,ghi,jkl}
-% will be written to the document as:
-% jkl ghi, def, abc
-% but it will appear on the document page as:
-% abc,def,ghi,jkl
-%
-% \kernhack{A}{B}
-% Produces a kern equivalent to the kern that would normally appear between A
-% and B.
-%
-\ProvidesPackage{switcheml}[2004/02/10 Obfuscate e-mail addresses]
-% Produce a kern equivalent to the kern between #1 and #2
-\def\kernhack#1#2{%
- \begingroup
- \setbox\z@\hbox{#1#2}%
- \dimen@\wd\z@
- \setbox\z@\hbox{#1{}#2}\advance\dimen@-\wd\z@
- \ifdim\dimen@=\z@\else\kern\dimen@\fi
- \endgroup
-}
-% Given a character to find (e.g., period) and a string of text, obfuscate the
-% text so that the last part of the text is placed first, etc., so everything
-% comes up in reverse order when you try to copy/paste but it looks fine on
-% screen. For instance,
-%
-% some.domain.com
-%
-% is rewritten as:
-%
-% box{com} box{domain.} box{some.}
-%
-% with each of the boxes placed such that they print out properly.
-%
-\def\switch#1#2{%
- \begingroup
- \def\@switch##1#1##2\@nil#1##3\@stop{%
- \def\reserved@a{##3}%
- \ifx\reserved@a\@empty#2\else
- \setbox\z@\hbox{##1#1}%
- \setbox\tw@\hbox{\kernhack{#1}{##2}\switch{#1}{##2}}%
- \dimen@\wd\tw@\advance\dimen@\wd\z@%
- \wd\z@\dimen@%
- \rlap{\hb@xt@\dimen@{\hfil\unhbox\tw@}}%
- \box\z@
- \fi
- }%
- \@switch#2\@nil#1\@nil#1\@stop
- \endgroup
-}
-% Given an e-mail address of the form abc@def.ghi.jkl, reverses it to be jkl
-% ghi. def. abc@
-\def\switchemail#1{%
- \expandafter\@switchemail#1\@stop
-}
-% Helper function for \switchemail. Note the \copy, because \kernhack will
-% destroy the box otherwise. Need to do some funky stuff because of catcodes.
-\begingroup
- \makeatother
- \def\tmp#1#2#3{%
- \gdef#1##1@##2#2{%
- \begingroup
- \setbox#3\hbox{\switch{.}{##2}}%
- \switch{@}{##1@\copy#3}%
- \endgroup
- }%
- }
- \makeatletter
- \tmp\@switchemail\@stop\@tempboxa
-\endgroup
-
-\endinput
diff --git a/Master/texmf-dist/tpm/randtext.tpm b/Master/texmf-dist/tpm/randtext.tpm
new file mode 100644
index 00000000000..13065b3cd54
--- /dev/null
+++ b/Master/texmf-dist/tpm/randtext.tpm
@@ -0,0 +1,22 @@
+<!DOCTYPE rdf:RDF SYSTEM "../../support/tpm.dtd">
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:TPM="http://texlive.dante.de/">
+ <rdf:Description about="http://texlive.dante.de/texlive/Package/randtext.zip">
+ <TPM:Name>randtext</TPM:Name>
+ <TPM:Type>Package</TPM:Type>
+ <TPM:Date>2006/03/20 13:43:00</TPM:Date>
+ <TPM:Version></TPM:Version>
+ <TPM:Creator>karl</TPM:Creator>
+ <TPM:Title>The randtext package.</TPM:Title>
+ <TPM:Description></TPM:Description>
+ <TPM:Author></TPM:Author>
+ <TPM:Size>5936</TPM:Size>
+ <TPM:Build/>
+ <TPM:RunFiles size="6230">
+texmf-dist/tex/latex/randtext/randtext.sty
+texmf-dist/tpm/randtext.tpm
+ </TPM:RunFiles>
+ <TPM:DocFiles size="537">texmf-dist/doc/latex/randtext/README</TPM:DocFiles>
+ <TPM:Provides>Package/randtext</TPM:Provides>
+ </rdf:Description>
+</rdf:RDF>
+
diff --git a/Master/texmf-dist/tpm/switcheml.tpm b/Master/texmf-dist/tpm/switcheml.tpm
deleted file mode 100644
index dc5ddf26afe..00000000000
--- a/Master/texmf-dist/tpm/switcheml.tpm
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE rdf:RDF SYSTEM "../../support/tpm.dtd">
-<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:TPM="http://texlive.dante.de/">
- <rdf:Description about="http://texlive.dante.de/texlive/Package/switcheml.zip">
- <TPM:Name>switcheml</TPM:Name>
- <TPM:Type>Package</TPM:Type>
- <TPM:Date>2006/01/09 00:49:07</TPM:Date>
- <TPM:Version></TPM:Version>
- <TPM:Creator>rahtz</TPM:Creator>
- <TPM:Title>Obfuscate email addresses.</TPM:Title>
- <TPM:Description>
-The package (roughly) parses an email address, and writes it out
-as a series of boxes in a jumbled order, but with positioning
-commands to make the result print correctly. This performance
-will confuse address-harvesters that look inside your PostScript
-or PDF files on the web.
-[description copied from TeX Catalogue]
- </TPM:Description>
- <TPM:Author></TPM:Author>
- <TPM:Size>3926</TPM:Size>
- <TPM:Build/>
- <TPM:RunFiles size="3685">
-texmf-dist/tex/latex/switcheml/switcheml.sty
-texmf-dist/tpm/switcheml.tpm
- </TPM:RunFiles>
- <TPM:DocFiles size="241">texmf-dist/doc/latex/switcheml/README</TPM:DocFiles>
- <TPM:Provides>Package/switcheml</TPM:Provides>
- </rdf:Description>
-</rdf:RDF>
-
diff --git a/Master/texmf/lists/randtext b/Master/texmf/lists/randtext
new file mode 100644
index 00000000000..faafa578131
--- /dev/null
+++ b/Master/texmf/lists/randtext
@@ -0,0 +1,6 @@
+texmf-dist/doc/latex/randtext/README
+
+texmf-dist/tex/latex/randtext/randtext.sty
+texmf-dist/tpm/randtext.tpm
+
+texmf/lists/randtext
diff --git a/Master/texmf/tpm/collection-latexextra.tpm b/Master/texmf/tpm/collection-latexextra.tpm
index 9c071e53781..e360de3476d 100644
--- a/Master/texmf/tpm/collection-latexextra.tpm
+++ b/Master/texmf/tpm/collection-latexextra.tpm
@@ -370,6 +370,7 @@ A large collection of add-on packages for LaTeX.
<TPM:Package name="qtree"/>
<TPM:Package name="quotchap"/>
<TPM:Package name="ragged2e"/>
+ <TPM:Package name="randtext"/>
<TPM:Package name="rccol"/>
<TPM:Package name="rcsinfo"/>
<TPM:Package name="rectopma"/>
@@ -449,7 +450,6 @@ A large collection of add-on packages for LaTeX.
<TPM:Package name="svn"/>
<TPM:Package name="svn-multi"/>
<TPM:Package name="svninfo"/>
- <TPM:Package name="switcheml"/>
<TPM:Package name="syntax"/>
<TPM:Package name="synttree"/>
<TPM:Package name="tableaux"/>