summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-13 00:08:20 +0000
committerKarl Berry <karl@freefriends.org>2006-01-13 00:08:20 +0000
commite1b890824f824f3aa08f3e3be990bc42f194b2cf (patch)
tree02af62684d7bd5feebb85450d5095bb9781008b7 /Master/texmf-dist/tex/latex
parent5dde6ace26ea26052fbcb74f63d3c10df9996f41 (diff)
switcheml
git-svn-id: svn://tug.org/texlive/trunk@1363 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/switcheml/switcheml.sty90
1 files changed, 90 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/switcheml/switcheml.sty b/Master/texmf-dist/tex/latex/switcheml/switcheml.sty
new file mode 100644
index 00000000000..fb409929a0d
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/switcheml/switcheml.sty
@@ -0,0 +1,90 @@
+%
+% 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