MarkdownView is a WKWebView based UI element, and internally use bootstrap and markdown-it.
This is a fork of the original library from keitaoouchi with these changes:
- It doesn't include highlight.js and therefore doesn't have syntax highlighting.
- Rationale: The size of the framework is reduced significantly.
- Javascript size goes doen from 902KB to 130KB
- Use may use it with Carthage: Add this line to your Cartfile:
github "michaelpeternell/MarkdownView" ~> 1.7
- Maybe you can somehow make this fork work with Cocoapods too, but I haven't tried.
import MarkdownView
let md = MarkdownView()
md.load(markdown: "# Hello World!")
md.isScrollEnabled = false
// called when rendering finished
md.onRendered = { [weak self] height in
self?.mdViewHeight.constant = height
self?.view.setNeedsLayout()
}
// called when user touch link
md.onTouchLink = { [weak self] request in
guard let url = request.url else { return false }
if url.scheme == "file" {
return false
} else if url.scheme == "https" {
let safari = SFSafariViewController(url: url)
self?.navigationController?.pushViewController(safari, animated: true)
return false
} else {
return false
}
}
Target | Version |
---|---|
iOS | => 10.0 |
Swift | => 5.0 |
MarkdownView is available through CocoaPods or Carthage.
pod "MarkdownView"
github "keitaoouchi/MarkdownView"
for detail, please follow the Carthage Instruction
Original author: keita.oouchi, keita.oouchi@gmail.com
Changes by: Michael Peternell (removed highlight.js)
bootstrap is licensed under MIT license.
markdown-it is licensed under MIT license.
MarkdownView is available under the MIT license. See the LICENSE file for more info.