{"id":15527095,"url":"https://github.com/liyanan2004/markdownview","last_synced_at":"2025-12-30T11:13:12.375Z","repository":{"id":56755447,"uuid":"523296057","full_name":"LiYanan2004/MarkdownView","owner":"LiYanan2004","description":"Rendering Markdown text natively in SwiftUI.","archived":false,"fork":false,"pushed_at":"2024-10-24T15:47:06.000Z","size":7027,"stargazers_count":186,"open_issues_count":2,"forks_count":18,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-30T06:58:14.735Z","etag":null,"topics":["cmark","commonmark","markdown","swift","swiftui"],"latest_commit_sha":null,"homepage":"https://liyanan2004.github.io/MarkdownView/documentation/markdownview/","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/LiYanan2004.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"custom":["https://www.buymeacoffee.com/liyanan04"]}},"created_at":"2022-08-10T10:18:44.000Z","updated_at":"2024-10-29T19:24:49.000Z","dependencies_parsed_at":"2024-11-13T02:13:27.132Z","dependency_job_id":null,"html_url":"https://github.com/LiYanan2004/MarkdownView","commit_stats":{"total_commits":121,"total_committers":6,"mean_commits":"20.166666666666668","dds":0.4132231404958677,"last_synced_commit":"22fac8da3c18319118b6bede2b4edbbb4c6f1723"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiYanan2004%2FMarkdownView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiYanan2004%2FMarkdownView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiYanan2004%2FMarkdownView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiYanan2004%2FMarkdownView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiYanan2004","download_url":"https://codeload.github.com/LiYanan2004/MarkdownView/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174423,"owners_count":20896078,"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":["cmark","commonmark","markdown","swift","swiftui"],"created_at":"2024-10-02T11:04:25.509Z","updated_at":"2025-12-30T11:13:12.370Z","avatar_url":"https://github.com/LiYanan2004.png","language":"Swift","funding_links":["https://www.buymeacoffee.com/liyanan04"],"categories":[],"sub_categories":[],"readme":"# MarkdownView\n\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FLiYanan2004%2FMarkdownView%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/LiYanan2004/MarkdownView)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FLiYanan2004%2FMarkdownView%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/LiYanan2004/MarkdownView)\n\nDisplay markdown content with SwiftUI.\n\n## Overview\n\nMarkdownView offers a super easy and highly customizable way to display markdown content in your app. \n\nIt leverages [swift-markdown](https://github.com/swiftlang/swift-markdown) to parse markdown content, fully compliant with the [CommonMark Spec](https://spec.commonmark.org/current/).\n\n## Supported Platforms\n\nYou can use MarkdownView in the following platforms:\n\n* macOS 12.0+\n* iOS 15.0+\n* watchOS 8.0+\n* tvOS 15.0+\n* visionOS 1.0+\n\n## Highlighted Features\n\n- Fully compliant with CommonMark\n- Support SVG rendering\n- Support LaTeX math rendering\n- Highly Customizable and Extensible\n    - Fonts\n    - Code Highlighter Themes\n    - Tint Colors\n    - Block Directives\n    - Custom Images\n- Fully native SwiftUI implementations\n\n## Getting started\n\n### Displaying Contents\n\nYou can create a `Markdown` view by providing a markdown text.\n\n```swift\nlet markdownText = \"\"\"\n# MarkdownView\n\nThis is [MarkdownView](https://github.com/liyanan2004/MarkdownView).\n\nMarkdownView offers a super easy and highly customizable way to display markdown content in your app. It leverages swift-markdown to parse markdown content, fully compliant with the CommonMark Spec.\n\nMarkdownView supports adavanced rendering features like SVG, Inline Math, as well as code highlighting.\n\"\"\"\n\nMarkdownView(markdownText)\n```\n\n![](/Images/simple-rendering.png)\n\n### Customizing Appearance\n\nYou can set custom font group or change font for a specific kind of markdown markup.\n\n```swift\nMarkdownView(\"# H1 title\")\n    .font(.largeTitle.weight(.black), for: .h1)\n```\n\n![](/Images/font.jpeg)\n\nAdding tint color for code blocks and quote blocks. Default is the accent color.\n\nYou can customize them explicitly.\n\n```swift\nMarkdownView(\"\u003e Quote and `inline code`\")\n    .tint(.pink, for: .inlineCodeBlock)\n```\n\n![](/Images/tint.jpeg)\n\n### Extend Rendering\n\nYou can add your custom image renderers and block directive renderers to display your content.\n\nTo do that, first create your renderer.\n\n```swift\nstruct CustomImageRenderer: MarkdownImageRenderer {\n    func makeBody(configuration: Configutation) -\u003e some View {\n        AsyncImage(url: configuration.url) {\n            switch $0 {\n            case .empty: ProgressView()\n            case .success(let image): image.resizable()\n            case .failure(let error): Text(error.localizedDescription)\n            @unknown default: Text(\"Unknown situation\")\n            }\n        }\n    }\n}\n```\n\nThen apply your renderer to `MarkdownView`.\n\n```swift\nMarkdownView(markdownText)\n    .imageRenderer(CustomImageRenderer(), forURLScheme: \"my-image\")\n```\n\nThe implementation of the block directive is exactly the same way.\n\n## Documentation\n\nFor more detailed documentation, check out the [documentation](https://swiftpackageindex.com/LiYanan2004/MarkdownView/main/documentation/MarkdownView) page hosted on Swift Package Index.\n\n## Swift Package Manager\n\nIn your `Package.swift` Swift Package Manager manifest, add the following dependency to your `dependencies` argument:\n\n```swift\n.package(url: \"https://github.com/LiYanan2004/MarkdownView.git\", .branch(\"main\")),\n```\n\nAdd the dependency to any targets you've declared in your manifest:\n\n```swift\n.target(name: \"MyTarget\", dependencies: [\"MarkdownView\"]),\n```\n\n## Dependencies\n\n- [apple/swift-markdown](https://github.com/apple/swift-markdown): Parsing \u0026 Visiting documents.\n- [raspu/Highlightr](https://github.com/raspu/Highlightr.git): Code Highlighting.\n- [colinc86/LaTeXSwiftUI](https://github.com/colinc86/LaTeXSwiftUI.git): Math Rendering.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyanan2004%2Fmarkdownview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliyanan2004%2Fmarkdownview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyanan2004%2Fmarkdownview/lists"}