Skip to content

Commit

Permalink
Merge pull request #60 from jimstudt/crlf
Browse files Browse the repository at this point in the history
Recognize CR-LF pairs as newlines for the purposes of Paragraph separation.
  • Loading branch information
JohnSundell authored Apr 7, 2023
2 parents fb342e1 + 2b1a569 commit bcc9f21
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Ink/Internal/FormattedText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private extension FormattedText {
continue
}

guard !nextCharacter.isAny(of: ["\n", "#", "<", "`", "-"]) else {
guard !nextCharacter.isAny(of: ["\n", "#", "<", "`", "-", "\r\n"]) else {
break
}

Expand Down
12 changes: 12 additions & 0 deletions Tests/InkTests/TextFormattingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ final class TextFormattingTests: XCTestCase {
XCTAssertEqual(html, "<p>Hello, world!</p>")
}

func testParagraphs() {
let html = MarkdownParser().html(from: "Hello, world!\n\nAgain.")
XCTAssertEqual(html, "<p>Hello, world!</p><p>Again.</p>")
}

func testDosParagraphs() {
let html = MarkdownParser().html(from: "Hello, world!\r\n\r\nAgain.")
XCTAssertEqual(html, "<p>Hello, world!</p><p>Again.</p>")
}

func testItalicText() {
let html = MarkdownParser().html(from: "Hello, *world*!")
XCTAssertEqual(html, "<p>Hello, <em>world</em>!</p>")
Expand Down Expand Up @@ -167,6 +177,8 @@ extension TextFormattingTests {
static var allTests: Linux.TestList<TextFormattingTests> {
return [
("testParagraph", testParagraph),
("testParagraphs", testParagraphs),
("testDosParagraphs", testDosParagraphs),
("testItalicText", testItalicText),
("testBoldText", testBoldText),
("testItalicBoldText", testItalicBoldText),
Expand Down

0 comments on commit bcc9f21

Please sign in to comment.