left: class implementation, right: my implementation
I found the differences in outputs through vimdiff.
The different results are in this github repo results_classimp.txt: class implementation results.txt: my implementation
#test-files/41.md
[a](url "tit")
classimp: []
my implementation: [url "tit"]
correct implementation is the class one, since there should be no link here (also the output from commonmark demo).
bug
A space should not be part of a link.
In Commonmark, when the space between the url and quote is deleted, the text is recognized as a link.
For the fix, I added an if statement before adding the link to the ArrayList toReturn that checks there is no space within the link. This prevents url "tit" from being asdded since there is a space.
#test-files/517.md
[](/uri)
classimp: [moon.jpg]
my implementation: [moon.jpg]
both have the wrong implementation. The link here would be /uri (also the output from commonmark demo).
bug
The code does not recognize that there is a picture object within the brackets because it takes that first “[” and “]” from the beginning index. Therefore, it thinks [![moon] is the bracket part and therefore moon.jpg is the link.
For the fix, I added a findfirst method that finds the closest “[” before the first “]”. Then (not depicted in the photo) I indicated that there was a sublink/ photo within and found the second “]” (the closing bracket after the current closing bracket).
This will detect that there is a sublink … and and the code does not output anything for the second snippet because it is a pciture but /uri for the second one.