Travis build: 407

This commit is contained in:
30secondsofcode
2019-08-26 10:03:49 +00:00
parent 2776b342dd
commit 983bc086c1
57 changed files with 376 additions and 873 deletions

View File

@ -1,4 +1,4 @@
const config = require('../../config');
const config = require('../../config')
const getMarkDownAnchor = paragraphTitle =>
paragraphTitle
@ -6,24 +6,23 @@ const getMarkDownAnchor = paragraphTitle =>
.toLowerCase()
.replace(/[^\w\- ]+/g, '')
.replace(/\s/g, '-')
.replace(/\-+$/, '');
.replace(/\-+$/, '')
// Creates an object from pairs
const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {});
const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {})
// Optimizes nodes in an HTML document
const optimizeNodes = (data, regexp, replacer) => {
let count = 0;
let output = data;
let count = 0
let output = data
do {
output = output.replace(regexp, replacer);
count = 0;
while (regexp.exec(output) !== null) ++count;
} while (count > 0);
return output;
};
output = output.replace(regexp, replacer)
count = 0
while (regexp.exec(output) !== null) ++count
} while (count > 0)
return output
}
// Capitalizes the first letter of a string
const capitalize = (str, lowerRest = false) =>
str.slice(0, 1).toUpperCase() +
(lowerRest ? str.slice(1).toLowerCase() : str.slice(1));
str.slice(0, 1).toUpperCase() + (lowerRest ? str.slice(1).toLowerCase() : str.slice(1))
const prepTaggedData = tagDbData =>
[...new Set(Object.entries(tagDbData).map(t => t[1][0]))]
.filter(v => v)
@ -32,23 +31,18 @@ const prepTaggedData = tagDbData =>
? 1
: capitalize(b, true) === 'Uncategorized'
? -1
: a.localeCompare(b),
);
: a.localeCompare(b)
)
const makeExamples = data => {
data =
data.slice(0, data.lastIndexOf(`\`\`\`${config.language}`)).trim() +
misc.collapsible(
'Examples',
data.slice(
data.lastIndexOf(`\`\`\`${config.language}`),
data.lastIndexOf('```'),
) + data.slice(data.lastIndexOf('```')),
);
return `${data}\n<br>${misc.link(
'⬆ Back to top',
misc.anchor('Contents'),
)}\n\n`;
};
data.slice(data.lastIndexOf(`\`\`\`${config.language}`), data.lastIndexOf('```')) +
data.slice(data.lastIndexOf('```'))
)
return `${data}\n<br>${misc.link('⬆ Back to top', misc.anchor('Contents'))}\n\n`
}
module.exports = {
getMarkDownAnchor,
@ -56,5 +50,5 @@ module.exports = {
optimizeNodes,
capitalize,
prepTaggedData,
makeExamples,
};
makeExamples
}