File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Tests/MarkdownTests/Inline Nodes Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -25,4 +25,39 @@ final class LineBreakTests: XCTestCase {
2525 let paragraph = document. child ( at: 0 ) as! Paragraph
2626 XCTAssertTrue ( Array ( paragraph. children) [ 1 ] is LineBreak )
2727 }
28+
29+ /// Test that hard line breaks work with spaces (two or more).
30+ func testSpaceHardLineBreak( ) {
31+ let source = """
32+ Paragraph. \( " " )
33+ Still the same paragraph.
34+ """
35+ let document = Document ( parsing: source)
36+ let paragraph = document. child ( at: 0 ) as! Paragraph
37+ XCTAssertTrue ( Array ( paragraph. children) [ 1 ] is LineBreak )
38+ }
39+
40+ /// Test that hard line breaks work with a slash.
41+ func testSlashHardLineBreak( ) {
42+ let source = """
43+ Paragraph. \\
44+ Still the same paragraph.
45+ """
46+ let document = Document ( parsing: source)
47+ let paragraph = document. child ( at: 0 ) as! Paragraph
48+ XCTAssertTrue ( Array ( paragraph. children) [ 1 ] is LineBreak )
49+ }
50+
51+ /// Sanity test that a multiline text without hard breaks doesn't return line breaks.
52+ func testLineBreakWithout( ) {
53+ let source = """
54+ Paragraph.
55+ Same line text.
56+ """
57+ let document = Document ( parsing: source)
58+
59+ let paragraph = document. child ( at: 0 ) as! Paragraph
60+ XCTAssertFalse ( Array ( paragraph. children) [ 1 ] is LineBreak )
61+ XCTAssertEqual ( Array ( paragraph. children) [ 1 ] . withoutSoftBreaks? . childCount, nil )
62+ }
2863}
You can’t perform that action at this time.
0 commit comments