{"id":28766747,"url":"https://github.com/weihas/wkmarkdownview","last_synced_at":"2026-05-09T06:35:47.812Z","repository":{"id":299429782,"uuid":"1001297997","full_name":"weihas/WKMarkdownView","owner":"weihas","description":"A local Markdown webview renderer for iOS with optional LaTeX support. Fully self-contained, no network required.","archived":false,"fork":false,"pushed_at":"2025-06-16T13:52:28.000Z","size":1183,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-16T14:53:22.023Z","etag":null,"topics":["concurrency","ios","katex","latex","local","markdown","marked","spm","swift","webview"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weihas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-13T06:34:47.000Z","updated_at":"2025-06-16T13:52:32.000Z","dependencies_parsed_at":"2025-06-16T14:53:25.202Z","dependency_job_id":"0a8d053f-1b54-4c72-98b8-23612743c3a7","html_url":"https://github.com/weihas/WKMarkdownView","commit_stats":null,"previous_names":["weihas/wkmarkdownview"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/weihas/WKMarkdownView","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weihas%2FWKMarkdownView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weihas%2FWKMarkdownView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weihas%2FWKMarkdownView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weihas%2FWKMarkdownView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weihas","download_url":"https://codeload.github.com/weihas/WKMarkdownView/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weihas%2FWKMarkdownView/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260355370,"owners_count":22996465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","ios","katex","latex","local","markdown","marked","spm","swift","webview"],"created_at":"2025-06-17T12:04:10.377Z","updated_at":"2026-05-09T06:35:47.788Z","avatar_url":"https://github.com/weihas.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WKMarkdownView\n\n[![Swift Version](https://img.shields.io/badge/Swift-5.5%2B-orange)](https://swift.org) [![Platforms](https://img.shields.io/badge/platform-iOS%2013%2B-blue)](https://www.apple.com/ios/) [![Swift Package Manager](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://swift.org/package-manager/) [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\nA lightweight Swift component for rendering **Markdown** and **KaTeX math** inside a `WKWebView`, all using **local resources**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./images/demo.png\" width=\"300\"\u003e\n\u003c/p\u003e\n\n---\n\n## Features\n\n- ✅ Render Markdown via [marked.js](https://github.com/markedjs/marked)\n- ✅ Support for inline and block LaTeX using [KaTeX](https://katex.org/)\n- ✅ Light/Dark mode via `prefers-color-scheme`\n- ✅ Modern async Swift API using `async/await`\n- ✅ Dynamically get content height for flexible layouts\n- ✅ Fully offline: all resources are bundled locally\n- ✅ **SwiftUI support** with automatic height adjustment\n\n---\n\n## Requirements\n\n- iOS 13.0+\n- Swift 5.5+\n- Xcode 13.0+\n\n---\n\n## Installation\n\n### Swift Package Manager\n\nTo install `WKMarkdownView` using the [Swift Package Manager](https://swift.org/package-manager/), add it to the `dependencies` in your `Package.swift` file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/weihas/WKMarkdownView.git\", from: \"1.0.0\")\n]\n```\n\n---\n\n## Quick Start\n\n`WKMarkdownView` offers a native SwiftUI view that automatically handles rendering and resizing. This is the easiest way to get started.\n\n```swift\nimport WKMarkdownView\nimport SwiftUI\n\nstruct ContentView: View {\n    let markdown = \"\"\"\n    # Welcome to SwiftUI\n\n    This is **Markdown** rendered in SwiftUI.\n\n    You can also write math: $E = mc^2$.\n\n    $$\n    \\\\int_a^b f(x) \\\\, dx\n    $$\n    \"\"\"\n\n    var body: some View {\n        ScrollView {\n            MarkdownView(markdown)\n                .padding()\n        }\n    }\n}\n```\n\n## Advanced Usage\n\n### UIKit Integration\n\nYou can also use `WKMarkdownView` directly in a UIKit project.\n\n```swift\nimport UIKit\nimport WKMarkdownView\nimport WebKit\n\nclass ViewController: UIViewController {\n    \n    override func viewDidLoad() {\n        super.viewDidLoad()\n        // Do any additional setup after loading the view.\n        // 1. Create a markdown view instance\n        // LaTeX support is enabled by default\n        let markdownView = WKMarkdownView()\n        view.addSubview(markdownView)\n        \n        // 2. Set its frame\n        markdownView.frame = view.bounds\n        markdownView.autoresizingMask = [.flexibleWidth, .flexibleHeight]\n        \n        // 3. Load the markdown content\n        \n        let markdown = \"\"\"\n        # Hello from UIKit\n        \n        This is **Markdown** with math support:\n        \n        Inline math: $E = mc^2$\n        \n        Block math:\n        $$\n        \\\\frac{a}{b} = c\n        $$\n        \"\"\"\n        \n        Task {\n            try? await markdownView.updateMarkdown(markdown)\n        }\n    }\n}\n```\n\n### Getting Content Height\n\nFor manual layout calculations, you can asynchronously retrieve the rendered content's height.\n\n```swift\nTask {\n    if let height = try? await markdownView.contentHeight() {\n        // Use the height for your layout...\n        print(\"Content height: \\\\(height)\")\n    }\n}\n```\n\n### Disabling LaTeX Support\n\nIf you don't need math rendering, you can disable it during initialization to save resources.\n\n```swift\n// Create a markdown view without LaTeX/math support\nlet markdownView = WKMarkdownView(enableLatex: false)\n```\n\n---\n\n## Contributing\n\nContributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/weihas/WKMarkdownView/issues).\n\n---\n\n## License\n\n`WKMarkdownView` is available under the MIT license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweihas%2Fwkmarkdownview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweihas%2Fwkmarkdownview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweihas%2Fwkmarkdownview/lists"}