# Wasot Syntax Complete Reference

## Chapter 1: Basic Document Structure

### Line Types
- Meta-lines (start with `.`)
- Text lines (don't start with `.`)
- Empty lines (treated as text)
- Whitespace-only lines
- Comment lines (start with `#`)
- Implicit text blocks (text without preceding meta-line)

### Block Boundaries
- Explicit close with `./`
- Implicit close on same/lower level
- Implicit close at end of document
- Self-closing blocks (headings)

## Chapter 2: Meta-Line Fundamentals

### Basic MetaLine Detection
- Line starts with `.` → meta-line
- Line starts with `..` → meta-line (level 2)
- Line starts with `...` → meta-line (level 3)
- Arbitrary nesting levels (tested up to 1000 dots)
- Empty line → not meta-line
- Line without leading dot → not meta-line
- Line with whitespace before dot → not meta-line
- Line with dot in middle → not meta-line
- Just a single dot `.` → meta-line

### Block Nesting
- Root level block (level 0 implicit)
- Single nesting: `.outer` → `..inner`
- Deep nesting: `.` → `..` → `...` → `....`
- Arbitrary deep nesting (1000+ levels)
- Mixed levels: `.` → `...` (skip level 2)

## Chapter 3: Block Types

### Simple Block Types
- Simple type: `.div`
- Type with numbers: `.h1`, `.block123`
- Type with special chars: `.type-name`, `.type_name`
- Type starting with number: `.123class`

### Special Block Types
- Regular blocks: `.div`, `.p`, `.span`
- Heading blocks: `.#`, `.##`, `.###`
- Heading with type suffix: `.# chapter`
- Self-closing blocks: `.#` with inline text
- Empty type blocks: `.`, `..` (become headings)

### Quoted Block Types
- Quoted type: `."block type"`
- Quoted type with spaces: `."my block type"`
- Quoted type with escaped quotes: `."type \"quoted\""`
- Unclosed quoted type: `."unclosed`

### Unicode and Special Characters in Types
- Type with Unicode: `.日本語`, `.émojis👨‍👩‍👧‍👦`
- Type with control chars: `.type\0name`, `.type\x01\x02`

## Chapter 4: Inline Text

### Basic Inline Text
- No inline text: `.div`
- Unquoted inline text: `.div some text`
- Empty inline text before params: `.div .. params`
- Whitespace-only inline text: `.div    .. params`
- Very long inline text (10MB tested)

### Quoted Inline Text
- Quoted inline text: `.div "quoted text"`
- Inline text with quotes inside: `.div text with "quotes" inside`
- Inline text quoted from start: `.div "text from start`
- Inline text with escaped quotes: `.div "text \"escaped\""`

### Special Cases
- Inline text with Unicode/emoji: `.div 日本語 👨‍👩‍👧‍👦`
- Inline text with dots: `.div text with .. dots`

## Chapter 5: Parameters and Arguments

### Parameter Separator
- No parameters: `.div text`
- Empty params: `.div text ..`
- Parameters only: `.div .. params`
- Multiple separators: `.div text .. p1 .. p2`
- Separator in quotes: `.div "text .. with dots" .. params`
- Mixed dots: `.div .. .. .. .. text`

### Positional Arguments
- Single arg: `arg1`
- Multiple args: `arg1 arg2 arg3`
- Quoted args: `"arg with spaces"`
- Mixed quoted/unquoted: `arg1 "arg 2" arg3`
- Args with special chars: `@#$%^&*()`
- Empty quoted arg: `""`
- Args with equals but no value: `arg=`

### Keyword Arguments
- Simple kwarg: `key=value`
- Quoted key: `"my key"=value`
- Quoted value: `key="my value"`
- Both quoted: `"my key"="my value"`
- Special chars in value: `key=@#$%^&*()`
- Empty value: `key=""`
- Multiple equals: `key=val=ue`
- Unicode in keys/values: `キー=値`

### Mixed Arguments
- Args before kwargs: `arg1 arg2 key=val`
- Interspersed: `arg1 key1=val1 arg2 key2=val2`
- Complex quotes: `"arg 1" key="val 1" "key 2"="val 2"`

## Chapter 6: Block IDs

### ID Syntax
- No ID: `.div`
- Simple ID: `.div :myid`
- ID with dots: `.div :section.subsection`
- ID with numbers: `.div :id123`
- ID with dashes/underscores: `.div :my-id_123`
- ID starting with number: `.div :123id`
- Multiple colons in ID: `.div :namespace:id`

### ID Placement
- ID with inline text: `.div text :id`
- ID with params: `.div .. params :id`
- ID with everything: `.div text .. params :id`
- Empty ID: `.div :`

### Unicode IDs
- ID with Unicode: `.div :日本語id`

### ID Assignment
- Explicit IDs with `:syntax`
- Auto-generated IDs (base36)
- ID uniqueness not enforced
- IDs on any block type

## Chapter 7: Complete MetaLine Combinations

### Basic Combinations
- Type only: `.div`
- Type + inline: `.div text`
- Type + params: `.div .. params`
- Type + ID: `.div :id`

### Advanced Combinations
- Type + inline + params: `.div text .. params`
- Type + inline + ID: `.div text :id`
- Type + params + ID: `.div .. params :id`
- Type + inline + params + ID: `.div text .. params :id`
- Everything quoted: `."type" "inline" .. "arg" "key"="val" :id`

## Chapter 8: Text Content

### Basic Text
- Single line text
- Multi-line text
- Empty text block
- Text with leading/trailing whitespace
- Very long lines (10MB tested)

### Block Children
- Block with no children
- Block with text children only
- Block with block children only
- Block with mixed text/block children
- Adjacent text lines (merged into single Text)
- Non-adjacent text lines (separate Text elements)

## Chapter 9: Links in Text

### Basic Links
- No links
- URL links: `((http://example.com))`
- Named links: `((name|http://example.com))`
- ID links: `((:section-id))`
- Footnote links: `((#))`

### Advanced Links
- Links with args: `((url .. arg key=val))`
- Multiple links per line
- Nested parentheses: `((text with )) inside))`
- Quoted content in links: `(("quoted content"))`
- Escaped quotes in links: `((text \"escaped\"))`
- Unclosed links: `((unclosed`

## Chapter 10: Footnotes

### Footnote Syntax
- Footnote marker: `*1 http://example.com`
- Multiple footnotes: `*1`, `*2`, `*3`
- Footnote with spaces: `*1    http://example.com`

### Invalid Footnotes
- Invalid footnote (no number): `* text`
- Invalid footnote (no space): `*1text`

## Chapter 11: Quote and Escape Handling

### Quote Handling
- Unclosed quotes at end of line
- Mismatched quote types: `"text'`
- Multiple quote levels: `"outer "inner" outer"`
- Escaped quotes: `\"`, `\"`
- Escaped backslashes: `\\`
- Quotes in different contexts (type, inline, args)

### Escape Sequences
- In quoted strings: `\"`, `\\`
- In unquoted context: treated literally
- Double escape: `\\\"`, `\\\\`
- Invalid escapes: `\n`, `\t` (kept as-is)

## Chapter 12: Unicode and Special Characters

### Unicode Support
- Zero-width characters: `\u{200B}`, `\u{200C}`
- Right-to-left text
- Emoji with modifiers
- Combining characters
- Various scripts (CJK, Arabic, Hebrew)

### Special Characters
- Control characters: `\0`, `\x01`, `\x07`
- Mathematical symbols

## Chapter 13: Parser Internals

### Tokenization
- Space-separated tokens
- Quoted tokens with spaces
- Empty tokens between spaces
- Tokens with equals signs
- Mixed quoted/unquoted

### Quote-Aware Tokenizer
- Handles nested quotes correctly
- Preserves quotes in output
- Handles escaped quotes
- Unclosed quotes fallback

### Equals Tokenizer
- Splits on first `=` outside quotes
- Handles `key=value=more`
- Handles quoted keys/values
- No equals → single token

## Chapter 14: Edge Cases and Limits

### Parser Resilience ("Honey Badger")
- 10MB single line
- 1000+ nesting levels
- Null bytes in content
- Mixed valid/invalid syntax
- Extreme repetition patterns
- Memory stress patterns

### Ambiguous Cases
- `.div .. .. .. ..` → first `..` is separator, rest are params
- `."unclosed quote text` → treated as regular type parsing
- `.type :multiple :colons` → only last `:id` pattern extracted
- Empty components: `."" "" .. "" ""="" :`

### Performance Boundaries
- Line length limits (tested to 10MB)
- Nesting depth (no practical limit)
- Number of arguments (no limit)
- Number of children per block (no limit)
- File size (streaming parser handles any size)