https://github.com/divadretlaw/html2markdown
https://github.com/divadretlaw/html2markdown
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/divadretlaw/html2markdown
- Owner: divadretlaw
- License: mit
- Created: 2023-01-28T11:56:52.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-15T09:33:57.000Z (6 months ago)
- Last Synced: 2024-12-15T10:29:11.712Z (6 months ago)
- Language: Swift
- Size: 85.9 KB
- Stars: 2
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# HTML2Markdown
## What is this?
It's a Swift Package which attempts to convert HTML into Markdown.
## How do I use it?
```swift
let html = "This is a terrible idea.
"
I must be daft.do {
let dom = try HTMLParser().parse(html: html)
let markdown = dom.markdownFormatted(options: .unorderedListBullets)
print(markdown)
} catch {
// parsing error
}
```This generates the following markdown string:
```
This is a *terrible* idea.\nI must be daft.
```## What is supported?
* `` and `` for highlighting text
* ordered and unordered lists (`` and `
`)
* paragraphs (``) and line breaks (`
`)
* hyperlinks (``)All other HTML tags are removed.
> Note:
> `SwiftUI.Text` currently cannot render Markdown lists therefore use the `MarkdownGenerator.Options.unorderedListBullets` option to generate nicer-looking bullets: `•` instead of `*`.## License
See [LICENSE](LICSNE)