speakingurl icon indicating copy to clipboard operation
speakingurl copied to clipboard

Consider removing apostrophe when slugifying English contractions

Open zzzzBov opened this issue 8 years ago • 3 comments

rather than converting don't and can't to don-t and can-t, consider adding a custom conversion from "'" to "" for English to turn them into dont and cant respectively.

In the odd case where single quotes are used as an actual quotation, they are typically surrounded by spaces:

Isn't this an 'example'?

would become

isnt-this-an-example

zzzzBov avatar Jul 26 '17 22:07 zzzzBov

It's not a quick change. Because of this config option mark and the order of replacements. In short, at the moment I haven't the time for deeper changes, so I would recommend to go with this solution:

var options = {
	    custom: {
                  "'": ""
            }
	};

var mySlug = require('speakingurl').createSlug(options);

var slug = mySlug("Isn't this an 'example'?");
console.log(slug); // Output: isnt-this-an-example

I use it all the time to configure an own project specific slug-function.

Hope it helps; if you have the time to send a pull request, feel free ;-) I think it would be a nice feature.

pid avatar Jul 30 '17 16:07 pid

@pid

Thanks for the response. I've already been using the {custom:...} solution, but I figured I'd call out the possibility for improvement around this feature.

zzzzBov avatar Jul 31 '17 14:07 zzzzBov

I think that having this built in would be nice. I don't see why anyone would want foo-s vs. foos.

niftylettuce avatar Dec 11 '17 22:12 niftylettuce