Fix inline code being rendered as blocks. (#5017)

* Fix inline code being rendered as blocks.

And make blocks non-greedy as well as only scrolling when needed.

* Rename the bubble layout priorities.

* Add an InlineCode attribute so that the builder also strips links from these too.

* Split up the snapshot tests into individual cases.

This should make it much easier to see *what* has changed when regenerating.
This commit is contained in:
Doug
2026-01-28 11:46:13 +00:00
committed by GitHub
parent 3d5269fa19
commit fa200cfedb
67 changed files with 324 additions and 83 deletions
@@ -32,7 +32,7 @@ class AttributedStringBuilderTests: XCTestCase {
}
func testRenderHTMLStringWithPreCode() {
guard let attributedString = attributedStringBuilder.fromHTML(HTMLFixtures.codeBlocks.rawValue) else {
guard let attributedString = attributedStringBuilder.fromHTML(HTMLFixtures.code.rawValue) else {
XCTFail("Could not build the attributed string")
return
}
@@ -46,7 +46,7 @@ class AttributedStringBuilderTests: XCTestCase {
return
}
XCTAssertEqual(regex.numberOfMatches(in: string, options: [], range: .init(location: 0, length: string.count)), 13)
XCTAssertEqual(regex.numberOfMatches(in: string, options: [], range: .init(location: 0, length: string.count)), 23)
}
func testRenderHTMLStringWithLink() {
@@ -349,7 +349,7 @@ class AttributedStringBuilderTests: XCTestCase {
}
let coalescedComponents = attributedString.formattedComponents
XCTAssertEqual(coalescedComponents.count, 3)
XCTAssertEqual(coalescedComponents.count, 1)
guard let component = coalescedComponents.first else {
XCTFail("Could not get the first component")