Fixed the link color and improved link dection in code blocks (#2466)

This commit is contained in:
Mauro
2024-02-14 17:45:23 +01:00
committed by GitHub
parent 2f983d6ecc
commit 99d6babc30
3 changed files with 29 additions and 5 deletions
@@ -493,11 +493,22 @@ class AttributedStringBuilderTests: XCTestCase {
checkAttachment(attributedString: attributedStringFromPlain2, expectedRuns: 1)
}
func testLinksAreIgnoredInCode() {
let htmlString = "<pre><code>test https://matrix.org test</code></pre>"
let attributedStringFromHTML = attributedStringBuilder.fromHTML(htmlString)
func testURLsAreIgnoredInCode() {
var htmlString = "<pre><code>test https://matrix.org test</code></pre>"
var attributedStringFromHTML = attributedStringBuilder.fromHTML(htmlString)
XCTAssert(attributedStringFromHTML?.runs.count == 1)
XCTAssertNil(attributedStringFromHTML?.link)
htmlString = "<pre><code>matrix.org</code></pre>"
attributedStringFromHTML = attributedStringBuilder.fromHTML(htmlString)
XCTAssert(attributedStringFromHTML?.runs.count == 1)
XCTAssertNil(attributedStringFromHTML?.link)
}
func testHyperlinksAreNotIgnoredInCode() {
let htmlString = "<pre><code>test <a href=\"https://matrix.org\">matrix</a> test</code></pre>"
let attributedStringFromHTML = attributedStringBuilder.fromHTML(htmlString)
checkLinkIn(attributedString: attributedStringFromHTML, expectedLink: "https://matrix.org", expectedRuns: 3)
}
func testUserMentionIsIgnoredInCode() {