{"id":18657187,"url":"https://github.com/tomdai/markdown-webview","last_synced_at":"2025-04-11T18:31:25.989Z","repository":{"id":152850988,"uuid":"627305760","full_name":"tomdai/markdown-webview","owner":"tomdai","description":"A performant SwiftUI Markdown view.","archived":false,"fork":false,"pushed_at":"2024-04-13T05:08:46.000Z","size":138,"stargazers_count":41,"open_issues_count":1,"forks_count":14,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T16:55:31.562Z","etag":null,"topics":["ios","macos","markdown","markdown-it","markdown-viewer","swift","swiftui"],"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/tomdai.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}},"created_at":"2023-04-13T07:38:13.000Z","updated_at":"2025-03-18T03:47:04.000Z","dependencies_parsed_at":"2024-11-07T07:41:53.916Z","dependency_job_id":null,"html_url":"https://github.com/tomdai/markdown-webview","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomdai%2Fmarkdown-webview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomdai%2Fmarkdown-webview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomdai%2Fmarkdown-webview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomdai%2Fmarkdown-webview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomdai","download_url":"https://codeload.github.com/tomdai/markdown-webview/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248458468,"owners_count":21107084,"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":["ios","macos","markdown","markdown-it","markdown-viewer","swift","swiftui"],"created_at":"2024-11-07T07:27:00.640Z","updated_at":"2025-04-11T18:31:25.636Z","avatar_url":"https://github.com/tomdai.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# markdown-webview\n\n`MarkdownWebView` is a surprisingly performant SwiftUI view that renders Markdown content. \n\nI call it surprising because the underlying view is a `WKWebView`, yet a SwiftUI scroll view containing a bunch of `MarkdownWebView` still scrolls smoothly. A similar looking view built with native SwiftUI views doesn't have such performance (yet, hopefully).\n\nhttps://user-images.githubusercontent.com/5054148/231708816-6c992197-893d-4d94-ae7c-2c6ce8d8c427.mp4\n\n## Features\n\n\u003cdetails\u003e\n\u003csummary\u003eAuto-adjusting View Height\u003c/summary\u003e\n\nThe view's height is always the content's height.\n\n\u003cimg alt=\"Auto-adjusting View Height\" src=\"https://user-images.githubusercontent.com/5054148/231703096-42a34f79-ffda-49b6-b352-304baa98fe84.png\" width=\"1000\"\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eText Selection\u003c/summary\u003e\n\n\u003cimg alt=\"Text Selection\" src=\"https://user-images.githubusercontent.com/5054148/231701074-17333cc7-5774-46ed-800a-dd113ca8dd5d.png\" width=\"1000\"\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eDynamic Content\u003c/summary\u003e\n\nhttps://user-images.githubusercontent.com/5054148/231708816-6c992197-893d-4d94-ae7c-2c6ce8d8c427.mp4\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eSyntax Highlighting\u003c/summary\u003e\nCode syntax is automatically highlighted.\n\u003c/details\u003e\n\n## Supported Platforms\n\n- macOS 11 and later\n- iOS 14 and later\n\n## Installation\n\nAdd this package as a dependency. \n\nSee the article [“Adding package dependencies to your app”](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app) to learn more.\n\n## Usage\n\n### Display Markdown Content\n\n```swift\nimport SwiftUI\nimport MarkdownWebView\n\nstruct ContentView: View {\n    @State private var markdownContent = \"# Hello World\"\n\n    var body: some View {\n        NavigationStack {\n            MarkdownWebView(markdownContent)\n        }\n    }\n}\n```\n\n### Customize Style\n\nThe view comes with a default style ([CSS files](https://github.com/tomdai/markdown-webview/tree/main/Sources/MarkdownWebView/Resources/stylesheets)) that suits many use cases.\n\nYou can also supply your own stylesheet by setting the `customStylesheet` parameter in the initializer.\n\n```swift\nimport SwiftUI\nimport MarkdownWebView\n\nstruct ContentView: View {\n    @State private var markdownContent = \"# Hello World\"\n    private let stylesheet: String? = try? .init(contentsOf: Bundle.main.url(forResource: \"markdown\", withExtension: \"css\")!)\n    \n    var body: some View {\n        NavigationStack {\n            MarkdownWebView(markdownContent, customStylesheet: stylesheet)\n        }\n    }\n}\n```\n\n\n### Handle Links\n\nThe view opens links with the default browser by default.\n\nYou can handle link activations yourself by setting the `onLinkActivation` parameter in the initializer.\n\n```swift\nimport SwiftUI\nimport MarkdownWebView\n\nstruct ContentView: View {\n    @State private var markdownContent = \"# Hello apple.com\"\n    \n    var body: some View {\n        NavigationStack {\n            MarkdownWebView(markdownContent)\n                .onLinkActivation { url in\n                    print(url)        \n                }\n        }\n    }\n}\n```\n\n## Requirement for macOS Apps\n\nThe underlying web view loads an HTML string. For the package to work in a macOS app, enable the “Outgoing Connections (Client)” capability.\n\n\u003cdetails\u003e\n\u003csummary\u003eWhat it looks like in Xcode\u003c/summary\u003e\n\n![Outgoing Connections (Client)](https://user-images.githubusercontent.com/5054148/231693500-093f4185-658b-4fa2-a182-fb40f50147b7.png)\n\u003c/details\u003e\n\n## Acknowledgements\nPortions of this package may utilize the following copyrighted material, the use of which is hereby acknowledged.\n\n- [markdown-it](https://github.com/markdown-it/markdown-it)\\\n    © 2014 Vitaly Puzrin, Alex Kocharin\n- [Punycode.js](https://github.com/mathiasbynens/punycode.js)\\\n    © Mathias Bynens\n- [highlight.js](https://github.com/highlightjs/highlight.js)\\\n    © 2006 Ivan Sagalaev\n- [markdown-it-mark](https://github.com/markdown-it/markdown-it-mark)\\\n    © 2014-2015 Vitaly Puzrin, Alex Kocharin\n- [markdown-it-task-lists](https://github.com/revin/markdown-it-task-lists)\\\n    © 2016, Revin Guillen\n- [github-markdown-css](https://github.com/sindresorhus/github-markdown-css)\\\n    © Sindre Sorhus\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomdai%2Fmarkdown-webview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomdai%2Fmarkdown-webview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomdai%2Fmarkdown-webview/lists"}