Fix rendering issues with ) in links

This commit is contained in:
Nicolas Werner 2021-04-24 14:31:59 +02:00
parent 6fd485a74a
commit 72d74ac59f
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -59,7 +59,7 @@ const QRegularExpression url_regex(
// match an URL, that is not quoted, i.e. // match an URL, that is not quoted, i.e.
// vvvvvv match quote via negative lookahead/lookbehind vv // vvvvvv match quote via negative lookahead/lookbehind vv
// vvvv atomic match url -> fail if there is a " before or after vvv // vvvv atomic match url -> fail if there is a " before or after vvv
R"((?<!["'])(?>((www\.(?!\.)|[a-z][a-z0-9+.-]*://)[^\s<>'"]+[^!,\.\s<>'"\]\)\:]))(?!["']))"); R"(\b(?<!["'])(?>((www\.(?!\.)|[a-z][a-z0-9+.-]*://)[^\s'"]+[^!,\.\s'"\]\)\:]))(?!["'])\b)");
// match any markdown matrix.to link. Capture group 1 is the link name, group 2 is the target. // match any markdown matrix.to link. Capture group 1 is the link name, group 2 is the target.
static const QRegularExpression matrixToMarkdownLink( static const QRegularExpression matrixToMarkdownLink(
R"(\[(.*?)(?<!\\)\]\((https://matrix.to/#/.*?\)))"); R"(\[(.*?)(?<!\\)\]\((https://matrix.to/#/.*?\)))");