gregjacobs / Autolinker.js

Utility to Automatically Link URLs, Email Addresses, Phone Numbers, Twitter handles, and Hashtags in a given block of text/HTML
MIT License
1.48k stars 239 forks source link

More flexible hashtags #130

Open simison opened 9 years ago

simison commented 9 years ago

Inspired by the discussion about mentions #119 — that all could be applied to hashtags as well. Updating more features at once in a backwards incompatible way makes sense, rather than having many of them in a row.

E.g.:

Autolinker.link( text, {
    hashtag: { 
        service: 'custom', // twitter (default), facebook, instagram, tumblr, google
        regex: '[A-Z][a-zA-Z0-9]{2, 13}',
        prefix: '#',
        template: 'http://my.website.com/{hashtag}' // 
    }
} );
gregjacobs commented 9 years ago

Hey, I like it. Autolinker will need some structural changes to support it, but would def like to move in that direction.

Btw, there's no need to break backward compatibility with this change. The hashtag option can accept either a string or an object. The string form will continue to accept the service name, while the object can be provided to provide more customizations.

simison commented 9 years ago

@gregjacobs even better so!

olafleur commented 7 years ago

As far as I can tell, the last version handles the more flexible hashtags. Closing.

andryfailli commented 7 years ago

Hi, I'm using v1.4.2 and I've configured autolinker with custom hashtag service as suggested in this issue.

Autolinker.link(text, {
    hashtag: { 
        service: 'custom', // twitter (default), facebook, instagram, tumblr, google
        regex: '[A-Z][a-zA-Z0-9]{2, 13}',
        prefix: '#',
        template: 'http://my.website.com/{hashtag}' // 
    }
})

But I'm receiving the following error

invalid hashtag cfg - see docs

Also in docs I didn't find any mention about the option to customize the hashtag urls... Is this feature supported?