File tree Expand file tree Collapse file tree
Sources/SwiftHTMLtoMarkdown
Tests/SwiftHTMLtoMarkdownTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public class MastodonHTML: HTML {
4949 markdown += " ( \( href) ) "
5050 return
5151 } else if node. nodeName ( ) == " #text " {
52- markdown += node. description
52+ markdown += node. description. trimmingCharacters ( in : . newlines )
5353 }
5454
5555 for node in node. getChildNodes ( ) {
Original file line number Diff line number Diff line change @@ -24,6 +24,16 @@ final class SwiftHTMLtoMarkdownTests: XCTestCase {
2424 XCTAssertTrue ( markdown == correctOutput)
2525 }
2626
27+ func testMastodonHTMLSingleLine( ) throws {
28+ let raw = " This is a test "
29+ let correctOutput = " This is a test "
30+ var document = MastodonHTML ( rawHTML: raw)
31+ try document. parse ( )
32+
33+ let markdown = try document. asMarkdown ( )
34+ print ( markdown)
35+ XCTAssertTrue ( markdown == correctOutput)
36+ }
2737 func testBasicHTML( ) throws {
2838 let raw = """
2939 <h1>Heading level 1</h1><h2>Heading level 2</h2>
You can’t perform that action at this time.
0 commit comments