Skip to content

Commit

Permalink
(javascript) fix jsx self-closing tag issues
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Dec 13, 2019
1 parent 40ef5c4 commit b0fe526
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/languages/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,23 @@ function(hljs) {
skip: true,
},
{ // E4X / JSX
begin: /</, end: /(\/[A-Za-z0-9\\._:-]+|[A-Za-z0-9\\._:-]+\/)>/,
className: 'jsx',
begin: /<[A-Za-z0-9\\._:-]+/, end: /(\/[A-Za-z0-9\\._:-]+\/?)>/,
subLanguage: 'xml',
contains: [
// self-closing tag
{ begin: /<[A-Za-z0-9\\._:-]+\s*\/>/, skip: true },
// manually closed tag
{
begin: /<[A-Za-z0-9\\._:-]+/, end: /(\/[A-Za-z0-9\\._:-]+|[A-Za-z0-9\\._:-]+\/)>/, skip: true,
begin: /<[A-Za-z0-9\\._:-]+/, end: /(\/[A-Za-z0-9\\._:-]+\/?)>/, skip: true,
contains: [
{ begin: /<[A-Za-z0-9\\._:-]+\s*\/>/, skip: true },
'self'
]
}
},
// it's possible our beginning JSX tag is actually self closing tag,
// so we need to allow for that possibility
{ begin: /\/>/, skip: true, endsParent: true},
]
}
],
Expand Down

0 comments on commit b0fe526

Please sign in to comment.