From a0a2ef020d1b03442c57abe8268227d95c224518 Mon Sep 17 00:00:00 2001 From: Ryan Booker <7423+ryanbooker@users.noreply.github.com> Date: Fri, 26 Apr 2024 20:58:15 +1000 Subject: [PATCH 1/2] Support b and i tags in Basic HTML --- Sources/SwiftHTMLtoMarkdown/BasicHTML.swift | 4 ++-- Tests/SwiftHTMLtoMarkdownTests/BasicHTMLTests.swift | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Sources/SwiftHTMLtoMarkdown/BasicHTML.swift b/Sources/SwiftHTMLtoMarkdown/BasicHTML.swift index fa97bd7..00ce01f 100644 --- a/Sources/SwiftHTMLtoMarkdown/BasicHTML.swift +++ b/Sources/SwiftHTMLtoMarkdown/BasicHTML.swift @@ -57,14 +57,14 @@ public class BasicHTML: HTML { let href = try node.attr("href") markdown += "(\(href))" return - } else if node.nodeName() == "strong" { + } else if node.nodeName() == "strong" || node.nodeName() == "b" { markdown += "**" for child in node.getChildNodes() { try convertNode(child) } markdown += "**" return - } else if node.nodeName() == "em" { + } else if node.nodeName() == "em" || node.nodeName() == "i" { markdown += "*" for child in node.getChildNodes() { try convertNode(child) diff --git a/Tests/SwiftHTMLtoMarkdownTests/BasicHTMLTests.swift b/Tests/SwiftHTMLtoMarkdownTests/BasicHTMLTests.swift index cfdfb3f..cf9a816 100644 --- a/Tests/SwiftHTMLtoMarkdownTests/BasicHTMLTests.swift +++ b/Tests/SwiftHTMLtoMarkdownTests/BasicHTMLTests.swift @@ -20,11 +20,12 @@ final class BasicHTMLTests: XCTestCase {
I just love bold text.
-Loveisbold
- +Loveisbold
+Italicized text is the cat's meow.
-Acatsmeow
- + +Acatsmeow
+This text is really important.
This is some code Hello World!