Fix error when whitespace occurs at end of <pre>
I had the state machine correct and made a mistake when converting it to code :/
This commit is contained in:
parent
a93a53e8d3
commit
e01664565f
|
@ -19,7 +19,15 @@ import Foundation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct BlockStateMachine {
|
struct BlockStateMachine {
|
||||||
|
#if false
|
||||||
|
var blockState: BlockState = .start {
|
||||||
|
didSet {
|
||||||
|
print("\(oldValue) -> \(blockState)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
var blockState: BlockState = .start
|
var blockState: BlockState = .start
|
||||||
|
#endif
|
||||||
let blockBreak: String
|
let blockBreak: String
|
||||||
let lineBreak: String
|
let lineBreak: String
|
||||||
let listIndentForContentOutsideItem: String
|
let listIndentForContentOutsideItem: String
|
||||||
|
@ -70,7 +78,8 @@ extension BlockStateMachine {
|
||||||
blockState = .preformattedEmptyBlock(depth: depth)
|
blockState = .preformattedEmptyBlock(depth: depth)
|
||||||
case .afterPreStartTagWithLeadingWhitespace(let depth):
|
case .afterPreStartTagWithLeadingWhitespace(let depth):
|
||||||
blockState = .preformattedEmptyBlockWithLeadingWhitespace(depth: depth)
|
blockState = .preformattedEmptyBlockWithLeadingWhitespace(depth: depth)
|
||||||
case .preformattedNonEmptyBlockWithTrailingWhitespace(depth: _):
|
case .preformattedNonEmptyBlockWithTrailingWhitespace(let depth):
|
||||||
|
blockState = .preformattedEmptyBlockWithLeadingWhitespace(depth: depth)
|
||||||
temporaryBuffer.append(blockBreak)
|
temporaryBuffer.append(blockBreak)
|
||||||
case .preformattedEmptyBlockWithLeadingWhitespace(depth: _):
|
case .preformattedEmptyBlockWithLeadingWhitespace(depth: _):
|
||||||
break
|
break
|
||||||
|
|
|
@ -687,5 +687,13 @@ final class AttributedStringConverterTests: XCTestCase {
|
||||||
XCTAssertEqual(convert("<p>a</p><p><br>b</p><p>c</p>"), result2)
|
XCTAssertEqual(convert("<p>a</p><p><br>b</p><p>c</p>"), result2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testWhitespaceAtEndOfPre() {
|
||||||
|
let result = NSAttributedString(string: "a", attributes: [
|
||||||
|
.font: monospaceFont,
|
||||||
|
.paragraphStyle: NSParagraphStyle.default,
|
||||||
|
.foregroundColor: color,
|
||||||
|
])
|
||||||
|
XCTAssertEqual(convert("<pre>a </pre>"), result)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue