{"id":2016,"url":"https://github.com/macteo/Marklight","last_synced_at":"2025-08-02T05:33:28.567Z","repository":{"id":62447576,"uuid":"48754512","full_name":"macteo/Marklight","owner":"macteo","description":"Markdown syntax highlighter for iOS","archived":false,"fork":false,"pushed_at":"2018-11-13T14:04:36.000Z","size":811,"stargazers_count":683,"open_issues_count":13,"forks_count":43,"subscribers_count":15,"default_branch":"develop","last_synced_at":"2025-06-26T02:41:00.388Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/macteo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-29T15:45:03.000Z","updated_at":"2025-06-19T05:49:34.000Z","dependencies_parsed_at":"2022-11-01T23:17:47.359Z","dependency_job_id":null,"html_url":"https://github.com/macteo/Marklight","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/macteo/Marklight","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macteo%2FMarklight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macteo%2FMarklight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macteo%2FMarklight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macteo%2FMarklight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/macteo","download_url":"https://codeload.github.com/macteo/Marklight/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macteo%2FMarklight/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268339405,"owners_count":24234544,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-01-05T20:16:01.317Z","updated_at":"2025-08-02T05:33:27.662Z","avatar_url":"https://github.com/macteo.png","language":"Swift","readme":"# Marklight\n\nMarkdown syntax highlighter for iOS and macOS.\n\n[![License MIT](https://img.shields.io/cocoapods/l/Marklight.svg)](https://raw.githubusercontent.com/macteo/marklight/master/LICENSE) [![Version](https://img.shields.io/cocoapods/v/Marklight.svg)](https://cocoapods.org/?q=marklight) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![travis-ci](https://travis-ci.org/macteo/Marklight.svg?branch=master)](https://travis-ci.org/macteo/Marklight)\n[![codecov.io](https://codecov.io/github/macteo/Marklight/coverage.svg?branch=feature/swift4)](https://codecov.io/github/macteo/Marklight?branch=master)\n![Swift 4.1](https://img.shields.io/badge/language-Swift%204.1-EB7943.svg) ![iOS 8+](https://img.shields.io/badge/iOS-8+-EB7943.svg)\n\n## Description\n\nMarklight is a drop in component to easily add realtime Markdown syntax highlight on any user editable text view in iOS and macOS applications.\nMarklight doesn't include HTML generation from Markdown, but you can use one of the many other components available like [Markingbird](https://github.com/kristopherjohnson/Markingbird).\n\nRegular expressions are taken from [Markingbird](https://github.com/kristopherjohnson/Markingbird), a Markdown parser and html generator.\n\n![Marklight Gif](https://raw.githubusercontent.com/macteo/Marklight/master/Assets/marklight.gif)![Screenshot 0](https://raw.githubusercontent.com/macteo/Marklight/master/Assets/screenshot-0.png)\n\n## Features\n\n- [x] Applicable to any `UITextView`.\n- [x] `NSTextStorage` subclass ready to use.\n- [x] Struct optimized for performances.\n- [x] Swift 4.1 compatible.\n- [x] Dynamic text style supported.\n- [x] Choose markdown syntax color.\n- [x] Choose font and color for code blocks.\n- [x] Choose font and color for quotes.\n- [x] Choose dynamic type font text style.\n- [x] Quote indentation.\n- [x] Documented.\n- [x] macOS compatibility.\n- [ ] Parsing tests.\n- [ ] Performance tests.\n\n## Requirements\n\n- iOS 8.0+\n- Xcode 9.3+\n- macOS 10.11+\n\n## Installation\n\n### CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\n\u003e CocoaPods 1.0.0+ is required to build Marklight.\n\nTo integrate Marklight into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '8.0'\nuse_frameworks!\n\npod 'Marklight'\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install [Carthage](https://github.com/Carthage/Carthage) with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate Marklight into your Xcode project using [Carthage](https://github.com/Carthage/Carthage), specify it in your `Cartfile`:\n\n```ogdl\ngithub \"macteo/Marklight\"\n```\n\nRun `carthage update --platform iOS` to build the framework and drag the built `Marklight.framework` into your Xcode project.\n\n### Manually\n\nAdd the *Marklight* Xcode project to your own. Then add the `Marklight` framework as desired to the embedded binaries of your app's target.\n\n## Usage\n\nIn this repository you can find a sample project with few lines of code in the `ViewController` class for a jumpstart.\n\n*Sample code is written in Swift but Objective-C should be supported too, if you find an incompatibility please open an issue.*\n\n### Integration\n\nThe easiest way to crete a user editable `UITextView` with markdown syntax highlight is to use the provided `MarklightTextStorage` class as `NSTextStorage` and add the `UITextView`'s `textLayout` to the `MarklightTextStorage` text storage.\n\nImport *Marklight* modules into your Swift class\n\n```swift\nimport Marklight\n```\n\nor if you are writing in Objective-C\n\n```objc\n#import \u003cMarklight/Marklight-Swift.h\u003e\n```\n\n\u003e Keep in mind the you have to let the project generate the Bridging Header otherwise the integration may fail.\n\nIn your `UIViewController` subclass keep a strong instance of the this `MarklightTextStorage` class.\n\n```swift\nlet textStorage = MarklightTextStorage()\n```\n\nCustomize the appearance as desired:\n\n* Dynamic text style.\n* Markdown syntax color.\n* Code's font and color.\n* Quotes' font and color.\n\nAs per Apple's documentation it should be enough to assign the `UITextView`'s `NSLayoutManager` to the `NSTextStorage` subclass, in our case `MarklightTextStorage`.\n\n```swift\n textStorage.addLayoutManager(textView.layoutManager)\n```\nHowever I'm experiencing some crashes if I want to preload some text instead of letting the user start from scratch with a new text. A workaround is proposed below.\n\nFor simplicity we assume you have a `String` to be highlighted inside an editable `UITextView` loaded from a storyboard.\n\n```swift\nlet string = \"# My awesome markdown string\"\n```\n\nConvert `string` to an `NSAttributedString`\n\n```swift\nlet attributedString = NSAttributedString(string: string)\n```\n\nSet the loaded string to the `UITextView`\n\n```swift\ntextView.attributedText = attributedString\n```\n\nAppend the loaded string to the `NSTextStorage`\n\n```swift\ntextStorage.appendAttributedString(attributedString)\n```\n\nEnjoy.\n\n## Acknowledgements\n\n* Matteo Gavagnin – [@macteo](https://twitter.com/macteo)\n* Christian Tietze (macOS Port) - [@ctietze](https://twitter.com/ctietze), [GitHub](http://github.com/DivineDominion)\n\n---\n\nMarklight is heavily based on [Markingbird](https://github.com/kristopherjohnson/Markingbird), so many thanks to [Kristopher Johnson](http://undefinedvalue.com) and every previous contribution on which [Markingbird](https://github.com/kristopherjohnson/Markingbird) is based upon.\n\n## License\n\nMarklight is released under the MIT license. See [LICENSE](https://raw.githubusercontent.com/macteo/Marklight/master/LICENSE) for details.\n","funding_links":[],"categories":["UI","Text","Swift"],"sub_categories":["Layout","Other free courses","Other Testing","Keychain"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacteo%2FMarklight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmacteo%2FMarklight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacteo%2FMarklight/lists"}