From 8ca98a15699b11d49ddc23431af99ccecf11cb44 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Thu, 2 Aug 2018 13:25:41 +0300 Subject: [PATCH] Codacy style updates for web.js --- scripts/web.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/scripts/web.js b/scripts/web.js index 992108db0..4db1c0cf3 100644 --- a/scripts/web.js +++ b/scripts/web.js @@ -148,7 +148,7 @@ if(!util.isTravisCI() || (util.isTravisCI() && (process.env['TRAVIS_EVENT_TYPE'] let commits = resCommits.headers.link.split('&').slice(-1)[0].replace(/[^\d]/g, ''), contribs = resContributors.headers.link.split('&').slice(-1)[0].replace(/[^\d]/g, ''), stars = resStars.headers.link.split('&').slice(-1)[0].replace(/[^\d]/g, ''); - indexStaticFile = indexStaticFile.replace(/\$snippet-count/g, Object.keys(snippets).length).replace(/\$commit-count/g, commits).replace(/\$contrib-count/g,contribs).replace(/\$star-count/g, stars); + indexStaticFile = indexStaticFile.replace(/\$snippet-count/g, Object.keys(snippets).length).replace(/\$commit-count/g, commits).replace(/\$contrib-count/g, contribs).replace(/\$star-count/g, stars); indexStaticFile = minify(indexStaticFile, { collapseBooleanAttributes: true, collapseWhitespace: true, @@ -186,12 +186,12 @@ try { for (let tag of [...new Set(Object.entries(tagDbData).map(t => t[1][0]))] .filter(v => v) .sort((a, b) => util.capitalize(a, true) === 'Uncategorized' ? 1 : util.capitalize(b, true) === 'Uncategorized' ? -1 : a.localeCompare(b))) { - output += '

' + - md - .render(`${util.capitalize(tag, true)}\n`) - .replace(/

/g, '') - .replace(/<\/p>/g, '') + - '

'; + output += '

' + + md + .render(`${util.capitalize(tag, true)}\n`) + .replace(/

/g, '') + .replace(/<\/p>/g, '') + + '

'; for (let taggedSnippet of Object.entries(tagDbData).filter(v => v[1][0] === tag)) output += md .render(`[${taggedSnippet[0]}](./${tag}#${taggedSnippet[0].toLowerCase()})\n`) @@ -206,7 +206,7 @@ try { for (let tag of [...new Set(Object.entries(tagDbData).map(t => t[1][0]))] .filter(v => v) .sort((a, b) => util.capitalize(a, true) === 'Uncategorized' ? 1 : util.capitalize(b, true) === 'Uncategorized' ? -1 : a.localeCompare(b))) { - let localOutput = output.replace(/\$tag/g, util.capitalize(tag)).replace(new RegExp(`./${tag}#`,'g'),'#'); + let localOutput = output.replace(/\$tag/g, util.capitalize(tag)).replace(new RegExp(`./${tag}#`, 'g'), '#'); localOutput += md .render(`## ${util.capitalize(tag, true)}\n`) .replace(/

/g, '

'); @@ -216,21 +216,21 @@ try { md .render(`\n${snippets[taggedSnippet[0] + '.md']}`) .replace(/

/g, `${taggedSnippet[1].includes('advanced')?'advanced':''}

`) + .replace(/<\/h3>/g, `${taggedSnippet[1].includes('advanced') ? 'advanced' : ''}`) .replace(/<\/h3>/g, '
') .replace(/
([^\0]*?)<\/code><\/pre>/gm, (match, p1) => `
${Prism.highlight(unescapeHTML(p1), Prism.languages.javascript)}
`) .replace(/<\/pre>\s+
📋 Copy to clipboard' +
         '
'; - // Add the ending static part - localOutput += `\n${endPart + '\n'}`; - // Optimize punctuation nodes - localOutput = util.optimizeNodes(localOutput, /([^\0<]*?)<\/span>([\n\r\s]*)([^\0]*?)<\/span>/gm, (match, p1, p2, p3) => `${p1}${p2}${p3}`); - // Optimize operator nodes - localOutput = util.optimizeNodes(localOutput, /([^\0<]*?)<\/span>([\n\r\s]*)([^\0]*?)<\/span>/gm, (match, p1, p2, p3) => `${p1}${p2}${p3}`); - // Optimize keyword nodes - localOutput = util.optimizeNodes(localOutput, /([^\0<]*?)<\/span>([\n\r\s]*)([^\0]*?)<\/span>/gm, (match, p1, p2, p3) => `${p1}${p2}${p3}`); - pagesOutput.push({'tag': tag,'content': localOutput}); + // Add the ending static part + localOutput += `\n${endPart + '\n'}`; + // Optimize punctuation nodes + localOutput = util.optimizeNodes(localOutput, /([^\0<]*?)<\/span>([\n\r\s]*)([^\0]*?)<\/span>/gm, (match, p1, p2, p3) => `${p1}${p2}${p3}`); + // Optimize operator nodes + localOutput = util.optimizeNodes(localOutput, /([^\0<]*?)<\/span>([\n\r\s]*)([^\0]*?)<\/span>/gm, (match, p1, p2, p3) => `${p1}${p2}${p3}`); + // Optimize keyword nodes + localOutput = util.optimizeNodes(localOutput, /([^\0<]*?)<\/span>([\n\r\s]*)([^\0]*?)<\/span>/gm, (match, p1, p2, p3) => `${p1}${p2}${p3}`); + pagesOutput.push({'tag': tag, 'content': localOutput}); } // Minify output pagesOutput.forEach(page => {