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.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PROBLEM
Ink does not currently parse URLs with parenthesis
()
correctly, because it reads until the first closing parenthesis)
.Example
Wikipedia has numerous links like this.
Github parsing: markdown example
Raw markdown:
[markdown example](https://en.wikipedia.org/wiki/Service_(systems_architecture))
SOLUTION
Use a balancing approach and count how many new opening parenthesis
(
appear to ensure that reading continues until the final closing parenthesis is encountered.Other solutions
I saw that there was already a PR that was a couple years old by nickd that hadn't been merged. It took the approach of counting opening parenthesis after reading ended, then continue reading until the final parenthesis is closed (accounting for new opening parenthesis).
I tried my tests on both solutions, and they both pass. I also ran some performance tests and they are essentially equal (0.0000X difference) in that regard.
If that solution is merged instead, I'm happy to close this PR.
Feel free to make any changes you want to the PR.