Skip to content

Commit 52e8cee

Browse files
Markup: Made most patterns greedy (#3065)
1 parent c7b6a7f commit 52e8cee

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

components/prism-markup.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Prism.languages.markup = {
2-
'comment': /<!--(?:(?!<!--)[\s\S])*?-->/,
3-
'prolog': /<\?[\s\S]+?\?>/,
2+
'comment': {
3+
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
4+
greedy: true
5+
},
6+
'prolog': {
7+
pattern: /<\?[\s\S]+?\?>/,
8+
greedy: true
9+
},
410
'doctype': {
511
// https://www.w3.org/TR/xml/#NT-doctypedecl
612
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
@@ -17,11 +23,14 @@ Prism.languages.markup = {
1723
greedy: true
1824
},
1925
'punctuation': /^<!|>$|[[\]]/,
20-
'doctype-tag': /^DOCTYPE/,
26+
'doctype-tag': /^DOCTYPE/i,
2127
'name': /[^\s<>'"]+/
2228
}
2329
},
24-
'cdata': /<!\[CDATA\[[\s\S]*?\]\]>/i,
30+
'cdata': {
31+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
32+
greedy: true
33+
},
2534
'tag': {
2635
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
2736
greedy: true,

components/prism-markup.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prism.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,8 +1231,14 @@ if (typeof global !== 'undefined') {
12311231
********************************************** */
12321232

12331233
Prism.languages.markup = {
1234-
'comment': /<!--(?:(?!<!--)[\s\S])*?-->/,
1235-
'prolog': /<\?[\s\S]+?\?>/,
1234+
'comment': {
1235+
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
1236+
greedy: true
1237+
},
1238+
'prolog': {
1239+
pattern: /<\?[\s\S]+?\?>/,
1240+
greedy: true
1241+
},
12361242
'doctype': {
12371243
// https://www.w3.org/TR/xml/#NT-doctypedecl
12381244
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
@@ -1249,11 +1255,14 @@ Prism.languages.markup = {
12491255
greedy: true
12501256
},
12511257
'punctuation': /^<!|>$|[[\]]/,
1252-
'doctype-tag': /^DOCTYPE/,
1258+
'doctype-tag': /^DOCTYPE/i,
12531259
'name': /[^\s<>'"]+/
12541260
}
12551261
},
1256-
'cdata': /<!\[CDATA\[[\s\S]*?\]\]>/i,
1262+
'cdata': {
1263+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
1264+
greedy: true
1265+
},
12571266
'tag': {
12581267
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
12591268
greedy: true,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy