restores Helder in all its glory

This commit is contained in:
2026-09-28 11:34:49 +02:00
parent c2b38b853c
commit 1d29d0952d
280 changed files with 29205 additions and 7 deletions
@@ -0,0 +1,50 @@
import HelderCore
import Testing
@Suite struct MarkdownGrammarTests {
@Test("headings read as keywords")
func headings() {
#expect(role("## Title", in: "## Title\ntext", .markdown) == .keyword)
#expect(role("#hashtag", in: "#hashtag", .markdown) == .plain)
}
@Test("a fenced block is highlighted in its own language and closes on its fence")
func fencedCode() {
let text = "```php\n$x = new Agent();\n```\nafter $x"
#expect(role("```php", in: text, .markdown) == .comment)
#expect(role("$x", in: text, .markdown) == .variable)
#expect(role("new", in: text, .markdown) == .keyword)
#expect(role("$x", in: text, .markdown, occurrence: 1) == .plain)
}
@Test("a fence in an unknown language stays plain")
func unknownFence() {
let text = "~~~text\nif x\n~~~"
#expect(role("if x", in: text, .markdown) == .plain)
}
@Test("a fenced block comment carries over lines inside the fence")
func fenceCarriesState() {
let text = "```js\n/* a\nb */ let c\n```"
#expect(role("b */", in: text, .markdown) == .comment)
#expect(role("let", in: text, .markdown) == .keyword)
}
@Test("inline code, link targets and autolinks")
func inline() {
let text = "Use `npm test` and [docs](https://x.test) or <https://y.test>."
#expect(role("`npm test`", in: text, .markdown) == .keyword)
#expect(role("(https://x.test)", in: text, .markdown) == .variable)
#expect(role("docs", in: text, .markdown) == .plain)
#expect(role("<https://y.test>", in: text, .markdown) == .variable)
}
@Test("list markers, quotes and rules read as punctuation")
func punctuation() {
let text = "- one\n1. two\n> quote\n---"
#expect(role("-", in: text, .markdown) == .comment)
#expect(role("1.", in: text, .markdown) == .comment)
#expect(role(">", in: text, .markdown) == .comment)
#expect(role("---", in: text, .markdown) == .comment)
}
}