From 5f83664c2a65729309867921ba2b61c4e78dc9a7 Mon Sep 17 00:00:00 2001 From: Gusted Date: Mon, 1 Apr 2024 23:02:14 +0200 Subject: [PATCH] Vue: Handle more edge cases (#950) - The parsing of `v-` directives expected that this always ended in `">`, however it is possible that there are other attributes after an `v-` directive also it made the assumption that there couldn't be any spaces in the value of the directive. Therefore it could result in incorrect lexing where almost the whole file could be marked as an LiteralString. - Handle `-` in HTML element names. - Explicitly mark `=` as an operator token. - Tests added. - Ref: https://codeberg.org/forgejo/forgejo/issues/2945 ## Before ![Screen Shot 2024-04-01 at 13 58 18](https://github.com/alecthomas/chroma/assets/25481501/e33d87fe-7788-40ca-a3c5-bbd964b91cb5) ## After ![Screen Shot 2024-04-01 at 23 01 17](https://github.com/alecthomas/chroma/assets/25481501/b6b0fec0-6dfc-4dfe-93cd-8a7c42a05ef7) --- lexers/embedded/vue.xml | 10 ++++++---- lexers/testdata/vue.actual | 6 ++++++ lexers/testdata/vue.expected | 28 ++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/lexers/embedded/vue.xml b/lexers/embedded/vue.xml index 751802075..ec3508359 100644 --- a/lexers/embedded/vue.xml +++ b/lexers/embedded/vue.xml @@ -83,9 +83,10 @@ - + + @@ -104,9 +105,10 @@ - + + @@ -258,14 +260,14 @@ - + - + diff --git a/lexers/testdata/vue.actual b/lexers/testdata/vue.actual index 237970d7f..2ca8bdd5c 100644 --- a/lexers/testdata/vue.actual +++ b/lexers/testdata/vue.actual @@ -1,5 +1,11 @@