summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/trimspaces/trimspaces.sty
blob: c4b681c3bd503485ae28b90db5444e383b9ed7f7 (plain)
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
%% LaTeX2e file `trimspaces.sty'
%% generated by the `filecontents' environment
%% from source `trimspaces' on 2009/09/17.
%%
\ProvidesPackage{trimspaces}[2009/09/17 v1.1
  Trim spaces around a token list]

% Trimming surrounding spaces:
\catcode`\Q=3
\newcommand\trim@spaces[1]{%
  \romannumeral-`\q\trim@trim@\noexpand#1Q Q%
}
\long\def\trim@trim@#1 Q{\trim@trim@@#1Q}
\long\def\trim@trim@@#1Q#2{#1}
\catcode`\Q=11

\newcommand\trim@spaces@noexp[1]{%
  \unexpanded\expandafter\expandafter\expandafter
    {\trim@spaces{#1}}%
}

\newcommand\trim@spaces@in[1]{%
  \edef#1{\expandafter\trim@spaces@noexp\expandafter{#1}}%
}

% Trimming preceding spaces:
\newcommand\trim@pre@space[1]{%
  \romannumeral-`\.\expandafter\noexpand#1%
}

\newcommand\trim@pre@space@noexp[1]{%
  \unexpanded\expandafter{%
    \romannumeral-`\.\expandafter\noexpand#1%
  }%
}

\newcommand\trim@pre@space@in[1]{%
  \expandafter\def\expandafter#1\expandafter{%
    \romannumeral-`\.\expandafter\noexpand#1%
  }%
}

% Trimming trailing space:
\catcode`\Q=3
\newcommand\trim@post@space[1]{\trim@trim@#1Q Q}
\catcode`\Q=11

\newcommand\trim@post@space@noexp[1]{%
  \unexpanded\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter
    {\trim@post@space{#1}}%
}

\newcommand\trim@post@space@in[1]{%
  \edef#1{\expandafter\trim@post@space@noexp\expandafter{#1}}%
}

% That's it.