Skip to content

Commit b26bbb8

Browse files
committed
JSX: Fix highlighting of empty objects. Fix #1364
1 parent 0efd6e1 commit b26bbb8

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

components/prism-jsx.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var javascript = Prism.util.clone(Prism.languages.javascript);
44

55
Prism.languages.jsx = Prism.languages.extend('markup', javascript);
6-
Prism.languages.jsx.tag.pattern= /<\/?[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{[^}]+\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?>/i;
6+
Prism.languages.jsx.tag.pattern= /<\/?[\w.:-]+\s*(?:\s+(?:[\w.:-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{[^}]*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\}))*\s*\/?>/i;
77

88
Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i;
99

components/prism-jsx.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/jsx/issue1364.test

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<CodeView title={{}} />
2+
3+
----------------------------------------------------
4+
5+
[
6+
["tag", [
7+
["tag", [
8+
["punctuation", "<"],
9+
"CodeView"
10+
]],
11+
["attr-name", ["title"]],
12+
["script", [
13+
["script-punctuation", "="],
14+
["punctuation", "{"],
15+
["punctuation", "{"],
16+
["punctuation", "}"],
17+
["punctuation", "}"]
18+
]],
19+
["punctuation", "/>"]
20+
]]
21+
]
22+
23+
----------------------------------------------------
24+
25+
Checks for empty objects in JSX. See #1364

0 commit comments

Comments
 (0)