Skip to content

Commit

Permalink
Markup: Make tags greedy. Fix #1356
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Mar 14, 2018
1 parent f0e6249 commit af834be
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/prism-markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Prism.languages.markup = {
'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
'tag': {
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,
greedy: true,
inside: {
'tag': {
pattern: /^<\/?[^\s>\/]+/i,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-markup.min.js

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

1 change: 1 addition & 0 deletions prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ Prism.languages.markup = {
'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
'tag': {
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,
greedy: true,
inside: {
'tag': {
pattern: /^<\/?[^\s>\/]+/i,
Expand Down
32 changes: 32 additions & 0 deletions tests/languages/jsx/issue1356.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<a href="//localhost">link</a>

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

[
["tag", [
["tag", [
["punctuation", "<"],
"a"
]],
["attr-name", ["href"]],
["attr-value", [
["punctuation", "="],
["punctuation", "\""],
"//localhost",
["punctuation", "\""]
]],
["punctuation", ">"]
]],
"link",
["tag", [
["tag", [
["punctuation", "</"],
"a"
]],
["punctuation", ">"]
]]
]

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

Checks for tags containing "//". See #1356.

0 comments on commit af834be

Please sign in to comment.