Fixed slugify function
This commit is contained in:
parent
15c51eb479
commit
a1c92708de
@ -20,7 +20,7 @@
|
|||||||
"bootstrap-tour": "~0.6.0",
|
"bootstrap-tour": "~0.6.0",
|
||||||
"ace": "#51b7cb67a63998c9c0b7d089a85c60e032a7cc17",
|
"ace": "#51b7cb67a63998c9c0b7d089a85c60e032a7cc17",
|
||||||
"pagedown-ace": "git@github.com:benweet/pagedown-ace.git#7805f240f343b5b2a05a5b9c0d4a3f5091e7a49b",
|
"pagedown-ace": "git@github.com:benweet/pagedown-ace.git#7805f240f343b5b2a05a5b9c0d4a3f5091e7a49b",
|
||||||
"pagedown-extra": "git@github.com:jmcmanus/pagedown-extra.git#cca554948c362affb1cbab3bacc3861e2d90d426",
|
"pagedown-extra": "git@github.com:jmcmanus/pagedown-extra.git#ae1547d1662e07d6530137bd3dff3a6e6c8aec3b",
|
||||||
"crel": "git@github.com:KoryNunn/crel.git#8dbda04b129fc0aec01a2a080d1cab26816e11c1",
|
"crel": "git@github.com:KoryNunn/crel.git#8dbda04b129fc0aec01a2a080d1cab26816e11c1",
|
||||||
"waitForImages": "git@github.com:alexanderdickson/waitForImages.git#~1.4.2",
|
"waitForImages": "git@github.com:alexanderdickson/waitForImages.git#~1.4.2",
|
||||||
"to-markdown": "git@github.com:benweet/to-markdown.git#jquery",
|
"to-markdown": "git@github.com:benweet/to-markdown.git#jquery",
|
||||||
|
@ -148,12 +148,10 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Slug function
|
// Slug function
|
||||||
|
var nonWordChars = XRegExp('[^\\p{L}-]', 'g');
|
||||||
utils.slugify = function(text) {
|
utils.slugify = function(text) {
|
||||||
return text.toLowerCase().replace(/\s/g, '-') // Replace spaces with -
|
return text.toLowerCase().replace(/\s/g, '-') // Replace spaces with -
|
||||||
.replace(XRegExp('[^\\p{L}]', 'g'), '') // Remove
|
.replace(nonWordChars, '') // Remove all non-word chars
|
||||||
// all
|
|
||||||
// non-word
|
|
||||||
// chars
|
|
||||||
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
||||||
.replace(/^-+/, '') // Trim - from start of text
|
.replace(/^-+/, '') // Trim - from start of text
|
||||||
.replace(/-+$/, ''); // Trim - from end of text
|
.replace(/-+$/, ''); // Trim - from end of text
|
||||||
|
Loading…
Reference in New Issue
Block a user