Joel Grunbaum
2021-08-12 e8ea5e907ca1fb359d5dd342e505a78bab42d879
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
#+TITLE:Spec for syntax tree
 
* Tree components
- Document :: Root of AST, contains metadata of title, date, author
- Block :: Paragraph level
- Table :: 
- Line :: Main component of Block
- Code :: Contains text and language
- Heading :: Contains level and words
- List :: Contains level, number and words. If number=0, list is unordered
- Word :: Token of text
- Text :: String single word
- MathDisp :: Display level math
- MathInline :: Inline level math
- Bold :: Bold text, can have multiple words
- Italic :: Italic text, can have multiple words
- Verbatim :: Verbatim text, can have multiple words
- Link :: Link to other place, containing link text and link destination
 
Document: Block*
Block: Table | Word* | Code
Table: Word* (2d array)
Code: Straight strings
# Line: Heading | List | Word* | MathDisp
Word: MathInline | Link | Format | Heading | List | MathDisp
Format: Bold | Italic | Verbatim | Text | Underline | Strikethrough
Italic: Format
Bold: Format
Verbatim: Format
Link: Text
Heading: Word*
List: Word*
 
 
* Language features and syntax
** Org
*** Document
Title is ~#+TITLE: [Text]~.
Author is ~#+AUTHOR: [Text]~.
Date is ~#+DATE: [Text]~.
*** Block
Block are defined by empty/blank lines.
*** Table
Tables are formatted with vertical pipes separating columns.
There may be formatting around boxes of -----.
*** Code
Code blocks are defined by ~#BEGIN_SRC [language]~ and ~#END_SRC~.
There are lines of text in between.
*** Heading
Heading levels are denoted by the number of '*' beginning the line.
REGEX: ~\** [[:TEXT:]]~.
*** List
List level is denoted by half the number of spaces at the start of the line.
The list number is #[.)] or if unordered [-+].
ORDERED REGEX: ~[ ]*[[:DIGIT:]]*[.)]~.
UNORDERED REGEX: ~[ ]*[-+]~.
*** Math
Display math is denoted between ~$$ $$~ or ~\[ \]~.
Inline math is ~$ $~.
*** Formatting
Italic is between ~/ /~.
Bold is between ~* *~.
Verbatim is between ~\~ \~~.
Strikethrough is ~+ +~.
Underline is ~_ _~.
*** Link
Links are ~[[destination][text]]~.
*** Comments
Comments begin with have the regex "^# " and can be omitted.