import HelderCore import Testing @Suite struct MarkupGrammarTests { @Test("tags, attributes, values and entities") func basics() { let text = "" #expect(paintedRuns(text, .markup) == [ "a:number", "href:variable", "\"/x\":string", "data-id:variable", "1:string", "hidden:variable", "&:variable", "a:number", ]) } @Test("comments, doctype and CDATA read as comments") func comments() { let text = "\n\n\n

" #expect(role("", in: text, .markup) == .comment) #expect(role(" b -->", in: text, .markup) == .comment) #expect(role("", in: text, .markup) == .comment) #expect(role("p", in: text, .markup) == .number) } @Test("a script body is JavaScript and a style body is CSS") func embedded() { let text = "\n\n

const

" #expect(role("const", in: text, .markup) == .keyword) #expect(role("// c", in: text, .markup) == .comment) #expect(role("script", in: text, .markup, occurrence: 1) == .number) #expect(role(".b", in: text, .markup) == .number) #expect(role("color", in: text, .markup) == .variable) #expect(role("const", in: text, .markup, occurrence: 1) == .plain) } @Test("a JavaScript line comment stops at the closing script tag") func scriptCloseInsideComment() { let text = "

" #expect(role("// x", in: text, .markup) == .comment) #expect(role("p", in: text, .markup) == .number) } @Test("a tag may wrap over lines, with a value that wraps too") func multiLineTag() { let text = "\nafter" #expect(role(" b\"", in: text, .markup) == .string) #expect(role("src", in: text, .markup) == .variable) #expect(role("after", in: text, .markup) == .plain) } @Test("Vue single-file components read their script block") func vue() { let text = "\n" #expect(role(":class", in: text, .markup) == .variable) #expect(role("@click", in: text, .markup) == .variable) #expect(role("import", in: text, .markup) == .keyword) } }