Skip to content

Commit

Permalink
fix dollars not being picked up in attribute names for jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ceymard committed Dec 22, 2019
1 parent 2f49590 commit c8e9791
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['tag'].pattern = /^<\/?[^\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/dollars-in-attrs.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div $$="bar baz" />;

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

[
["tag", [
["tag", [
["punctuation", "<"],
"div"
]],
["attr-name", ["$$"]],
["attr-value", [
["punctuation", "="],
["punctuation", "\""],
"bar baz",
["punctuation", "\""]
]],
["punctuation", "/>"]
]],
["punctuation", ";"]
]

----------------------------------------------------
Checks that attribute names can contain $
No issue filed

0 comments on commit c8e9791

Please sign in to comment.