ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - keitaoouchi/MarkdownView: Markdown View for iOS.
Markdown View for iOS. Contribute to keitaoouchi/MarkdownView development by creating an account on GitHub.
Visit Site

GitHub - keitaoouchi/MarkdownView: Markdown View for iOS.

GitHub - keitaoouchi/MarkdownView: Markdown View for iOS.

MarkdownView

CI Status Swift 5.2 Carthage compatible Version License Swift Package Manager compatible

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

GIF

How to use

UIViewController

import MarkdownView

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

SwiftUI

import SwiftUI
import MarkdownView

struct SampleUI: View {
  var body: some View {
    ScrollView {        
      MarkdownUI(body: markdown)
        .onTouchLink { link in 
          print(link)
          return false
        }
        .onRendered { height in 
          print(height)
        }
    }
  }
  
  private var markdown: String {
    let path = Bundle.main.path(forResource: "sample", ofType: "md")!
    let url = URL(fileURLWithPath: path)
    return try! String(contentsOf: url, encoding: String.Encoding.utf8)
  }
}

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

Experimental Features

This is not stable :bow:

Custom CSS Styling

Please check Example/ViewController/CustomCss.swift.

Plugins

Please check Example/ViewController/Plugins.swift. Each plugin should be self-contained, with no external dependent plugins.

Here is a sample project that builds markdown-it-new-katex as a compatible library.

Requirements

Target Version
iOS => 13.0
Swift => 5.2

Installation

MarkdownView is available through Swift Package Manager or CocoaPods or Carthage.

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/keitaoouchi/MarkdownView.git", from: "1.7.1")
]

Alternatively, you can add the package directly via Xcode.

CocoaPods

pod "MarkdownView"

Carthage

github "keitaoouchi/MarkdownView"

for detail, please follow the Carthage Instruction

Author

keita.oouchi, [email protected]

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.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory