fix: Empty tags now report diagnostics.

This commit is contained in:
Spencer Brower
2026-08-10 17:42:43 -04:00
parent 3551eb3b2c
commit a9d7525dd6
3 changed files with 35 additions and 1 deletions
+14 -1
View File
@@ -130,7 +130,7 @@ input: |
</footer> </footer>
expected: | expected: |
Empty tag Empty tag
--> <test>:11:28 --> <test>:11:28
| |
9 | href="https://edwardtufte.github.io/tufte-css/">Tufte CSS</a> 9 | href="https://edwardtufte.github.io/tufte-css/">Tufte CSS</a>
10 | </p> 10 | </p>
@@ -139,6 +139,19 @@ expected: |
12 | </footer> 12 | </footer>
| |
--- ---
name: empty raw tag
enable: true
should: error
input: |
Hello, {{&}}
expected: |
Empty tag
--> <test>:1:8
|
1 | Hello, {{&}}
| ^^^^^ tag must contain a key
|
---
name: Missing pipe arguement name: Missing pipe arguement
enable: true enable: true
should: error should: error
+5
View File
@@ -28,6 +28,11 @@ test_diag_empty_tag :: proc(t: ^testing.T) {
run_diag_case(t, "empty tag") run_diag_case(t, "empty tag")
} }
@(test)
test_diag_empty_raw_tag :: proc(t: ^testing.T) {
run_diag_case(t, "empty raw tag")
}
@(test) @(test)
test_diag_missing_pipe_arguement :: proc(t: ^testing.T) { test_diag_missing_pipe_arguement :: proc(t: ^testing.T) {
run_diag_case(t, "Missing pipe arguement") run_diag_case(t, "Missing pipe arguement")
+16
View File
@@ -271,6 +271,14 @@ parse_section :: proc(
pos^ += 1 pos^ += 1
case .Variable: case .Variable:
if len(strings.trim_space(tok.value)) == 0 {
return Error_Body {
msg = "Empty tag",
pos = tok.pos,
kind = .Syntax,
hint = "tag must contain a key",
}
}
idx := len(nodes) idx := len(nodes)
append(nodes, Node{kind = .Variable}) append(nodes, Node{kind = .Variable})
pipe_key, perr := parse_pipeline( pipe_key, perr := parse_pipeline(
@@ -290,6 +298,14 @@ parse_section :: proc(
pos^ += 1 pos^ += 1
case .Unescaped: case .Unescaped:
if len(strings.trim_space(tok.value)) == 0 {
return Error_Body {
msg = "Empty tag",
pos = tok.pos,
kind = .Syntax,
hint = "tag must contain a key",
}
}
idx := len(nodes) idx := len(nodes)
append(nodes, Node{kind = .Unescaped}) append(nodes, Node{kind = .Unescaped})
pipe_key, perr := parse_pipeline( pipe_key, perr := parse_pipeline(