Repository: apple/swift-docc (swift)

Issue:
Hard breaks aren't reflected in output
### Description

The [CommonMark spec](https://spec.commonmark.org/0.30/#hard-line-break) allows writers to specify a line break (not a paragraph break) by writing two or more spaces at the end of the line, or by writing a backslash (`\`) at the end of the line.  Currently, the rendered content from DocC doesn't break the line at that location.

Example input:

```
This text should\
appear on two lines.

This is the second paragraph.
```

### Checklist

- [X] If possible, I've reproduced the issue using the `main` branch of this package.
- [X] This issue hasn't been addressed in an [existing GitHub issue](https://github.com/apple/swift-docc/issues).

rdar://101684224

Pull request:
Bug/issue #, if applicable: 

With the corresponding swift-docc-render PR, Close #477.

## Summary

Make visitLineBreak return new line instead of space to align with [CommonMark spec](https://spec.commonmark.org/0.30/#hard-line-break)

## Dependencies

- [ ] swift-docc-render PR

> Issue is tracked at https://github.com/apple/swift-docc-render/issues/697

## Testing

Update RenderContentCompilerTests.swift

## Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

- [x] Added tests
- [x] Ran the `./bin/test` script and it succeeded
- [x] Updated documentation if necessary

Patch:
diff --git a/Sources/SwiftDocC/Model/Rendering/RenderContentCompiler.swift b/Sources/SwiftDocC/Model/Rendering/RenderContentCompiler.swift
index d3a717b266..f47d46a622 100644
--- a/Sources/SwiftDocC/Model/Rendering/RenderContentCompiler.swift
+++ b/Sources/SwiftDocC/Model/Rendering/RenderContentCompiler.swift
@@ -275,7 +275,7 @@ struct RenderContentCompiler: MarkupVisitor {
     }
     
     mutating func visitLineBreak(_ lineBreak: LineBreak) -> [RenderContent] {
-        return [RenderInlineContent.text(" ")]
+        return [RenderInlineContent.text("\n")]
     }
     
     mutating func visitEmphasis(_ emphasis: Emphasis) -> [RenderContent] {


Test patch:
diff --git a/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift b/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift
index 87488caa22..e4bdd2e6a2 100644
--- a/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift
+++ b/Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift
@@ -131,4 +131,69 @@ class RenderContentCompilerTests: XCTestCase {
             XCTAssertEqual(paragraph, RenderBlockContent.Paragraph(inlineContent: [link]))
         }
     }
+    
+    func testLineBreak() throws {
+        let (bundle, context) = try testBundleAndContext(named: "TestBundle")
+        var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift))
+
+        let source = #"""
+        Backslash before new line\
+        is an explicit hard line break.
+
+        Two spaces before new line  
+        is a hard line break.
+
+        Paragraph can't end with hard line break.\
+
+        # Headings can't end with hard line break.\
+
+            Code blocks ignore\
+            hard line breaks.
+
+        A single space before new line
+        is a soft line break.
+        """#
+        let document = Document(parsing: source)
+        let expectedDump = #"""
+        Document
+        ├─ Paragraph
+        │  ├─ Text "Backslash before new line"
+        │  ├─ LineBreak
+        │  └─ Text "is an explicit hard line break."
+        ├─ Paragraph
+        │  ├─ Text "Two spaces before new line"
+        │  ├─ LineBreak
+        │  └─ Text "is a hard line break."
+        ├─ Paragraph
+        │  └─ Text "Paragraph can’t end with hard line break.\"
+        ├─ Heading level: 1
+        │  └─ Text "Headings can’t end with hard line break.\"
+        ├─ CodeBlock language: none
+        │  Code blocks ignore\
+        │  hard line breaks.
+        └─ Paragraph
+           ├─ Text "A single space before new line"
+           ├─ SoftBreak
+           └─ Text "is a soft line break."
+        """#
+        XCTAssertEqual(document.debugDescription(), expectedDump)
+        let result = document.children.flatMap { compiler.visit($0) }
+        XCTAssertEqual(result.count, 6)
+        do {
+            guard case let .paragraph(paragraph) = result[0] as? RenderBlockContent else {
+                XCTFail("RenderCotent result is not the expected RenderBlockContent.paragraph(Paragraph)")
+                return
+            }
+            let text = RenderInlineContent.text("\n")
+            XCTAssertEqual(paragraph.inlineContent[1], text)
+        }
+        do {
+            guard case let .paragraph(paragraph) = result[1] as? RenderBlockContent else {
+                XCTFail("RenderCotent result is not the expected RenderBlockContent.paragraph(Paragraph)")
+                return
+            }
+            let text = RenderInlineContent.text("\n")
+            XCTAssertEqual(paragraph.inlineContent[1], text)
+        }
+    }
 }