Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept HTML markup for links first, then parse URLs #60

Closed
MaffooBristol opened this issue Apr 11, 2018 · 2 comments
Closed

Accept HTML markup for links first, then parse URLs #60

MaffooBristol opened this issue Apr 11, 2018 · 2 comments

Comments

@MaffooBristol
Copy link

Hi, thanks for the module. Unfortunately it doesn't do what I was expecting, so I won't be using it right now. But one suggestion I have is to also parse actual HTML for links. For example:

image

I know I can just change the way the content of the variable is printed and use dangerouslySetInnerHtml or whatever it's named, but I don't really want to... dangerously set inner HTML. I only want it to run for links, which is why a quick google brought up this module.

Would it be possible to attempt to convert the <a href="http://www.google.com">Google</a> instances first and then, if failing to find them, convert the actual link inside? Otherwise you get the weird bug seen above.

Thanks
Matt

@tasti
Copy link
Owner

tasti commented May 3, 2018

The screenshot you shared is the expected (default) behavior.

What you're doing seems to be best solved using dangerouslySetInnerHTML, as you suggested. We don't intend this library to be a full-fledged html parser, which is what it'd take to solve the scenario you've described.

However, you can write a custom matchDecorator (follow https://github.com/tasti/react-linkify/blob/master/src/decorators/defaultMatchDecorator.js) to implement your own parser. This is probably the way to go.

I'll close this issue, but if you need more guidance feel free to re-open.

@tasti tasti closed this as completed May 3, 2018
@MaffooBristol
Copy link
Author

Thanks. I just went for a different route and I entirely understand that you don't want to bloat the module with extra stuff like that. Cheers for getting back to me on it though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants