1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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
|