pid / speakingurl

Generate a slug – transliteration with a lot of options
http://pid.github.io/speakingurl/
BSD 3-Clause "New" or "Revised" License
1.12k stars 84 forks source link

Consider removing apostrophe when slugifying English contractions #105

Open zzzzBov opened 7 years ago

zzzzBov commented 7 years ago

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
pid commented 7 years ago

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.

zzzzBov commented 7 years ago

@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.

niftylettuce commented 6 years ago

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