blob: 13f0b9a7139fdfdb700d4fe8b021387e90acdf4c (
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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
%%
%% This is file `catchfilebetweentags.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% catchfilebetweentags.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% catchfilebetweentags : 2011/02/19 v1.1 - catchfilebetweentags : catch file between delimiters or tags
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 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
%%
%% This work consists of the main source file catchfilebetweentags.dtx
%% and the derived files
%% catchfilebetweentags.sty, catchfilebetweentags.pdf, catchfilebetweentags.ins,
%%
%% catchfilebetweentags : catchfilebetweentags : a new dimen corresponding to the remainder of the line
%% Copyright (C) 2010 by Florent Chervet <florent.chervet@free.fr>
%%
\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
[2005/12/01]% LaTeX must be 2005/12/01 or younger
\ProvidesPackage{catchfilebetweentags}
[2011/02/19 v1.1 - Catch file between tags (FC)]
\RequirePackage{etex,etoolbox,ltxcmds}
\RequirePackage{catchfile}
\globtoks\CatchFBT@tok
\newrobustcmd*\CatchFileBetweenDelims[4]{%
\begingroup
\edef\CatchFileBetweenDelims{\endgroup
\noexpand\@testopt
{\CatchFBT@Work{\noexpand#1}{#2}{#3}{#4}}
{\noexpand\makeatletter}%
}\CatchFileBetweenDelims
}% \CatchFileBetweenDelims
\newcommand\CatchFileBetweenTags{}
\begingroup
\@makeother\<%
\@makeother\>%
\@makeother\*%
\catcode`\: 14%
\@makeother\%:
\gdef\CatchFileBetweenTags#1#2#3{:
\CatchFileBetweenDelims\CatchFBT@tok{#2}{%<*#3>}{%</#3>}[\CatchFBT@sanitize]:
\CatchFBT@Final{#1}:
}:% \CatchFileBetweenTags
\endgroup
\newrobustcmd*\ExecuteMetaData[2][\jobname]{%
\CatchFileBetweenTags\CatchFBT@tok{#1}{#2}%
\global\expandafter\CatchFBT@tok\expandafter{%
\expandafter}\the\CatchFBT@tok
}% \ExecuteMetaData
\long\protected\def\CatchFBT@Work#1#2#3#4[#5]{%
\def\CatchFBT@setup{#5%
\long\def\CatchFile@Do####1#3{\CatchFBT@catchthepart}% discard before start-delim
\long\edef\CatchFBT@catchthepart####1#4{% capture until end-delim
\CatchFBT@tok{\endgroup
\CatchFBT@IsAToken#1
{\global\noexpand#1{####1}}
{\xdef\noexpand#1{\noexpand\unexpanded{####1}}}}%
\noexpand\CatchFBT@discardtherest}%
\long\expandafter\def
\expandafter\CatchFBT@discardtherest
\expandafter####\expandafter1\CatchFile@EOF{}%
\everyeof{#3#4}%
\everyeof\expandafter\expandafter\expandafter{%
\expandafter\the\expandafter\everyeof\CatchFile@EOF
\expandafter\the\expandafter\CatchFBT@tok\noexpand}}%
\CatchFileDef#1{#2}\CatchFBT@setup
}% \CatchFBT@Work
\def\CatchFBT@sanitize{%
\@sanitize
\@makeother\{%
\@makeother\}%
\endlinechar=`\^^J%
}% \CatchFBT@sanitize
\newrobustcmd*\CatchFBT@Final[1]{\@testopt
{\CatchFBT@Fin@l{#1}}{}%
}% \CatchFBT@Final
\def\CatchFBT@Fin@l#1[#2]{%
\begingroup
\endlinechar\m@ne \makeatletter #2%
\scantokens\expandafter{%
\expandafter\CatchFBT@tok\expandafter{\the\CatchFBT@tok}}%
\CatchFBT@IsAToken{#1}
{\global#1\expandafter{\the\CatchFBT@tok}}
{\xdef#1{\the\CatchFBT@tok}}%
\ifx\CatchFBT@tok#1\else\global\CatchFBT@tok{}\fi
\endgroup
}% \CatchFBT@Final
\def\CatchFBT@IsAToken#1{%
\expandafter\expandafter
\expandafter\CatchFBT@Is@Token
\expandafter\meaning\expandafter#1\string\toks
\\\\{first}{second}\\\\%
}% \CatchFBT@IsAToken
\expandafter\def\expandafter\CatchFBT@Is@Token
\expandafter#\expandafter1\string\toks#2#3\\#4#5#6\\\\{%
\csname ltx@%
\if\relax\detokenize{#1}\relax#5%
\else second\fi oftwo%
\endcsname
}% \CatchFBT@Is@Token
\endinput
%%
%% End of file `catchfilebetweentags.sty'.
|