use Twitter::Extractor for creating links #2502
Merged
Conversation
|
cc @abcang |
|
I think simple replacement is dangerous, I have an idea to use for example, html, links = encode_and_link_urls("@masakki Hello, world!, http://example.com/?x=@masarakki", [])
#=> html: "@masarakki Hello, world!, \1", links: ['<a href="http://example.com/?x=@masarakki">http://example.com/?x=@masarakki</a>']
html, links = link_mentions(html, link)
#=> html: "\2 Hello, world!, \1", links: ['<a href="http://example.com/?x=@masarakki>...</a>' '<a href="/users/1">@masarakki</a>']
html = build(html, links)
#=> '<a href="/usrs/1>@masarakki</a> Hello, world! <a href="http://example.com...'
....of cource, |
|
I think that it is safe to replace it after extracting the target like twitter-text. |
app/lib/formatter.rb
Outdated
| rel: 'nofollow noopener', | ||
| } | ||
| result = '' | ||
| def rewite(text, entities) |
Gargron
May 2, 2017
Member
Is this meant to be called rewrite?
Is this meant to be called rewrite?
masarakki
May 5, 2017
Author
Contributor
oh sorry
oh sorry
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
I found a problem in creating link tag.
Conditions:
=@username(in mentions)For example,
In this case,
At first,
encode_and_link_urlsconvert url to<a href="http://example.com/?x=@masarakki" rel="nofollow ...">http://example.com/?x=@masarakki</a>.Then, because of
=@usernamematches to Account::ACCOUNT_RE,@masarakkiwill be convert to link bylink_mentions.At last, it will be
<a href="http://example.com/?x=<a href="/...">@masarakki</a> rel="nofollow ...">Sample: https://friends.nico/@masarakki/2717988