Skip to content

Instantly share code, notes, and snippets.

@sayrer
Created August 24, 2020 03:37
Show Gist options
  • Save sayrer/97c4d5a0ea15eada487c4fc0b2916261 to your computer and use it in GitHub Desktop.
Save sayrer/97c4d5a0ea15eada487c4fc0b2916261 to your computer and use it in GitHub Desktop.
Twitter Text in Ruby
require "rust_bindings/ruby/twittertext"
autolinker = Twittertext::Autolinker.new
puts autolinker.autolink "Just setting up my $TWTR or #TWTR or @twitter? Please visit https://twiter.com."
# prints
# Just setting up my <a href="https://twitter.com/search?q=%24TWTR" title="$TWTR" class="tweet-url cashtag">$TWTR</a> or
# <a href="https://twitter.com/search?q=%23TWTR" title="#TWTR" class="tweet-url hashtag">#TWTR</a> or
# @<a class="tweet-url username" href="https://twitter.com/twitter">twitter</a>?
# Please visit <a href="https://twiter.com">https://twiter.com</a>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment