Skip to content

iHTCboy/MarkdownView

 
 

Repository files navigation

MarkdownView

CI Status Swift 5.0 Carthage compatible Version License

MarkdownView is a WKWebView based UI element, and internally use bootstrap, highlight.js, markdown-it.

GIF

How to use

import MarkdownView

let md = MarkdownView()
md.load(markdown: "# Hello World!")

Options

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
  }
}

Requirements

Target Version
iOS => 10.0
Swift => 5.0

Installation

MarkdownView is available through CocoaPods or Carthage.

CocoaPods

pod "MarkdownView"

Carthage

github "keitaoouchi/MarkdownView"

for detail, please follow the Carthage Instruction

Author

keita.oouchi, keita.oouchi@gmail.com

License

bootstrap is licensed under MIT license.
highlight.js is licensed under BSD-3-Clause license.
markdown-it is licensed under MIT license.

MarkdownView is available under the MIT license. See the LICENSE file for more info.

About

Markdown View for iOS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 55.6%
  • CSS 23.6%
  • Ruby 10.9%
  • JavaScript 8.8%
  • Objective-C 1.1%