From 6c1e333c1992049b685369a5bac20fd9fca69959 Mon Sep 17 00:00:00 2001 From: Aditya Date: Thu, 10 Sep 2026 09:31:11 +0530 Subject: [PATCH] Fix XML empty-tag highlighting --- runtime/syntax/xml.yaml | 2 +- runtime/syntax_test.go | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 runtime/syntax_test.go diff --git a/runtime/syntax/xml.yaml b/runtime/syntax/xml.yaml index df4cde8118..ca37a37342 100644 --- a/runtime/syntax/xml.yaml +++ b/runtime/syntax/xml.yaml @@ -20,7 +20,7 @@ rules: end: "\\??>" rules: - identifier: - start: " " + start: '[ \t][:A-Z_a-z\x{C0}-\x{D6}\x{D8}-\x{F6}\x{F8}-\x{2FF}\x{370}-\x{37D}\x{37F}-\x{1FFF}\x{200C}-\x{200D}\x{2070}-\x{218F}\x{2C00}-\x{2FEF}\x{3001}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFFD}\x{10000}-\x{EFFFF}]' end: "=" rules: [] - constant.string: diff --git a/runtime/syntax_test.go b/runtime/syntax_test.go new file mode 100644 index 0000000000..b6a34f3ade --- /dev/null +++ b/runtime/syntax_test.go @@ -0,0 +1,27 @@ +package config + +import ( + "testing" + + "github.com/micro-editor/micro/v2/pkg/highlight" +) + +func TestXMLEmptyTagWithSpace(t *testing.T) { + data, err := Asset("syntax/xml.yaml") + if err != nil { + t.Fatal(err) + } + file, err := highlight.ParseFile(data) + if err != nil { + t.Fatal(err) + } + def, err := highlight.ParseDef(file, nil) + if err != nil { + t.Fatal(err) + } + + matches := highlight.NewHighlighter(def).HighlightString("\nplain") + if group := matches[1][0]; group != 0 { + t.Fatalf("text after empty tag highlighted as %q", group) + } +}