Merged the comment and line-comment tokens
This commit is contained in:
parent
ed944399b8
commit
e95a85c02e
|
@ -1,7 +1,6 @@
|
|||
Prism.languages.javascript = {
|
||||
'comment': /\/\*[\w\W]*?\*\//g,
|
||||
'line-comment': {
|
||||
pattern: /(^|[^\\])\/\/.*?(\r?\n|$)/g,
|
||||
'comment': {
|
||||
pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/g,
|
||||
lookbehind: true
|
||||
},
|
||||
'string': /("|')(\\?.)*?\1/g,
|
||||
|
|
|
@ -1 +1 @@
|
|||
Prism.languages.javascript={comment:/\/\*[\w\W]*?\*\//g,"line-comment":{pattern:/(^|[^\\])\/\/.*?(\r?\n|$)/g,lookbehind:!0},string:/("|')(\\?.)*?\1/g,regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,lookbehind:!0},keyword:/\b(var|let|if|else|while|do|for|return|in|instanceof|function|new|with|typeof|try|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,number:/\b-?(0x)?\d*\.?\d+\b/g,operator:/[-+]{1,2}|!|=?<|=?>|={1,2}|(&){1,2}|\|?\||\?|\*|\//g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g};Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/ig,inside:{tag:{pattern:/(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript}}});
|
||||
Prism.languages.javascript={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/g,lookbehind:!0},string:/("|')(\\?.)*?\1/g,regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,lookbehind:!0},keyword:/\b(var|let|if|else|while|do|for|return|in|instanceof|function|new|with|typeof|try|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,number:/\b-?(0x)?\d*\.?\d+\b/g,operator:/[-+]{1,2}|!|=?<|=?>|={1,2}|(&){1,2}|\|?\||\?|\*|\//g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g};Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/ig,inside:{tag:{pattern:/(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript}}});
|
|
@ -42,7 +42,7 @@
|
|||
<dt>lookbehind</dt>
|
||||
<dd>This option mitigates JavaScript’s lack of lookbehind. When set to <code>true</code>,
|
||||
the first capturing group in the regex <code>pattern</code> is discarded when matching this token, so it effectively behaves
|
||||
as if it was lookbehind. For an example of this, check out the JavaScript language definition, in particular the regex and line-comment tokens:
|
||||
as if it was lookbehind. For an example of this, check out the JavaScript language definition, in particular the regex and comment tokens:
|
||||
<pre data-src="components/prism-javascript.js"></pre></dd>
|
||||
|
||||
<dt>rest</dt>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<title>Plugins ▲ Prism</title>
|
||||
<base href=".." />
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<link rel="stylesheet" href="prism.css" data-noprefix />
|
||||
<link rel="stylesheet" href="plugins/line-highlight/prism-line-highlight.css" data-noprefix />
|
||||
<script src="../prefixfree/prefixfree.min.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<div class="intro" data-src="templates/header-plugins.html" data-type="text/html"></div>
|
||||
</header>
|
||||
|
||||
<section>
|
||||
<h1>Available plugins</h1>
|
||||
<ul class="plugin-list"></ul>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h1>Contribute</h1>
|
||||
<p>Writing Prism plugins is easy! Read how at the “<a href="extending.html#writing-plugins">Extending Prism</a>” section.
|
||||
</section>
|
||||
|
||||
<footer data-src="templates/footer.html" data-type="text/html"></footer>
|
||||
|
||||
<script src="prism.js"></script>
|
||||
<script src="plugins/line-highlight/prism-line-highlight.js"></script>
|
||||
<script src="utopia.js"></script>
|
||||
<script src="code.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -49,7 +49,6 @@ pre[class*="language-"] {
|
|||
}
|
||||
|
||||
.token.comment,
|
||||
.token.line-comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
|
|
|
@ -46,7 +46,6 @@ code[class*="language-"] {
|
|||
}
|
||||
|
||||
.token.comment,
|
||||
.token.line-comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
|
|
|
@ -44,7 +44,6 @@ pre[class*="language-"] {
|
|||
}
|
||||
|
||||
.token.comment,
|
||||
.token.line-comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
|
|
5
prism.js
5
prism.js
|
@ -386,9 +386,8 @@ if (Prism.languages.markup) {
|
|||
***********************************************/
|
||||
|
||||
Prism.languages.javascript = {
|
||||
'comment': /\/\*[\w\W]*?\*\//g,
|
||||
'line-comment': {
|
||||
pattern: /(^|[^\\])\/\/.*?(\r?\n|$)/g,
|
||||
'comment': {
|
||||
pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/g,
|
||||
lookbehind: true
|
||||
},
|
||||
'string': /("|')(\\?.)*?\1/g,
|
||||
|
|
Loading…
Reference in New Issue