-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
147 lines (92 loc) · 3.8 KB
/
README
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
Antelatex
=========
This software is a pre-processor for TeX/LaTeX.
Please read the LICENSE file before using this software.
Prerequisites:
==============
- ocaml (any version will do)
Compilation:
============
$ make all
This should build both the native and the byte-code version of the
executable.
Installation:
=============
$ make install
This should install the native-code executable file in the appropriate
place (/usr/local/bin by default).
$ make install-byte
This installs the bytecode version of the executable.
$ make install BINDIR=~/bin
This overrides the default installation directory.
Usage:
======
$ antelatex -g grammar.gra myfile.ant
This calls antelatex on a file called myfile.ant. It uses the grammar
definition in grammar.gra to process myfile.ant and produce a file called
myfile.tex.
Grammar file syntax:
====================
Grammar files are text files that define the substitutions that should be
applied within some sets of delimiters.
A simple first line of a grammar file can be:
Delimiters:{{[[}{]]}{$}{$}}
The braces are separators, and within the braces are the delimiters. In
this case, the grammar declares that the substitutions that are to follow
should be applied within double brackets [[ and ]] and that the result of
the substitution should appear in the TeX file between $ and $. The keyword
"Delimiters:" is optional.
The delimiters should always be 2 characters long. In the same line it is
possible to declare several delimiters for the same set of substitutions,
as in:
{{[[}{]]}{$}{$}}{{<[}{]>}{}{}}
This declaration defines the delimiters [[ ]] and <[ ]> such that [[ ]]
introduces the math mode while <[ ]> does not.
Following the delimiters declaration, there should be a number of
substitutions. Each substitution definition takes exactly one line, of the
form:
0 {alpha} = \alpha
where 0 is the arity, 'alpha' the sequence of characters (between curly
braces) to by substituted and '\alpha' (anything after the '=' and before
the end of line) what it should be substituted to.
2 {-->} = \xlongarrow{#1}_{#2}
When the arity is more than 0, the arguments are substituted in the
positions materialised by #1, #2, ... The arity is optional and can be
automatically detected. It is thus possible to only write:
{alpha} = \alpha
The following special characters cannot appear on the left-hand side of
these substitution definitions:
{ } [ ] ( )
The following characters cannot be in a word to be substituted unless that
word has no alpha-numerical characters:
, . ; *
These symbols are interpreted literally by antelatex, except for the curly
braces { and }, which are used for grouping.
No restriction exist on the right-hand side, meaning that, for example, the
following substitution is allowed:
1 {-->^} = \rightarrow^{#1}
Tex file syntax:
================
Antelatex applies the substitutions in certain delimited parts of a text
files.
Suppose a file contains the following line:
We know that [[1 plus 1]] is equal to <[two]>.
if the grammar file contains the following definitions:
Delimiters:{{[[}{]]}{$}{$}}{{<[}{]>}{}{}}
{plus} = +
{two} = 2
Then antelatex will produce a file containing the line:
We know that $1 + 1$ is equal to 2.
Notice that the double brackets [[ ]] introduce the dollar signs of the
math mode. This is the only difference between the two delimiters in this
case.
It is important to define in the grammar all the syntactic elements that
appear within the delimiters. Only the numbers, and a few characters ('[ ]
( ) , . ; *' are automatically defined.
Within the delimiters, the use of double quotes tells antelatex not to
interpret a chunk of text. Antelatex surrounds that bit with \mbox.
[[2 "is" 2]]
is translated in
$2 \mbox{is} 2$
Within the delimiters, portions that are within (* and *) are considered
as comments and are not substituted.