Skip to content

Commit

Permalink
Fixed leading whitespace in #text
Browse files Browse the repository at this point in the history
  • Loading branch information
ActuallyTaylor committed Jun 24, 2023
1 parent 36075cc commit 77b47ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/SwiftHTMLtoMarkdown/MastodonHTML.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class MastodonHTML: HTML {
markdown += "(\(href))"
return
} else if node.nodeName() == "#text" {
markdown += node.description
markdown += node.description.trimmingCharacters(in: .newlines)
}

for node in node.getChildNodes() {
Expand Down
10 changes: 10 additions & 0 deletions Tests/SwiftHTMLtoMarkdownTests/SwiftHTMLtoMarkdownTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ final class SwiftHTMLtoMarkdownTests: XCTestCase {
XCTAssertTrue(markdown == correctOutput)
}

func testMastodonHTMLSingleLine() throws {
let raw = "This is a test"
let correctOutput = "This is a test"
var document = MastodonHTML(rawHTML: raw)
try document.parse()

let markdown = try document.asMarkdown()
print(markdown)
XCTAssertTrue(markdown == correctOutput)
}
func testBasicHTML() throws {
let raw = """
<h1>Heading level 1</h1><h2>Heading level 2</h2>
Expand Down

0 comments on commit 77b47ba

Please sign in to comment.