Due to scenarios wherein a formatted link ended up as part of a larger
raw link after parsing, change the containment check to an overlap check
and add appropriate tests for these edge cases.
Testing with #6542 surfaced a crash scenario, caused by formatted links
that had URLs in the display text, for example
[mean example - https://osu.ppy.sh](https://osu.ppy.sh)
In that case the outer Markdown link would get picked up once, and then
reduced to the link text when looking for other links, leading to it
being picked up again the second time when the raw link is found.
Add a check in the raw link parsing path that ensures that the found
URL is not a part of a bigger, pre-existing link.
Extend the Markdown parsing regex to allow parsing so-called inline
links. Within the parenthesis () part of the Markdown URL syntax,
introduce a new capturing group:
(
\s+ // whitespace between actual URL and inline title
(?<title> // start of "title" named group
"" // opening double quote (doubled inside @ string)
(
[^""] // any character but a double quote
| // or
(?<=\\) // the next character should be preceded by a \
"" // a double quote
)* // zero or more times
"" // closing double quote
)
)? // the whole group is optional
This allows for parsing the inline links as-provided by web. Correctness
is displayed by the passing tests.
While reviewing #6542 it became apparent that there was another Markdown
link format variant, used in comments that came from the web API, called
the "inline link" style. It allows to specify the tooltip title within
the actual URL portion, as such:
[link text](https://osu.ppy.sh "tooltip text")
Add tests with a couple of easy and trickier examples of such a format.
Moreover, add a new edge case of a Markdown link with a link inside
the display text, which during tests was detected to be problematic.