{"id":16848801,"url":"https://github.com/andyfinnell/nativemarkkit","last_synced_at":"2025-07-27T16:07:45.022Z","repository":{"id":37001683,"uuid":"273757826","full_name":"andyfinnell/NativeMarkKit","owner":"andyfinnell","description":"NativeMark is a flavor of Markdown designed to be rendered by native apps.","archived":false,"fork":false,"pushed_at":"2023-04-18T09:45:46.000Z","size":13915,"stargazers_count":51,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T08:48:54.475Z","etag":null,"topics":["appkit","commonmark","markdown","swift","swiftui","uikit"],"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/andyfinnell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2020-06-20T17:52:09.000Z","updated_at":"2025-01-25T02:03:01.000Z","dependencies_parsed_at":"2024-10-28T12:25:51.341Z","dependency_job_id":"2243176b-300f-48c4-b5c0-08306a6610be","html_url":"https://github.com/andyfinnell/NativeMarkKit","commit_stats":{"total_commits":156,"total_committers":2,"mean_commits":78.0,"dds":0.09615384615384615,"last_synced_commit":"c58eb73e18fe2311f4675ffa7d23555afa976017"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyfinnell%2FNativeMarkKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyfinnell%2FNativeMarkKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyfinnell%2FNativeMarkKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andyfinnell%2FNativeMarkKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andyfinnell","download_url":"https://codeload.github.com/andyfinnell/NativeMarkKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244912800,"owners_count":20530764,"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":["appkit","commonmark","markdown","swift","swiftui","uikit"],"created_at":"2024-10-13T13:12:40.300Z","updated_at":"2025-03-22T05:31:35.984Z","avatar_url":"https://github.com/andyfinnell.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NativeMarkKit\n![Tests](https://github.com/andyfinnell/NativeMarkKit/workflows/Tests/badge.svg) [![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)\n\nNativeMark is a flavor of Markdown designed to be rendered by native apps (i.e. it compiles down to native types, not HTML). Specifically, it implements the [CommonMark spec](https://spec.commonmark.org/0.29/) with the significant exception of raw HTML tags. NativeMark will treat raw HTML tags as plain text. It also supports some of Github Flavored Markdown's extensions, such as strikethrough.\n\nThe goal of NativeMark is to provide a simple, intuitive way to create styled text in native apps. NativeMarkKit is an implementation of NativeMark for macOS, iOS, and tvOS. NativeMarkKit supports dark mode, dynamic type, and SwiftUI where available.\n\n## Requirements\n\n- Swift 5.1 or greater\n- iOS/tvOS 9 or greater OR macOS 10.11 or greater\n\n## Installation\n\nCurrently, NativeMarkKit is only available as a Swift Package.\n\n### ...using a Package.swift file\n\nOpen the Package.swift file and edit it:\n\n1. Add NativeMarkKit repo to the `dependencies` array.\n1. Add NativeMarkKit as a dependency of the target that will use it\n\n```Swift\n// swift-tools-version:5.1\n\nimport PackageDescription\n\nlet package = Package(\n  // ...snip...\n  dependencies: [\n    .package(url: \"https://github.com/andyfinnell/NativeMarkKit.git\", from: \"2.0.0\")\n  ],\n  targets: [\n    .target(name: \"MyTarget\", dependencies: [\"NativeMarkKit\"])\n  ]\n)\n```\n\nThen build to pull down the dependencies:\n\n```Bash\n$ swift build\n```\n\n### ...using Xcode\n\nUse the Swift Packages tab on the project to add NativeMarkKit:\n\n1. Open the Xcode workspace or project that you want to add NativeMarkKit to\n1. In the file browser, select the project to show the list of projects/targets on the right\n1. In the list of projects/targets on the right, select the project\n1. Select the \"Swift Packages\" tab\n1. Click on the \"+\" button to add a package\n1. In the \"Choose Package Repository\" sheet, search for  \"https://github.com/andyfinnell/NativeMarkKit.git\"\n1. Click \"Next\"\n1. Choose the version rule you want\n1. Click \"Next\"\n1. Choose the target you want to add NativeMarkKit to\n1. Click \"Finish\"\n\n## Usage \n\n### ...with views\n\nThe easiest way to use NativeMarkKit is to use `NativeMarkLabel`:\n\n```Swift\nimport NativeMarkKit\n\nlet label = NativeMarkLabel(nativeMark: \"**Hello**, _world_!\")\n\n// Assuming myView is an NSView or UIView\nmyView.addSubview(label)\n```\n\n### ...with SwiftUI\n\nNativeMarkKit has a basic SwiftUI wrapper around `NativeMarkLabel` called `NativeMarkText`:\n\n```Swift\nimport SwiftUI\nimport NativeMarkKit\n\nstruct ContentView: View {\n    var body: some View {\n         NativeMarkText(\"**Hello**, _world_!\")\n    }\n}\n```\n\n### ...styling\n\nNativeMarkKit provides a style sheet data structure so NativeMark can be customized to match the styling of the app. By default, `NativeMarkLabel` and `NativeMarkText` use the `.default` `StyleSheet` to control how NativeMark is rendered. You can modify `.default` to create a global, default style sheet, or you can `.duplicate()` `.default` to create a one off style sheet for a specific use case.\n\nFor example, if you wanted links to use a brand color, you could mutate the `.default` `StyleSheet`:\n\n```Swift\nStyleSheet.default.mutate(inline: [\n    .link: [\n        .textColor(.purple)\n    ]\n])\n```\n\nThe above code would cause all NativeMark text using the `.default` style sheet to render links in purple.\n\nIf you only wanted to do this for a specific `NativeMarkLabel` (or `NativeMarkText`) you can `.duplicate()` `.default` and pass in the new style sheet to the labels that want it.\n\n```Swift\nlet purpleLinksStyleSheet = StyleSheet.default.duplicate().mutate(inline: [\n    .link: [\n        .textColor(.purple)\n    ]\n])\n```\n\nThen when the `NativeMarkLabel` is created:\n\n```Swift\nimport NativeMarkKit\n\nlet label = NativeMarkLabel(nativeMark: \"**Hello**, [Apple](https://www.apple.com)!\", styleSheet: purpleLinksStyleSheet)\n\n```\n\n### ...links\n\nBy default NativeMarkKit will open links in the default browser when they are clicked/tapped on. If you want to provide custom behavior instead, you can provide a closure to the `NativeMarkLabel`.\n\n```Swift\nimport NativeMarkKit\n\nlet label = NativeMarkLabel(nativeMark: \"**Hello**, [Apple](https://www.apple.com)!\")\nlabel.onOpenLink = { url in\n    // your custom code here\n    print(\"Opening \\(url)\")\n}\n```\n\n## Documentation\n\nMore [documentation](Documentation).\n\n## Acknowledgements\n\nThe NativeMarkKit project would like to acknowledge the work of the [CommonMark](https://commonmark.org/) project to document a standardized flavor of Markdown. NativeMarkKit's front end parsing is based on [CommonMark's parsing strategy](https://spec.commonmark.org/0.29/#appendix-a-parsing-strategy) and the reference implementation [CommonMark.js](https://github.com/commonmark/commonmark.js). Additionally, this project derives its suite of parsing tests from [CommonMark's specs](https://spec.commonmark.org/0.29/spec.json).\n\nFor Github Flavored Markdown extensions the [Github Flavored Markdown Spec](https://github.github.com/gfm/) was used.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyfinnell%2Fnativemarkkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandyfinnell%2Fnativemarkkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyfinnell%2Fnativemarkkit/lists"}