-
Notifications
You must be signed in to change notification settings - Fork 76
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
Parsing issue with multiple links #1
Comments
Great work! We should also add some tests to cover this. Could you create a pull request with the tests and this fix? Otherwise I can have a look at it. |
Sure I'll submit a pull request soon. I'm not using your library directly as a Pod because I need to customise the attributes I'm applying for each element, so it's a little more work. I'll do it soon though! |
Thanks! Maybe we could add a formatting block to each method that adds a specific parsing rule? That way you could use the regexes defined in the project but set your own formatting if needed. |
Fix for a crash when attempting to create a URL from a string that contains emoji (including test)
I'm using your library and I came across some markdown that crashed the parser:
What was happening was the first link was being matched but the regex was too greedy and also matched all the text in between the start of the first link and the end of the last link. When the URL was parsed it was obviously invalid and hance
url
wasnil
. Once we attempted to add the attribute with thenil
url
value it crashed the application.The regex I came up with to fix this was:
The change is the addition of the
?
inside the\\[.*?\\]
part. This means it will lazily match, rather than greedily consuming as much as it can. I also changed the link part to use\S
because URL's should not contain whitespace. Ideally we'd only match for valid URL characters.The text was updated successfully, but these errors were encountered: