mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 08:37:25 +02:00
Add Prettier Formatting (#258)
* Add Prettier formatting to source files and example files, and check that Prettier formatting is maintained on PRs * Remove trailing-comma as we are using Node 6 on Circle * Use latest Node 6 LTS version in Circle * Remove unused test
This commit is contained in:
parent
0cead4b6f9
commit
65421db62e
50 changed files with 1376 additions and 1350 deletions
|
@ -8,33 +8,33 @@
|
|||
module.exports = string => {
|
||||
// var accents = "àáäâèéëêìíïîòóöôùúüûñç";
|
||||
const accents =
|
||||
"\u00e0\u00e1\u00e4\u00e2\u00e8" +
|
||||
"\u00e9\u00eb\u00ea\u00ec\u00ed\u00ef" +
|
||||
"\u00ee\u00f2\u00f3\u00f6\u00f4\u00f9" +
|
||||
"\u00fa\u00fc\u00fb\u00f1\u00e7";
|
||||
'\u00e0\u00e1\u00e4\u00e2\u00e8' +
|
||||
'\u00e9\u00eb\u00ea\u00ec\u00ed\u00ef' +
|
||||
'\u00ee\u00f2\u00f3\u00f6\u00f4\u00f9' +
|
||||
'\u00fa\u00fc\u00fb\u00f1\u00e7';
|
||||
|
||||
const without = "aaaaeeeeiiiioooouuuunc";
|
||||
const without = 'aaaaeeeeiiiioooouuuunc';
|
||||
|
||||
let slug = string
|
||||
.toString()
|
||||
// Handle uppercase characters
|
||||
.toLowerCase()
|
||||
// Handle accentuated characters
|
||||
.replace(new RegExp("[" + accents + "]", "g"), c => {
|
||||
.replace(new RegExp('[' + accents + ']', 'g'), c => {
|
||||
return without.charAt(accents.indexOf(c));
|
||||
})
|
||||
// Replace `.`, `(` and `?` with blank string like Github does
|
||||
.replace(/\.|\(|\?/g, "")
|
||||
.replace(/\.|\(|\?/g, '')
|
||||
// Dash special characters
|
||||
.replace(/[^a-z0-9]/g, "-")
|
||||
.replace(/[^a-z0-9]/g, '-')
|
||||
// Compress multiple dash
|
||||
.replace(/-+/g, "-")
|
||||
.replace(/-+/g, '-')
|
||||
// Trim dashes
|
||||
.replace(/^-|-$/g, "");
|
||||
.replace(/^-|-$/g, '');
|
||||
|
||||
// Add trailing `-` if string contains ` ...` in the end like Github does
|
||||
if (/\s[.]{1,}/.test(string)) {
|
||||
slug += "-";
|
||||
slug += '-';
|
||||
}
|
||||
|
||||
return slug;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue