twitter / twitter-text

Twitter Text Libraries. This code is used at Twitter to tokenize and parse text to meet the expectations for what can be used on the platform.
https://developer.twitter.com/en/docs/counting-characters
Apache License 2.0
3.07k stars 510 forks source link

@ on mention is outside the anchor tag #350

Closed framelita closed 2 years ago

framelita commented 3 years ago

Describe the bug When running autoLink, mention's @ sign is outside the anchor tag

To Reproduce twitter.autoLink('@TwitterSpaces')

Expected behavior Currently it's returning: @<a class="tweet-url username" href="https://twitter.com/TwitterSpaces" data-screen-name="TwitterSpaces" rel="nofollow">TwitterSpaces</a> When it's supposed to be: <a class="tweet-url username" href="https://twitter.com/TwitterSpaces" data-screen-name="TwitterSpaces" rel="nofollow">@TwitterSpaces</a>

Example on Twitter page: image image

stratgt10 commented 2 years ago

Nice

geekysrm commented 2 years ago

Hey, I found myself scratching my head with this and found the answer on one of the closed issues.

Use this: twttr.txt.autoLink('foo test @foo', { usernameIncludeSymbol: true } );

jamauro commented 2 years ago

Thanks @geekysrm!

framelita commented 2 years ago

Thanks @geekysrm!