diff --git a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilderV2.swift b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilderV2.swift
index 8c70bc027..0a4f93b59 100644
--- a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilderV2.swift
+++ b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilderV2.swift
@@ -116,7 +116,7 @@ struct AttributedStringBuilderV2: AttributedStringBuilderProtocol {
switch tag {
case "h1", "h2", "h3", "h4", "h5", "h6":
- let level = Int(String(tag.dropFirst())) ?? 1
+ let level = max(3, Int(String(tag.dropFirst())) ?? 1)
let size: CGFloat = UIFont.systemFontSize + CGFloat(6 - level) * 2
content = attributedString(from: childElement, preserveFormatting: preserveFormatting, listTag: listTag, listIndex: &childIndex, indentLevel: indentLevel)
content.setFontPreservingSymbolicTraits(UIFont.boldSystemFont(ofSize: size))
diff --git a/UnitTests/Sources/AttributedStringBuilderTests.swift b/UnitTests/Sources/AttributedStringBuilderTests.swift
index 535f6c6a0..20034d8cc 100644
--- a/UnitTests/Sources/AttributedStringBuilderTests.swift
+++ b/UnitTests/Sources/AttributedStringBuilderTests.swift
@@ -35,7 +35,7 @@ class AttributedStringBuilderV1Tests: XCTestCase {
XCTAssertEqual(attributedString.runs.count, 11) // newlines hold no attributes
let pointSizes = attributedString.runs.compactMap(\.uiKit.font?.pointSize)
- XCTAssertEqual(pointSizes, [24, 22, 20, 18, 16, 14])
+ XCTAssertEqual(pointSizes, [23, 23, 23, 21, 19, 17])
} else {
XCTAssert(attributedString.runs.count == 6)
@@ -173,7 +173,13 @@ class AttributedStringBuilderV1Tests: XCTestCase {
return
}
- if !AttributedStringBuilder.useNextGenHTMLParser {
+ if AttributedStringBuilder.useNextGenHTMLParser {
+ XCTAssertEqual(h1Font, h2Font)
+ XCTAssertEqual(h2Font, h3Font)
+
+ XCTAssert(h1Font.pointSize > UIFont.preferredFont(forTextStyle: .body).pointSize)
+ XCTAssert(h1Font.pointSize <= 23)
+ } else {
XCTAssertEqual(h1Font, h2Font)
XCTAssertEqual(h2Font, h3Font)