-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrules.ab
382 lines (272 loc) · 8.25 KB
/
rules.ab
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# Inline and basics
## Basic
- Italic: `_italic_` or `{_italic_}` (the second is more explicit
and covers edge cases, like `part{_italic_})`
- Strong: `*strong*` or `{*strong*}
- Verbatime / code: `` `verbatim` ``
- Highlight: {=highlighted=}
- Underline: {+underlined+}
- Delete: {-deleted-}
## Escaping characters
Characters can be escaped using `\`.
E.g. `\*not strong` will not produce a strong inline.
E.g. `\a` will just escape a, even if not needed in this context.
## Attributes
Generally, attributes can be specified with `{}`. These can have different behaviors
depending on the context.
## Horizontal rule
Horizontal rule separation (with and without white-spaces before and after), more than two consecutive '-':
`---`
-----------------
# Attributes
Most blocks and span can possess attributes, written like `{myattribute}`. Attributes
with values can be written like `{attr:value}` or `{attr=value}`. It is up to the block
or span to use these attributes or not. Multiple attributes are separated by commas `,`.
# References
## Labels and refs
It is possible to labelize items and make reference to them. To labelize anything,
simply use the attribute `{l:my label}` right after the object.
### Refs
To make references, one uses the syntax `[[my label]]` (like wiki links in Markdown).
To make references to another document, one can use `[[document#label]]. If there is
a document with the same name as a label in current document and one wishes to use the
current label, it is possible to solve the problem by specifying `[[#current label]]`
(# alone designates current document)
### Automatic enumeration
Some things that can be automatically enumerated:
- Chapters and headers
- Figures
- Tables
- Block code
- Drawings
- Citations
When ones wants to override the editor enumeration preferences, one can use the attribute
`{enum}` or `{noenum}`.
### Definitions
A paragraph *starting* with the following regex ^\[.*\]: is considered as a definition.
We can have footnotes, links, images and citation definitions.
Definitions cannot be part of another block, e.g.
```AB
>[def]: this won't be a definition
```
If one wants a definition on multiple lines, use four 4-space indentation:
```AB
[my def]: paragraph
a second paragraph
```
### Bibliography and citation
It is possible to add a bibliography element and make reference to it by simply putting
in a new line:
```AB
I want to make a citation [[c:my citation]]
[c:my citation]: Foo bar, Markup languages proceedings, Volume 2, p.45, 2022
```
If the citation is in another document, one can use the `#` notation:
```AB
I want to make a citation [[document#c:my citation]]
### Footnotes
It is also possible to do standard footnotes:
```AB
I want a footnote [[fn:foot]].
[fn:foot]: A note.
```
-----------------
# Links
```AB
<https://example.com>
A link inside [text](example.com).
Another link which is defined [later][link]
[link]: https://example.com
```
-----------------
# Media
```AB
![image.png]
![Image with title](image.png)
![Image defined later][image]
[image]: image.png
```
-----------------
# Headers
Header is a # followed by a space, with the number of # indicating the level (1-6)
```AB
# Simple header {l:with label}
```
```AB
## Second-level header
## with a second line
```
```AB
# Header
## Sub-header
```
-----------------
# Blocks
If there are more than 4 whitespaces, then everything that follows (the line) is counted as a paragraph,
except if we are in the case of a sub-list and list items.
-----------------
# Lists
Must be a list marker, preceeded by an optional space, and followed by a mandatory space.
To be still part of an item, one must align with the first char of the item.
You can have only one blank line in between.
```AB
- Item 1
Still in item 1
- Item 2
Not item item 2 (too many blank lines)
```
## List-markers
```AB
- bullet
+ bullet
* bullet
x. ordered
x) ordered
(x) ordered
x can be one of the following:
1 decimal-enumerated (limited to 999999999)
a lower alpha-enumerated (limited to zzz)
A upper alpha-enumerated (limited to ZZZ)
i lower roman-enumerated (limited to mmmcmxcix, i.e. 3999)
I upper roman-enumerated (limited to MMMCMXCIX, i.e. 3999)
```
Different type of markers in list interrupt current lists and create new lists.
```AB
- item
1. item
i. item
```
creates three different lists with each one list item.
### Ambiguous cases
If one needs to start a paragraph with a list marker, one can simply escape the first char.
```AB
\I. wanted to start a simple paragraph and not a list.
```
If another alpha-enumerated item is in the list, and the list is not interrupted in between the two
items, then it is automatically alpha-enumerated.
Example:
```AB
i. Item
j. Item
```
produces an alpha-enumerated list.
To decide between ambiguous cases (alpha or roman?), if no other list items allow for the arbitration,
then the lowest decimal equivalent enumeration wins.
Example:
```AB
i. Item
```
In this case, in roman `i` corresponds to 1 and in alpha `i` corresponds to 9,
so the list is roman-enumerated.
### Tasks
List markers can be followed by [ ], [x] or [v], thus creating tasks (empty, failed, succeeded)
## Sub-list
Lists can have lists in them (and any other blocks), which are called sublists. It is not possible
to start with sublists.
Sub-lists must have 4 spaces (or one tab) of indentation compared to the
parent list item, i.e. a sub-list must be preceeded by 4 spaces, a sub-sub-list by 8 spaces, etc.
```AB
- Item 1
a) Sub-list item
b) Sub-list item
i. Sub-sub-list item
c) Sub-list item
- Item 2
```
It is not possible to begin with a sub-list, except if it is interrupted by a blockquote:
```AB
- - Not valid, the second dash is interpreted as text
- > - Okay
```
-----------------
# Block quotes
Block Quotes:
```AB
> First level
>> Second level
```
Block quotes do not allow lazy line continuation as in Markdown.
## Mixing block quotes and list items
```AB
> - Item 1
> > Start blockquote
> > continue blockquote
> i. > - Valid list in blockquote in list in blockquote
```
-----------------
# Paragraphs
To separate paragraphs, one must insert blank lines (can be with withespace).
Paragraph have the least precedence, so they can be interrupted by any other block.
```AB
My first paragraph
My second paragraph
with a second line.
# Interrupted by a header
```
-----------------
# Code blocks
Three or more consecutive backticks can start a code block, with markup information on the first line.
The closing consecutive backticks can't contain any chars except withespace beyond the line. \\ escape
chars do not work in code blocks.
````AB
```html
<p>html code</p>
```
````
````
```html
<p>html code</p>
```a # Won't close the backticks
````
Code blocks are interrupted by the end of parents
````AB
> ```
> code block
Previous code block is interrupted by this paragraph
````
-----------------
# Latex Math
Latex maths can be produced with two consecutive $. Depending on the context, the
equation will be *inline* or *display*. Inline equations always fit on one line,
and display equations are defined by being either on multiple lines or by being
defined apart.
```AB
A paragraph can contain inline equations like $$f(x) = x^2$$ or display equations: $$f(x) = \\
x^3$$.
A display equation can be defined also like this:
$$g(x) = \sin(x)$$
$$\int \cos(x)dx$$ is not display but inline.
```
Escaping rules:
```AB
$$
I write \$$
$$
```
-----------------
# Tables
TODO
-----------------
# Special Blocks
A special block starts with three consecutive `:` followed by a name and optional attributes.
Whitespaces are ignored for the name.
The block is finished with three consecutive `:` or an interruption of a parents block.
```AB
::: name-of-block
content
:::
```
Special blocks can be inside quotes and list. A special block inside a quote or list not
closed will be closed when the parent block is closed. Special blocks cannot be nested.
Here are special blocks used by MathNotes:
## Figures
```AB
::: figure {ncols=2,nrows=3,center}
![title of my image](image.png) any text written here is ignored
![other image](image.png)
Any text written here is taken as legend
:::
```
One image per line.
It is possible to specify number of cols with the attribute ncols.
Keywords center, left, right will align the images.