ESLint: Added semi rule (#2836)
This commit is contained in:
parent
9cae446161
commit
b03e7eb0cd
|
@ -5,6 +5,7 @@ module.exports = {
|
|||
rules: {
|
||||
// stylistic rules
|
||||
'quotes': ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
|
||||
'semi': 'warn',
|
||||
|
||||
// I turned this rule off because we use `hasOwnProperty` in a lot of places
|
||||
// TODO: Think about re-enabling this rule
|
||||
|
|
|
@ -124,7 +124,7 @@ if (toc.children.length > 0) {
|
|||
|
||||
if (PrefixFree.functions.indexOf('calc') == -1) {
|
||||
var style = document.createElement('_').style;
|
||||
style.width = 'calc(1px + 1%)'
|
||||
style.width = 'calc(1px + 1%)';
|
||||
|
||||
if(!style.width) {
|
||||
// calc not supported
|
||||
|
|
|
@ -62,7 +62,7 @@ if (hstr) {
|
|||
if (components[category][id]) {
|
||||
if (components[category][id].option !== 'default') {
|
||||
if (typeof components[category][id] === 'string') {
|
||||
components[category][id] = { title: components[category][id] }
|
||||
components[category][id] = { title: components[category][id] };
|
||||
}
|
||||
components[category][id].option = 'default';
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ function buildContentsHeader(id) {
|
|||
header += ':';
|
||||
header += '<ul>';
|
||||
deps.forEach(function (text) {
|
||||
header += '<li>' + text + '.</li>'
|
||||
header += '<li>' + text + '.</li>';
|
||||
});
|
||||
header += '</ul>';
|
||||
}
|
||||
|
|
|
@ -24,4 +24,4 @@ Prism.languages.cil = {
|
|||
'number': /\b-?(?:0x[0-9a-fA-F]+|[0-9]+)(?:\.[0-9a-fA-F]+)?\b/i,
|
||||
|
||||
'punctuation': /[{}[\];(),:=]|IL_[0-9A-Za-z]+/
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(function (Prism) {
|
||||
|
||||
var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char8_t|char16_t|char32_t|class|compl|concept|const|consteval|constexpr|constinit|const_cast|continue|co_await|co_return|co_yield|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
|
||||
var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function () { return keyword.source; })
|
||||
var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function () { return keyword.source; });
|
||||
|
||||
Prism.languages.cpp = Prism.languages.extend('c', {
|
||||
'class-name': [
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
var identifier = replace(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source, [nonTypeKeywords, genericName]);
|
||||
var array = /\[\s*(?:,\s*)*\]/.source;
|
||||
var typeExpressionWithoutTuple = replace(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source, [identifier, array]);
|
||||
var tupleElement = replace(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source, [generic, nestedRound, array])
|
||||
var tupleElement = replace(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source, [generic, nestedRound, array]);
|
||||
var tuple = replace(/\(<<0>>+(?:,<<0>>+)+\)/.source, [tupleElement]);
|
||||
var typeExpression = replace(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source, [tuple, identifier, array]);
|
||||
|
||||
|
@ -308,10 +308,10 @@
|
|||
// string interpolation
|
||||
var formatString = /:[^}\r\n]+/.source;
|
||||
// multi line
|
||||
var mInterpolationRound = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2)
|
||||
var mInterpolationRound = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
|
||||
var mInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [mInterpolationRound, formatString]);
|
||||
// single line
|
||||
var sInterpolationRound = nested(replace(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source, [regularStringOrCharacter]), 2)
|
||||
var sInterpolationRound = nested(replace(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source, [regularStringOrCharacter]), 2);
|
||||
var sInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [sInterpolationRound, formatString]);
|
||||
|
||||
function createInterpolationInside(interpolation, interpolationRound) {
|
||||
|
|
|
@ -30,4 +30,4 @@ Prism.languages['dns-zone-file'] = {
|
|||
'punctuation': /[()]/
|
||||
};
|
||||
|
||||
Prism.languages['dns-zone'] = Prism.languages['dns-zone-file']
|
||||
Prism.languages['dns-zone'] = Prism.languages['dns-zone-file'];
|
||||
|
|
|
@ -133,7 +133,7 @@
|
|||
},
|
||||
rest: Prism.languages[filter.language]
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
if (level <= 0) {
|
||||
return /[]/.source;
|
||||
} else {
|
||||
return source.replace(/<SELF>/g, function () { return nested(source, level - 1) });
|
||||
return source.replace(/<SELF>/g, function () { return nested(source, level - 1); });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
}
|
||||
};
|
||||
|
||||
Prism.languages.gitignore = Prism.languages.ignore
|
||||
Prism.languages.hgignore = Prism.languages.ignore
|
||||
Prism.languages.npmignore = Prism.languages.ignore
|
||||
Prism.languages.gitignore = Prism.languages.ignore;
|
||||
Prism.languages.hgignore = Prism.languages.ignore;
|
||||
Prism.languages.npmignore = Prism.languages.ignore;
|
||||
|
||||
}(Prism));
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
var codeLinePattern = /(^(?:\s*(?:\*\s*)*))[^*\s].*$/m;
|
||||
|
||||
var memberReference = /#\s*\w+(?:\s*\([^()]*\))?/.source;
|
||||
var reference = /(?:[a-zA-Z]\w+\s*\.\s*)*[A-Z]\w*(?:\s*<mem>)?|<mem>/.source.replace(/<mem>/g, function () { return memberReference });
|
||||
var reference = /(?:[a-zA-Z]\w+\s*\.\s*)*[A-Z]\w*(?:\s*<mem>)?|<mem>/.source.replace(/<mem>/g, function () { return memberReference; });
|
||||
|
||||
Prism.languages.javadoc = Prism.languages.extend('javadoclike', {});
|
||||
Prism.languages.insertBefore('javadoc', 'keyword', {
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
pattern: /\./,
|
||||
alias: 'important'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
stringInterpolation.interpolation.inside.content.inside = jq;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(function (Prism) {
|
||||
|
||||
var string = /("|')(?:\\(?:\r\n?|\n|.)|(?!\1)[^\\\r\n])*\1/
|
||||
var string = /("|')(?:\\(?:\r\n?|\n|.)|(?!\1)[^\\\r\n])*\1/;
|
||||
|
||||
Prism.languages.json5 = Prism.languages.extend('json', {
|
||||
'property': [
|
||||
|
|
|
@ -45,4 +45,4 @@ Prism.languages.jsstacktrace = {
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -105,7 +105,7 @@ var walkTokens = function (tokens) {
|
|||
openedTags[openedTags.length - 1].openedBraces--;
|
||||
|
||||
} else {
|
||||
notTagNorBrace = true
|
||||
notTagNorBrace = true;
|
||||
}
|
||||
}
|
||||
if (notTagNorBrace || typeof token === 'string') {
|
||||
|
|
|
@ -297,7 +297,7 @@
|
|||
// this might be a language that Prism does not support
|
||||
|
||||
// do some replacements to support C++, C#, and F#
|
||||
var lang = codeLang.content.replace(/\b#/g, 'sharp').replace(/\b\+\+/g, 'pp')
|
||||
var lang = codeLang.content.replace(/\b#/g, 'sharp').replace(/\b\+\+/g, 'pp');
|
||||
// only use the first word
|
||||
lang = (/[a-z][\w-]*/i.exec(lang) || [''])[0].toLowerCase();
|
||||
var alias = 'language-' + lang;
|
||||
|
|
|
@ -122,4 +122,4 @@ Prism.languages.nevod = {
|
|||
],
|
||||
'punctuation': /[:;,()]/,
|
||||
'name': /[a-zA-Z0-9\-.]+/
|
||||
}
|
||||
};
|
||||
|
|
|
@ -52,4 +52,4 @@ Prism.languages.powerquery = {
|
|||
};
|
||||
|
||||
Prism.languages.pq = Prism.languages['powerquery'];
|
||||
Prism.languages.mscript = Prism.languages['powerquery']
|
||||
Prism.languages.mscript = Prism.languages['powerquery'];
|
|
@ -174,7 +174,7 @@
|
|||
},
|
||||
rest: Prism.languages[filter.language]
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
type: 'Adj BigInt Bool Ctl Double false Int One Pauli PauliI PauliX PauliY PauliZ Qubit Range Result String true Unit Zero',
|
||||
// all other keywords
|
||||
other: 'Adjoint adjoint apply as auto body borrow borrowing Controlled controlled distribute elif else fail fixup for function if in internal intrinsic invert is let mutable namespace new newtype open operation repeat return self set until use using while within'
|
||||
}
|
||||
};
|
||||
// keywords
|
||||
function keywordsToPattern(words) {
|
||||
return '\\b(?:' + words.trim().replace(/ /g, '|') + ')\\b';
|
||||
|
|
|
@ -101,4 +101,4 @@
|
|||
}
|
||||
};
|
||||
|
||||
}(Prism))
|
||||
}(Prism));
|
||||
|
|
|
@ -21,4 +21,4 @@ Prism.languages['splunk-spl'] = {
|
|||
'boolean': /\b(?:f|false|t|true)\b/i,
|
||||
'operator': /[<>=]=?|[-+*/%|]/,
|
||||
'punctuation': /[()[\],]/
|
||||
}
|
||||
};
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
openedTags[openedTags.length - 1].openedBraces--;
|
||||
|
||||
} else if (token.type !== 'comment') {
|
||||
notTagNorBrace = true
|
||||
notTagNorBrace = true;
|
||||
}
|
||||
}
|
||||
if (notTagNorBrace || typeof token === 'string') {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
flags = (flags || '').replace(/m/g, '') + 'm'; // add m flag
|
||||
var pattern = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|]|}|(?:[\r\n]\s*)?#))/.source
|
||||
.replace(/<<prop>>/g, function () { return properties; }).replace(/<<value>>/g, function () { return value; });
|
||||
return RegExp(pattern, flags)
|
||||
return RegExp(pattern, flags);
|
||||
}
|
||||
|
||||
Prism.languages.yaml = {
|
||||
|
|
|
@ -54,7 +54,7 @@ const formatBytes = (bytes, decimals = 2) => {
|
|||
const i = Math.floor(Math.log(Math.abs(bytes)) / Math.log(k));
|
||||
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||
}
|
||||
};
|
||||
|
||||
const maybePlus = (from, to) => from < to ? '+' : '';
|
||||
|
||||
|
@ -64,7 +64,7 @@ const absDiff = (from, to) => {
|
|||
}
|
||||
|
||||
return `${maybePlus(from, to)}${formatBytes(to - from)}`;
|
||||
}
|
||||
};
|
||||
|
||||
const percDiff = (from, to) => {
|
||||
if (from === to) {
|
||||
|
@ -72,7 +72,7 @@ const percDiff = (from, to) => {
|
|||
}
|
||||
|
||||
return `${maybePlus(from, to)}${(100 * (to - from) / (from || to)).toFixed(1)}%`;
|
||||
}
|
||||
};
|
||||
|
||||
const getSummary = (rows, totalMasterFileSize, totalFileSize) => {
|
||||
const numFiles = rows.length;
|
||||
|
@ -81,7 +81,7 @@ const getSummary = (rows, totalMasterFileSize, totalFileSize) => {
|
|||
const percentDiff = percDiff(totalMasterFileSize, totalFileSize);
|
||||
|
||||
return `A total of ${numFiles} file${maybeS} have changed, with a combined diff of ${byteDiff} (${percentDiff}).`;
|
||||
}
|
||||
};
|
||||
|
||||
const run = async () => {
|
||||
const minified = await getChangedMinifiedFiles();
|
||||
|
@ -107,7 +107,7 @@ const run = async () => {
|
|||
]);
|
||||
|
||||
totalFileSize += fileSize;
|
||||
totalMasterFileSize += fileMasterSize
|
||||
totalMasterFileSize += fileMasterSize;
|
||||
|
||||
rows.push([
|
||||
file,
|
||||
|
@ -130,7 +130,7 @@ ${rows.map(row => `| ${row.join(' | ')} |`).join('\n')}
|
|||
|
||||
</details>
|
||||
`);
|
||||
}
|
||||
};
|
||||
|
||||
run().catch(err => {
|
||||
console.error(err);
|
||||
|
|
|
@ -369,7 +369,7 @@ async function changes() {
|
|||
for (const subCategory of Object.keys(category).sort(strCompare)) {
|
||||
if (subCategory) {
|
||||
md += `${indentation}* __${subCategory}__\n`;
|
||||
printCategory(category[subCategory], indentation + ' ')
|
||||
printCategory(category[subCategory], indentation + ' ');
|
||||
} else {
|
||||
for (const info of category['']) {
|
||||
md += `${indentation}* ${infoToString(info)}\n`;
|
||||
|
|
|
@ -65,7 +65,7 @@ module.exports = {
|
|||
// error if used. So we just replace the "function" with some literal that JSDoc will interpret as a
|
||||
// namespace. Not pretty but it works.
|
||||
comment.comment = comment.comment
|
||||
.replace(/\bimport\s*\(\s*(?:"(?:[^"\r\n\\]|\\.)*"|'(?:[^'\r\n\\]|\\.)*')\s*\)/g, '__dyn_import__')
|
||||
.replace(/\bimport\s*\(\s*(?:"(?:[^"\r\n\\]|\\.)*"|'(?:[^'\r\n\\]|\\.)*')\s*\)/g, '__dyn_import__');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -354,7 +354,7 @@
|
|||
* @returns {string}
|
||||
*/
|
||||
function getLanguagePath(lang) {
|
||||
return config.languages_path + 'prism-' + lang + (config.use_minified ? '.min' : '') + '.js'
|
||||
return config.languages_path + 'prism-' + lang + (config.use_minified ? '.min' : '') + '.js';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
*/
|
||||
function selectElementText(element) {
|
||||
// https://stackoverflow.com/a/20079910/7595472
|
||||
window.getSelection().selectAllChildren(element)
|
||||
window.getSelection().selectAllChildren(element);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
prefix: function prefix(string) {
|
||||
prefixString = string || '';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Prism.hooks.add('wrap', function (env) {
|
||||
if (adder) {
|
||||
|
|
|
@ -140,6 +140,6 @@
|
|||
logged = true;
|
||||
}
|
||||
Prism.plugins.fileHighlight.highlight.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
document.body.removeChild(d);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,7 +10,7 @@ var assign = Object.assign || function (obj1, obj2) {
|
|||
obj1[name] = obj2[name];
|
||||
}
|
||||
return obj1;
|
||||
}
|
||||
};
|
||||
|
||||
function NormalizeWhitespace(defaults) {
|
||||
this.defaults = assign({}, defaults);
|
||||
|
|
|
@ -44,7 +44,7 @@ if (Prism.languages.markup) {
|
|||
'hkern': 1, 'vkern': 1
|
||||
},
|
||||
MathML: {}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var language;
|
||||
|
|
2
prism.js
2
prism.js
|
@ -1769,6 +1769,6 @@ Prism.languages.js = Prism.languages.javascript;
|
|||
logged = true;
|
||||
}
|
||||
Prism.plugins.fileHighlight.highlight.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
|
@ -318,12 +318,12 @@ describe('components.json', function () {
|
|||
|
||||
for (const modifyId of toArray(entry.modify)) {
|
||||
if (optional.has(modifyId)) {
|
||||
assert.fail(`The component "${id}" has declared "${modifyId}" as both optional and modify.`)
|
||||
assert.fail(`The component "${id}" has declared "${modifyId}" as both optional and modify.`);
|
||||
}
|
||||
}
|
||||
for (const requireId of toArray(entry.require)) {
|
||||
if (optional.has(requireId)) {
|
||||
assert.fail(`The component "${id}" has declared "${requireId}" as both optional and require.`)
|
||||
assert.fail(`The component "${id}" has declared "${requireId}" as both optional and require.`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -151,7 +151,7 @@ function parseHTML(html) {
|
|||
|
||||
const p = new Parser({
|
||||
onerror(err) {
|
||||
reject(err)
|
||||
reject(err);
|
||||
},
|
||||
onend() {
|
||||
resolve(tree);
|
||||
|
|
|
@ -110,7 +110,7 @@ module.exports = (Prism) => {
|
|||
} else {
|
||||
elementStr = String(element);
|
||||
}
|
||||
redefStr += `\t'${key}': ${elementStr},\n`
|
||||
redefStr += `\t'${key}': ${elementStr},\n`;
|
||||
}
|
||||
redefStr += '}';
|
||||
} else {
|
||||
|
|
|
@ -74,7 +74,7 @@ module.exports = {
|
|||
if (testCase.comment.trim()) {
|
||||
content += separator + testCase.comment.trim();
|
||||
}
|
||||
content += '\n'
|
||||
content += '\n';
|
||||
content = content.replace(/\r?\n/g, lineEnd);
|
||||
|
||||
fs.writeFileSync(filePath, content, 'utf-8');
|
||||
|
|
|
@ -286,8 +286,8 @@ function printPrettyTokenStream(prettyStream, indentationLevel = 1, indentationC
|
|||
const lineEnd = (i === prettyStream.length - 1) ? '\n' : ',\n';
|
||||
out += lineEnd;
|
||||
}
|
||||
})
|
||||
out += indentation.substr(indentationChar.length) + ']'
|
||||
});
|
||||
out += indentation.substr(indentationChar.length) + ']';
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* eslint-disable no-undef */
|
||||
const expect = require('chai').expect;
|
||||
const jsdom = require('jsdom')
|
||||
const { JSDOM } = jsdom
|
||||
const jsdom = require('jsdom');
|
||||
const { JSDOM } = jsdom;
|
||||
|
||||
require('../../../prism')
|
||||
require('../../../prism');
|
||||
// fake DOM
|
||||
global.self = {}
|
||||
global.self.Prism = Prism
|
||||
global.document = {}
|
||||
global.self = {};
|
||||
global.self.Prism = Prism;
|
||||
global.document = {};
|
||||
document.createRange = function () {
|
||||
}
|
||||
global.self.document = document
|
||||
};
|
||||
global.self.document = document;
|
||||
|
||||
require('../../../plugins/keep-markup/prism-keep-markup')
|
||||
require('../../../plugins/keep-markup/prism-keep-markup');
|
||||
|
||||
describe('Prism Keep Markup Plugin', function () {
|
||||
|
||||
|
@ -23,62 +23,62 @@ describe('Prism Keep Markup Plugin', function () {
|
|||
document.createRange = function () {
|
||||
return {
|
||||
setStart: function (node, offset) {
|
||||
start.push({ node, offset })
|
||||
start.push({ node, offset });
|
||||
},
|
||||
setEnd: function (node, offset) {
|
||||
end.push({ node, offset })
|
||||
end.push({ node, offset });
|
||||
},
|
||||
extractContents: function () {
|
||||
return new JSDOM('').window.document.createTextNode('')
|
||||
return new JSDOM('').window.document.createTextNode('');
|
||||
},
|
||||
insertNode: function (node) {
|
||||
nodes.push(node)
|
||||
nodes.push(node);
|
||||
},
|
||||
detach: function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
const beforeHighlight = Prism.hooks.all['before-highlight'][0]
|
||||
const afterHighlight = Prism.hooks.all['after-highlight'][0]
|
||||
};
|
||||
};
|
||||
const beforeHighlight = Prism.hooks.all['before-highlight'][0];
|
||||
const afterHighlight = Prism.hooks.all['after-highlight'][0];
|
||||
const env = {
|
||||
element: new JSDOM(code).window.document.getElementsByTagName('code')[0],
|
||||
language: 'javascript'
|
||||
}
|
||||
beforeHighlight(env)
|
||||
afterHighlight(env)
|
||||
return { start, end, nodes }
|
||||
};
|
||||
beforeHighlight(env);
|
||||
afterHighlight(env);
|
||||
return { start, end, nodes };
|
||||
}
|
||||
|
||||
it('should keep <span> markup', function () {
|
||||
const result = execute(`<code class="language-javascript">x<span>a</span>y</code>`)
|
||||
expect(result.start.length).to.equal(1)
|
||||
expect(result.end.length).to.equal(1)
|
||||
expect(result.nodes.length).to.equal(1)
|
||||
expect(result.nodes[0].nodeName).to.equal('SPAN')
|
||||
})
|
||||
const result = execute(`<code class="language-javascript">x<span>a</span>y</code>`);
|
||||
expect(result.start.length).to.equal(1);
|
||||
expect(result.end.length).to.equal(1);
|
||||
expect(result.nodes.length).to.equal(1);
|
||||
expect(result.nodes[0].nodeName).to.equal('SPAN');
|
||||
});
|
||||
it('should preserve markup order', function () {
|
||||
const result = execute(`<code class="language-javascript">x<a></a><b></b>y</code>`)
|
||||
expect(result.start.length).to.equal(2)
|
||||
expect(result.start[0].offset).to.equal(0)
|
||||
expect(result.start[0].node.textContent).to.equal('y')
|
||||
expect(result.start[1].offset).to.equal(0)
|
||||
expect(result.start[1].node.textContent).to.equal('y')
|
||||
expect(result.end.length).to.equal(2)
|
||||
expect(result.end[0].offset).to.equal(0)
|
||||
expect(result.end[0].node.textContent).to.equal('y')
|
||||
expect(result.end[1].offset).to.equal(0)
|
||||
expect(result.end[1].node.textContent).to.equal('y')
|
||||
expect(result.nodes.length).to.equal(2)
|
||||
expect(result.nodes[0].nodeName).to.equal('A')
|
||||
expect(result.nodes[1].nodeName).to.equal('B')
|
||||
})
|
||||
const result = execute(`<code class="language-javascript">x<a></a><b></b>y</code>`);
|
||||
expect(result.start.length).to.equal(2);
|
||||
expect(result.start[0].offset).to.equal(0);
|
||||
expect(result.start[0].node.textContent).to.equal('y');
|
||||
expect(result.start[1].offset).to.equal(0);
|
||||
expect(result.start[1].node.textContent).to.equal('y');
|
||||
expect(result.end.length).to.equal(2);
|
||||
expect(result.end[0].offset).to.equal(0);
|
||||
expect(result.end[0].node.textContent).to.equal('y');
|
||||
expect(result.end[1].offset).to.equal(0);
|
||||
expect(result.end[1].node.textContent).to.equal('y');
|
||||
expect(result.nodes.length).to.equal(2);
|
||||
expect(result.nodes[0].nodeName).to.equal('A');
|
||||
expect(result.nodes[1].nodeName).to.equal('B');
|
||||
});
|
||||
it('should keep last <span> markup', function () {
|
||||
const result = execute(`<code class="language-javascript">xy<span>a</span></code>`)
|
||||
expect(result.start.length).to.equal(1)
|
||||
expect(result.end.length).to.equal(1)
|
||||
expect(result.nodes.length).to.equal(1)
|
||||
expect(result.nodes[0].nodeName).to.equal('SPAN')
|
||||
})
|
||||
const result = execute(`<code class="language-javascript">xy<span>a</span></code>`);
|
||||
expect(result.start.length).to.equal(1);
|
||||
expect(result.end.length).to.equal(1);
|
||||
expect(result.nodes.length).to.equal(1);
|
||||
expect(result.nodes[0].nodeName).to.equal('SPAN');
|
||||
});
|
||||
// The markup is removed if it's the last element and the element's name is a single letter: a(nchor), b(old), i(talic)...
|
||||
// https://github.com/PrismJS/prism/issues/1618
|
||||
/*
|
||||
|
@ -90,4 +90,4 @@ describe('Prism Keep Markup Plugin', function () {
|
|||
expect(result.nodes[0].nodeName).to.equal('A')
|
||||
})
|
||||
*/
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue