You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/why-djot.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,54 @@ Markdown was designed in 2004 as a simple format for writing blog posts. Twenty
10
10
2.**Ambiguous syntax** - `_` and `*` behave differently based on context
11
11
3.**Limited features** - no highlighting, attributes, or consistent extensions
12
12
4.**HTML dependency** - raw HTML is the escape hatch for everything
13
+
5.**Complex parsing** - requires backtracking and lookahead
14
+
15
+
## Parser Design: No Backtracking
16
+
17
+
One of Djot's most significant technical advantages is its parser design.
18
+
19
+
### The Markdown Parsing Problem
20
+
21
+
Markdown requires **backtracking** - the parser must sometimes go back and reinterpret what it already parsed. Consider:
22
+
23
+
```markdown
24
+
*foo *bar* baz*
25
+
```
26
+
27
+
A Markdown parser sees `*foo ` and thinks "this might be emphasis." It continues, finds `*bar*` (definitely emphasis), then hits `baz*`. Now it must decide: is the outer `*...*` emphasis too?
28
+
29
+
The parser has to backtrack and try different interpretations. This leads to:
30
+
31
+
-**Unpredictable results** - different parsers make different choices
32
+
-**Performance costs** - worst-case exponential time complexity
33
+
-**Edge case bugs** - complex nesting creates surprising output
34
+
35
+
### Djot's Solution
36
+
37
+
Djot was designed from the ground up to parse **without backtracking**:
38
+
39
+
-`*` always means strong, `_` always means emphasis
40
+
- Delimiters must be "matched" - `*foo*` works, `*foo _bar* baz_` doesn't cross
41
+
- The parser never needs to reconsider previous decisions
0 commit comments