Skip to content

Commit d5d555c

Browse files
committed
Allow JSX Elements that begin with 0-9 or _ to be correctly highlighted
Previously highlighting would only work for elements named [a-zA-Z]. This allows for numbers and _ as well.
1 parent 2e4925a commit d5d555c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rc/filetype/javascript.kak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ define-command -hidden init-javascript-filetype -params 1 %~
169169
add-highlighter "shared/%arg{1}/shebang" region ^#! $ fill meta
170170
add-highlighter "shared/%arg{1}/division" region '[\w\)\]]\K(/|(\h+/\s+))' '(?=\w)' group # Help Kakoune to better detect /…/ literals
171171
add-highlighter "shared/%arg{1}/regex" region / (?<!\\)(\\\\)*/[gimuy]* fill meta
172-
add-highlighter "shared/%arg{1}/jsx" region -recurse (?<![\w<])<[a-zA-Z>][\w:.-]* (?<![\w<])<[a-zA-Z>][\w:.-]*(?!\hextends)(?=[\s/>])(?!>\()) (</.*?>|/>) regions
172+
add-highlighter "shared/%arg{1}/jsx" region -recurse (?<![\w<])<[\w>][\w:.-]* (?<![\w<])<[\w>][\w:.-]*(?!\hextends)(?=[\s/>])(?!>\()) (</.*?>|/>) regions
173173

174174
# Regular expression flags are: g → global match, i → ignore case, m → multi-lines, u → unicode, y → sticky
175175
# https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
@@ -186,7 +186,7 @@ define-command -hidden init-javascript-filetype -params 1 %~
186186
# We inline a small XML highlighter here since it anyway need to recurse back up to the starting highlighter.
187187
# To make things simple we assume that jsx is always enabled.
188188

189-
add-highlighter "shared/%arg{1}/jsx/tag" region -recurse < <(?=[/a-zA-Z>]) (?<!=)> regions
189+
add-highlighter "shared/%arg{1}/jsx/tag" region -recurse < <(?=[/\w>]) (?<!=)> regions
190190
add-highlighter "shared/%arg{1}/jsx/expr" region -recurse \{ \{ \} ref %arg{1}
191191

192192
add-highlighter "shared/%arg{1}/jsx/tag/base" default-region group

0 commit comments

Comments
 (0)