Markup: Added support for CSS and JS inside of CDATAs (#1660)
This adds support for CSS/JS inside of (any number of) CDATAs.
This commit is contained in:
parent
16f2ad061a
commit
57127701e4
|
@ -22,15 +22,7 @@ Prism.languages.css = {
|
|||
Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
|
||||
|
||||
if (Prism.languages.markup) {
|
||||
Prism.languages.insertBefore('markup', 'tag', {
|
||||
'style': {
|
||||
pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,
|
||||
lookbehind: true,
|
||||
inside: Prism.languages.css,
|
||||
alias: 'language-css',
|
||||
greedy: true
|
||||
}
|
||||
});
|
||||
Prism.languages.markup.tag.addInlined('style', 'css');
|
||||
|
||||
Prism.languages.insertBefore('inside', 'attr-value', {
|
||||
'style-attr': {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Prism.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+?[\s\S]*?(?:;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^{}\s][^{};]*?(?=\s*\{)/,string:{pattern:/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/!important\b/i,"function":/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:,]/},Prism.languages.css.atrule.inside.rest=Prism.languages.css,Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,lookbehind:!0,inside:Prism.languages.css,alias:"language-css",greedy:!0}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag));
|
||||
Prism.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+?[\s\S]*?(?:;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^{}\s][^{};]*?(?=\s*\{)/,string:{pattern:/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/!important\b/i,"function":/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:,]/},Prism.languages.css.atrule.inside.rest=Prism.languages.css,Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("style","css"),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag));
|
|
@ -77,15 +77,7 @@ Prism.languages.insertBefore('javascript', 'string', {
|
|||
});
|
||||
|
||||
if (Prism.languages.markup) {
|
||||
Prism.languages.insertBefore('markup', 'tag', {
|
||||
'script': {
|
||||
pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,
|
||||
lookbehind: true,
|
||||
inside: Prism.languages.javascript,
|
||||
alias: 'language-javascript',
|
||||
greedy: true
|
||||
}
|
||||
});
|
||||
Prism.languages.markup.tag.addInlined('script', 'javascript');
|
||||
}
|
||||
|
||||
Prism.languages.js = Prism.languages.javascript;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,lookbehind:!0}],keyword:[{pattern:/((?:^|})\s*)(?:catch|finally)\b/,lookbehind:!0},/\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/],number:/\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,"function":/[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,operator:/-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^\/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,lookbehind:!0,greedy:!0},"function-variable":{pattern:/[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,greedy:!0,inside:{interpolation:{pattern:/\${[^}]+}/,inside:{"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,lookbehind:!0,inside:Prism.languages.javascript,alias:"language-javascript",greedy:!0}}),Prism.languages.js=Prism.languages.javascript;
|
||||
Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,lookbehind:!0}],keyword:[{pattern:/((?:^|})\s*)(?:catch|finally)\b/,lookbehind:!0},/\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/],number:/\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,"function":/[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,operator:/-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^\/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,lookbehind:!0,greedy:!0},"function-variable":{pattern:/[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,greedy:!0,inside:{interpolation:{pattern:/\${[^}]+}/,inside:{"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.js=Prism.languages.javascript;
|
|
@ -50,6 +50,50 @@ Prism.hooks.add('wrap', function(env) {
|
|||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
|
||||
/**
|
||||
* Adds an inlined language to markup.
|
||||
*
|
||||
* An example of an inlined language is CSS with `<style>` tags.
|
||||
*
|
||||
* @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
|
||||
* case insensitive.
|
||||
* @param {string} lang The language key.
|
||||
* @example
|
||||
* addInlined('style', 'css');
|
||||
*/
|
||||
value: function addInlined(tagName, lang) {
|
||||
var inside = {};
|
||||
inside['language-' + lang] = {
|
||||
pattern: /[\s\S]+/,
|
||||
inside: Prism.languages[lang]
|
||||
};
|
||||
|
||||
var def = {};
|
||||
def[tagName] = {
|
||||
pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[[\s\S]*?\]\]>\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, tagName), 'i'),
|
||||
lookbehind: true,
|
||||
greedy: true,
|
||||
inside: {
|
||||
'included-cdata': {
|
||||
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
||||
inside: {
|
||||
'content': {
|
||||
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
||||
lookbehind: true,
|
||||
inside: inside
|
||||
},
|
||||
'cdata': /^<!\[CDATA\[|\]\]>$/i
|
||||
}
|
||||
},
|
||||
rest: inside
|
||||
}
|
||||
};
|
||||
|
||||
Prism.languages.insertBefore('markup', 'cdata', def);
|
||||
}
|
||||
});
|
||||
|
||||
Prism.languages.xml = Prism.languages.extend('markup', {});
|
||||
Prism.languages.html = Prism.languages.markup;
|
||||
Prism.languages.mathml = Prism.languages.markup;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Prism.languages.markup={comment:/<!--[\s\S]*?-->/,prolog:/<\?[\s\S]+?\?>/,doctype:/<!DOCTYPE[\s\S]+?>/i,cdata:/<!\[CDATA\[[\s\S]*?]]>/i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s\/>])))+)?\s*\/?>/i,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,inside:{punctuation:[/^=/,{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.hooks.add("wrap",function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&/,"&"))}),Prism.languages.xml=Prism.languages.extend("markup",{}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup;
|
||||
Prism.languages.markup={comment:/<!--[\s\S]*?-->/,prolog:/<\?[\s\S]+?\?>/,doctype:/<!DOCTYPE[\s\S]+?>/i,cdata:/<!\[CDATA\[[\s\S]*?]]>/i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s\/>])))+)?\s*\/?>/i,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,inside:{punctuation:[/^=/,{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.hooks.add("wrap",function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&/,"&"))}),Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(a,e){var s={};s["language-"+e]={pattern:/[\s\S]+/,inside:Prism.languages[e]};var t={};t[a]={pattern:RegExp("(<__[\\s\\S]*?>)(?:<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\s*|[\\s\\S])*?(?=<\\/__>)".replace(/__/g,a),"i"),lookbehind:!0,greedy:!0,inside:{"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:{content:{pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:s},cdata:/^<!\[CDATA\[|\]\]>$/i}},rest:s}},Prism.languages.insertBefore("markup","cdata",t)}}),Prism.languages.xml=Prism.languages.extend("markup",{}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup;
|
64
prism.js
64
prism.js
|
@ -614,6 +614,50 @@ Prism.hooks.add('wrap', function(env) {
|
|||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
|
||||
/**
|
||||
* Adds an inlined language to markup.
|
||||
*
|
||||
* An example of an inlined language is CSS with `<style>` tags.
|
||||
*
|
||||
* @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
|
||||
* case insensitive.
|
||||
* @param {string} lang The language key.
|
||||
* @example
|
||||
* addInlined('style', 'css');
|
||||
*/
|
||||
value: function addInlined(tagName, lang) {
|
||||
var inside = {};
|
||||
inside['language-' + lang] = {
|
||||
pattern: /[\s\S]+/,
|
||||
inside: Prism.languages[lang]
|
||||
};
|
||||
|
||||
var def = {};
|
||||
def[tagName] = {
|
||||
pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[[\s\S]*?\]\]>\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, tagName), 'i'),
|
||||
lookbehind: true,
|
||||
greedy: true,
|
||||
inside: {
|
||||
'included-cdata': {
|
||||
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
||||
inside: {
|
||||
'content': {
|
||||
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
||||
lookbehind: true,
|
||||
inside: inside
|
||||
},
|
||||
'cdata': /^<!\[CDATA\[|\]\]>$/i
|
||||
}
|
||||
},
|
||||
rest: inside
|
||||
}
|
||||
};
|
||||
|
||||
Prism.languages.insertBefore('markup', 'cdata', def);
|
||||
}
|
||||
});
|
||||
|
||||
Prism.languages.xml = Prism.languages.extend('markup', {});
|
||||
Prism.languages.html = Prism.languages.markup;
|
||||
Prism.languages.mathml = Prism.languages.markup;
|
||||
|
@ -648,15 +692,7 @@ Prism.languages.css = {
|
|||
Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
|
||||
|
||||
if (Prism.languages.markup) {
|
||||
Prism.languages.insertBefore('markup', 'tag', {
|
||||
'style': {
|
||||
pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,
|
||||
lookbehind: true,
|
||||
inside: Prism.languages.css,
|
||||
alias: 'language-css',
|
||||
greedy: true
|
||||
}
|
||||
});
|
||||
Prism.languages.markup.tag.addInlined('style', 'css');
|
||||
|
||||
Prism.languages.insertBefore('inside', 'attr-value', {
|
||||
'style-attr': {
|
||||
|
@ -797,15 +833,7 @@ Prism.languages.insertBefore('javascript', 'string', {
|
|||
});
|
||||
|
||||
if (Prism.languages.markup) {
|
||||
Prism.languages.insertBefore('markup', 'tag', {
|
||||
'script': {
|
||||
pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,
|
||||
lookbehind: true,
|
||||
inside: Prism.languages.javascript,
|
||||
alias: 'language-javascript',
|
||||
greedy: true
|
||||
}
|
||||
});
|
||||
Prism.languages.markup.tag.addInlined('script', 'javascript');
|
||||
}
|
||||
|
||||
Prism.languages.js = Prism.languages.javascript;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
----------------------------------------------------
|
||||
|
||||
[
|
||||
|
||||
["tag", [
|
||||
["tag", [
|
||||
["punctuation", "<"],
|
||||
|
@ -18,11 +17,15 @@
|
|||
["punctuation", ">"]
|
||||
]],
|
||||
["script", [
|
||||
["keyword", "let"],
|
||||
" str ",
|
||||
["operator", "="],
|
||||
["template-string", [["string", "`\r\n\t\t<style>\r\n\t\t\t.foo { color: blue; }\r\n\t\t</style>\r\n\t`"]]],
|
||||
["punctuation", ";"]
|
||||
["language-javascript", [
|
||||
["keyword", "let"],
|
||||
" str ",
|
||||
["operator", "="],
|
||||
["template-string", [
|
||||
["string", "`\r\n\t\t<style>\r\n\t\t\t.foo { color: blue; }\r\n\t\t</style>\r\n\t`"]
|
||||
]],
|
||||
["punctuation", ";"]
|
||||
]]
|
||||
]],
|
||||
["tag", [
|
||||
["tag", [
|
||||
|
@ -35,4 +38,4 @@
|
|||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for Javascript usage inside Markup, using <script> tags.
|
||||
Checks for Javascript usage inside Markup, using <script> tags.
|
||||
|
|
|
@ -4,6 +4,16 @@ foo {
|
|||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.bar { }
|
||||
<![CDATA[
|
||||
foo {
|
||||
bar: baz;
|
||||
}
|
||||
]]>
|
||||
#foo { }
|
||||
</style>
|
||||
|
||||
<foo style="bar:baz;">
|
||||
|
||||
----------------------------------------------------
|
||||
|
@ -14,9 +24,7 @@ foo {
|
|||
["punctuation", "<"],
|
||||
"style"
|
||||
]],
|
||||
["attr-name", [
|
||||
"type"
|
||||
]],
|
||||
["attr-name", ["type"]],
|
||||
["attr-value", [
|
||||
["punctuation", "="],
|
||||
["punctuation", "\""],
|
||||
|
@ -26,13 +34,57 @@ foo {
|
|||
["punctuation", ">"]
|
||||
]],
|
||||
["style", [
|
||||
["selector", "foo"],
|
||||
["punctuation", "{"],
|
||||
["property", "bar"],
|
||||
["punctuation", ":"],
|
||||
" baz",
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"]
|
||||
["language-css", [
|
||||
["selector", "foo"],
|
||||
["punctuation", "{"],
|
||||
["property", "bar"],
|
||||
["punctuation", ":"],
|
||||
" baz",
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"]
|
||||
]]
|
||||
]],
|
||||
["tag", [
|
||||
["tag", [
|
||||
["punctuation", "</"],
|
||||
"style"
|
||||
]],
|
||||
["punctuation", ">"]
|
||||
]],
|
||||
|
||||
["tag", [
|
||||
["tag", [
|
||||
["punctuation", "<"],
|
||||
"style"
|
||||
]],
|
||||
["punctuation", ">"]
|
||||
]],
|
||||
["style", [
|
||||
["language-css", [
|
||||
["selector", ".bar"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"]
|
||||
]],
|
||||
["included-cdata", [
|
||||
["cdata", "<![CDATA["],
|
||||
["content", [
|
||||
["language-css", [
|
||||
["selector", "foo"],
|
||||
["punctuation", "{"],
|
||||
["property", "bar"],
|
||||
["punctuation", ":"],
|
||||
" baz",
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"]
|
||||
]]
|
||||
]],
|
||||
["cdata", "]]>"]
|
||||
]],
|
||||
["language-css", [
|
||||
["selector", "#foo"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"]
|
||||
]]
|
||||
]],
|
||||
["tag", [
|
||||
["tag", [
|
||||
|
@ -49,9 +101,7 @@ foo {
|
|||
]],
|
||||
["style-attr", [
|
||||
["attr-name", [
|
||||
["attr-name", [
|
||||
"style"
|
||||
]]
|
||||
["attr-name", ["style"]]
|
||||
]],
|
||||
["punctuation", "=\""],
|
||||
["attr-value", [
|
||||
|
@ -68,4 +118,4 @@ foo {
|
|||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for CSS usage inside Markup, using <style> tag and style attribute.
|
||||
Checks for CSS usage inside Markup, using <style> tag and style attribute.
|
||||
|
|
|
@ -1,20 +1,26 @@
|
|||
<script type="text/javascript">foo()</script>
|
||||
|
||||
<script>
|
||||
"foo bar"
|
||||
</script>
|
||||
|
||||
<script type="application/javascript">
|
||||
var a = 0;
|
||||
<![CDATA[
|
||||
let foo = '</script>';
|
||||
]]>
|
||||
"foo"
|
||||
</script>
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
|
||||
["tag", [
|
||||
["tag", [
|
||||
["punctuation", "<"],
|
||||
"script"
|
||||
]],
|
||||
["attr-name", [
|
||||
"type"
|
||||
]],
|
||||
["attr-name", ["type"]],
|
||||
["attr-value", [
|
||||
["punctuation", "="],
|
||||
["punctuation", "\""],
|
||||
|
@ -24,9 +30,11 @@
|
|||
["punctuation", ">"]
|
||||
]],
|
||||
["script", [
|
||||
["function", "foo"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"]
|
||||
["language-javascript", [
|
||||
["function", "foo"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"]
|
||||
]]
|
||||
]],
|
||||
["tag", [
|
||||
["tag", [
|
||||
|
@ -44,7 +52,56 @@
|
|||
["punctuation", ">"]
|
||||
]],
|
||||
["script", [
|
||||
["string", "\"foo bar\""]
|
||||
["language-javascript", [
|
||||
["string", "\"foo bar\""]
|
||||
]]
|
||||
]],
|
||||
["tag", [
|
||||
["tag", [
|
||||
["punctuation", "</"],
|
||||
"script"
|
||||
]],
|
||||
["punctuation", ">"]
|
||||
]],
|
||||
|
||||
["tag", [
|
||||
["tag", [
|
||||
["punctuation", "<"],
|
||||
"script"
|
||||
]],
|
||||
["attr-name", ["type"]],
|
||||
["attr-value", [
|
||||
["punctuation", "="],
|
||||
["punctuation", "\""],
|
||||
"application/javascript",
|
||||
["punctuation", "\""]
|
||||
]],
|
||||
["punctuation", ">"]
|
||||
]],
|
||||
["script", [
|
||||
["language-javascript", [
|
||||
["keyword", "var"],
|
||||
" a ",
|
||||
["operator", "="],
|
||||
["number", "0"],
|
||||
["punctuation", ";"]
|
||||
]],
|
||||
["included-cdata", [
|
||||
["cdata", "<![CDATA["],
|
||||
["content", [
|
||||
["language-javascript", [
|
||||
["keyword", "let"],
|
||||
" foo ",
|
||||
["operator", "="],
|
||||
["string", "'</script>'"],
|
||||
["punctuation", ";"]
|
||||
]]
|
||||
]],
|
||||
["cdata", "]]>"]
|
||||
]],
|
||||
["language-javascript", [
|
||||
["string", "\"foo\""]
|
||||
]]
|
||||
]],
|
||||
["tag", [
|
||||
["tag", [
|
||||
|
@ -57,4 +114,4 @@
|
|||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for Javascript usage inside Markup, using <script> tags.
|
||||
Checks for Javascript usage inside Markup, using <script> tags.
|
||||
|
|
|
@ -39,7 +39,9 @@
|
|||
["punctuation", ">"]
|
||||
]],
|
||||
["script", [
|
||||
["regex", "/foo/"]
|
||||
["language-javascript", [
|
||||
["regex", "/foo/"]
|
||||
]]
|
||||
]],
|
||||
["tag", [
|
||||
["tag", [
|
||||
|
@ -54,4 +56,4 @@
|
|||
|
||||
Checks for scripts containing C# code.
|
||||
Also checks that those don't break normal JS scripts.
|
||||
Note: Markup is loaded before Javascript so that scripts are added into grammar.
|
||||
Note: Markup is loaded before Javascript so that scripts are added into grammar.
|
||||
|
|
Loading…
Reference in New Issue