Skip to content

Commit

Permalink
Handle self-closing tags with spaces in JSX
Browse files Browse the repository at this point in the history
  • Loading branch information
isagalaev committed Mar 31, 2016
1 parent 61d8880 commit 5c0bdf8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/languages/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function(hljs) {
begin: /</, end: /(\/\w+|\w+\/)>/,
subLanguage: 'xml',
contains: [
{begin: /<\w+\/>/, skip: true},
{begin: /<\w+\s*\/>/, skip: true},
{begin: /<\w+/, end: /(\/\w+|\w+\/)>/, skip: true, contains: ['self']}
]
}
Expand Down
1 change: 1 addition & 0 deletions test/markup/javascript/jsx.expect.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<span class="hljs-keyword">var</span> jsx = <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">node</span>/&gt;</span></span>;
<span class="hljs-keyword">var</span> jsx = <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">node</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">child</span>/&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">node</span>&gt;</span></span>;
<span class="hljs-keyword">var</span> jsx = <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">node</span>&gt;</span>...<span class="hljs-tag">&lt;<span class="hljs-name">child</span>&gt;</span>...<span class="hljs-tag">&lt;/<span class="hljs-name">child</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">node</span>&gt;</span></span>;
<span class="hljs-keyword">var</span> jsx = <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>;
<span class="hljs-keyword">var</span> x = <span class="hljs-number">5</span>;
<span class="hljs-keyword">return</span> (<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">node</span> <span class="hljs-attr">attr</span>=<span class="hljs-string">"value"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">node</span>&gt;</span></span>);
1 change: 1 addition & 0 deletions test/markup/javascript/jsx.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var jsx = <node/>;
var jsx = <node><child/></node>;
var jsx = <node>...<child>...</child></node>;
var jsx = <div><br /></div>;
var x = 5;
return (<node attr="value"></node>);

0 comments on commit 5c0bdf8

Please sign in to comment.