Skip to content

Commit

Permalink
Markup: Made most patterns greedy (#3065)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Sep 15, 2021
1 parent c7b6a7f commit 52e8cee
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
17 changes: 13 additions & 4 deletions components/prism-markup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Prism.languages.markup = {
'comment': /<!--(?:(?!<!--)[\s\S])*?-->/,
'prolog': /<\?[\s\S]+?\?>/,
'comment': {
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
greedy: true
},
'prolog': {
pattern: /<\?[\s\S]+?\?>/,
greedy: true
},
'doctype': {
// https://www.w3.org/TR/xml/#NT-doctypedecl
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
Expand All @@ -17,11 +23,14 @@ Prism.languages.markup = {
greedy: true
},
'punctuation': /^<!|>$|[[\]]/,
'doctype-tag': /^DOCTYPE/,
'doctype-tag': /^DOCTYPE/i,
'name': /[^\s<>'"]+/
}
},
'cdata': /<!\[CDATA\[[\s\S]*?\]\]>/i,
'cdata': {
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
greedy: true
},
'tag': {
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
greedy: true,
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.

17 changes: 13 additions & 4 deletions prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -1231,8 +1231,14 @@ if (typeof global !== 'undefined') {
********************************************** */

Prism.languages.markup = {
'comment': /<!--(?:(?!<!--)[\s\S])*?-->/,
'prolog': /<\?[\s\S]+?\?>/,
'comment': {
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
greedy: true
},
'prolog': {
pattern: /<\?[\s\S]+?\?>/,
greedy: true
},
'doctype': {
// https://www.w3.org/TR/xml/#NT-doctypedecl
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
Expand All @@ -1249,11 +1255,14 @@ Prism.languages.markup = {
greedy: true
},
'punctuation': /^<!|>$|[[\]]/,
'doctype-tag': /^DOCTYPE/,
'doctype-tag': /^DOCTYPE/i,
'name': /[^\s<>'"]+/
}
},
'cdata': /<!\[CDATA\[[\s\S]*?\]\]>/i,
'cdata': {
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
greedy: true
},
'tag': {
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
greedy: true,
Expand Down

0 comments on commit 52e8cee

Please sign in to comment.