WWJavaScriptContext+Markdown

main

Use JavaScript to convert Markdown text.
William-Weng/WWJavaScriptContext_Markdown

WWJavaScriptContext+Markdown

Swift-5.6 iOS-14.0 Swift Package Manager-SUCCESS LICENSE

dependencies: [
    .package(url: "https://github.com/William-Weng/WWJavaScriptContext_Markdown.git", .upToNextMajor(from: "1.0.0"))
]

Function - 可用函式

函式 功能
convertHTML(source:) 轉換Markdown => HTML

Example

import UIKit
import WebKit
import WWPrint
import WWJavaScriptContext
import WWJavaScriptContext_Markdown

final class ViewController: UIViewController {
    
    @IBOutlet weak var myTextView: UITextView!
    @IBOutlet weak var myWebView: WKWebView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    @IBAction func convertHTML(_ sender: UIButton) {
        
        guard let text = myTextView.text,
              let htmlString = WWJavaScriptContext.Markdown.shared.convertHTML(source: text)
        else {
            return
        }
        
        wwPrint(htmlString)
        myWebView.loadHTMLString("\(htmlString)", baseURL: nil)
    }
}

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

Last updated: Tue Nov 19 2024 21:37:06 GMT-1000 (Hawaii-Aleutian Standard Time)