# ID with Dots Test Failures - Code Change Locations

**Date:** 2026-02-07
**Issue:** 2 syntax tests fail because they expect dots to be allowed in IDs, but the parser intentionally disallows them.

## Quick Summary

| Test | Status | Root Cause |
|------|--------|------------|
| `id_with_dots` | ❌ FAIL | Dots not allowed in IDs |
| `id_with_dots_for_namespacing` | ❌ FAIL | Dots not allowed in IDs |

---

## Option A: Fix the Test Expectations (Recommended)

Update the test file to match actual behavior. Dots in `:id` syntax are treated as inline text.

### Files to Change

#### 1. `tests/wasot_syntax_tests.md:465-482`

**Current (incorrect):**
```yaml
**ID with dots**

Test IDs that contain dots for namespacing.

```wasot
.div :page.header.logo
Logo content here.
```

```yaml
- block-started:
    type: div
    level: 1
    id: page.header.logo
- text-finished:
    lines: ["Logo content here."]
- block-finished
```
```

**Change to:**
```yaml
**ID with dots treated as inline text**

Test that IDs containing dots are not parsed as IDs (dots reserved for document references).

```wasot
.div :page.header.logo
Logo content here.
```

```yaml
- block-started:
    type: div
    level: 1
    inline-text: ":page.header.logo"
- text-finished:
    lines: ["Logo content here."]
- block-finished
```
```

#### 2. `tests/wasot_syntax_tests.md:1497-1514`

**Current (incorrect):**
```yaml
**ID with dots for namespacing**

Test IDs that contain dots for namespacing.

```wasot
.div :docid.id
Content here.
```

```yaml
- block-started:
    type: div
    level: 1
    id: "docid.id"
- text-finished:
    lines: ["Content here."]
- block-finished
```
```

**Change to:**
```yaml
**Dotted ID syntax treated as inline text**

Test that dotted ID syntax is treated as inline text since dots are reserved for document references.

```wasot
.div :docid.id
Content here.
```

```yaml
- block-started:
    type: div
    level: 1
    inline-text: ":docid.id"
- text-finished:
    lines: ["Content here."]
- block-finished
```
```

---

## Option B: Allow Dots in IDs (Not Recommended)

If you want to allow dots in IDs, you'll need to modify the ID extraction regex.

### Files to Change

#### 1. `src/parsers/wasot/parser.rs:196-199`

**Current:**
```rust
// Pattern matches: whitespace + colon + letters (including Unicode)/numbers/dashes/underscores/colons
// Updated to support Unicode characters, uppercase letters, and starting with digits
// Note: dots are NOT allowed in IDs (reserved for document.local-id references)
let pattern = r"\s:[A-Za-z0-9\-_:\p{L}]+\s*$";
```

**Change to:**
```rust
// Pattern matches: whitespace + colon + letters/numbers/dashes/underscores/colons/dots
// WARNING: This may conflict with document.local-id reference syntax
let pattern = r"\s:[A-Za-z0-9\-_:.\p{L}]+\s*$";
```

#### 2. `src/parsers/wasot/parser.rs:1801-1808`

**Remove or update this test:**
```rust
#[test]
fn test_ids_no_longer_allow_dots() {
    // IDs with dots should NOT be extracted (dots reserved for document references)
    let (id, cleaned) = extract_id_string(".div text :has.dot");
    // The regex won't match because dots aren't allowed
    assert_eq!(id, "");
    assert_eq!(cleaned, ".div text :has.dot");
}
```

### ⚠️ Warning for Option B

Allowing dots in IDs would break the **document reference** feature. The syntax `document-name.local-id` is used for cross-document linking:

```wasot
.link [See other doc](#other-doc.section-id)
```

If dots are allowed in regular IDs, the parser can't distinguish between:
- A local ID: `:page.header.logo` (one ID with dots)
- A document reference: `other-doc.section-id` (document name + local ID)

---

## Option C: Use Different Separator for Namespacing

Change the test inputs to use dashes or underscores instead of dots.

### Files to Change

#### 1. `tests/wasot_syntax_tests.md:465-482`

Change input from:
```wasot
.div :page.header.logo
```

To:
```wasot
.div :page-header-logo
```

And update expected output accordingly.

#### 2. `tests/wasot_syntax_tests.md:1497-1514`

Change input from:
```wasot
.div :docid.id
```

To:
```wasot
.div :docid-id
```

---

## Verification Commands

```bash
# Verify dots are not allowed in IDs
echo '.div :page.header.logo' | cargo run --bin wasot -- -t jsonl 2>/dev/null | jq '.meta_line | {id: .id.value, inline_text: .inline_text.content}'
# Expected: {"id":"1","inline_text":":page.header.logo"}

# Verify dashes work in IDs
echo '.div :page-header-logo' | cargo run --bin wasot -- -t jsonl 2>/dev/null | jq '.meta_line | {id: .id.value, inline_text: .inline_text.content}'
# Expected: {"id":"page-header-logo","inline_text":""}

# Verify underscores work in IDs
echo '.div :page_header_logo' | cargo run --bin wasot -- -t jsonl 2>/dev/null | jq '.meta_line | {id: .id.value, inline_text: .inline_text.content}'
# Expected: {"id":"page_header_logo","inline_text":""}
```

---

## Recommendation

**Use Option A** - update the test expectations. The current behavior is intentional and documented in the codebase. The tests are simply out of date with the actual design decision.

After making changes, regenerate and run tests:
```bash
./scripts/test_syntax.sh
```
