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.
Allow users to put both balanced round parentheses, as well as
unbalanced escaped ones, in old style link text. The implementation
is the same as for Markdown and new style links, except for swapping
all instances of
\[\]
to
\(\)
for obvious reasons (different type of parenthesis requiring escaping).
Tests also included.