ActuallyTaylor/SwiftHTMLToMarkdown
A simple Swift package that converts HTML into Markdown
Supported Flavors of HTML
| Flavor | Support | | -------------------- | --------------------------------------------------- | | Mastodon Status HTML (MastodonHTML) | ✅ | | Basic HTML (BasicHTML) | ⚠️ (Almost fully supported, tables are not) |
How to use
Using the library is pretty simple. The first step is to pick which HTML flavor you are going to be converting. If you are converting a Basic HTML document you can use the BasicHTML class. For Mastodon statuses you can use the MastodonHTML class.
Once you have picked out the class you will be using, the following code is all you need!
var document = BasicHTML(rawHTML: raw)
try document.parse()
let markdown = try document.asMarkdown()
print(markdown)Package Metadata
Repository: ActuallyTaylor/SwiftHTMLToMarkdown
Stars: 54
Forks: 25
Open issues: 2
Default branch: main
Primary language: swift
License: MIT
Topics: html, html-to-markdown, html-to-markdown-converter, htmltomarkdown, markdown, swift
README: README.md