Skip to content

Commit

Permalink
JSX: Fix highlighting of empty objects. Fix #1364
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Mar 22, 2018
1 parent 0efd6e1 commit b26bbb8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/prism-jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var javascript = Prism.util.clone(Prism.languages.javascript);

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

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

Expand Down
2 changes: 1 addition & 1 deletion components/prism-jsx.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions tests/languages/jsx/issue1364.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<CodeView title={{}} />

----------------------------------------------------

[
["tag", [
["tag", [
["punctuation", "<"],
"CodeView"
]],
["attr-name", ["title"]],
["script", [
["script-punctuation", "="],
["punctuation", "{"],
["punctuation", "{"],
["punctuation", "}"],
["punctuation", "}"]
]],
["punctuation", "/>"]
]]
]

----------------------------------------------------

Checks for empty objects in JSX. See #1364

0 comments on commit b26bbb8

Please sign in to comment.