{"id":15029209,"url":"https://github.com/raspu/highlightr","last_synced_at":"2025-05-14T22:09:45.700Z","repository":{"id":40284529,"uuid":"57836866","full_name":"raspu/Highlightr","owner":"raspu","description":"iOS \u0026 OSX Syntax Highlighter. ","archived":false,"fork":false,"pushed_at":"2024-07-29T14:22:51.000Z","size":2967,"stargazers_count":1755,"open_issues_count":28,"forks_count":276,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-05-12T05:35:51.227Z","etag":null,"topics":["highlight","ios","ios-lib","macos","sample-gif","swift-library","syntax-highlighting"],"latest_commit_sha":null,"homepage":null,"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/raspu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-05-01T21:19:49.000Z","updated_at":"2025-05-12T02:51:17.000Z","dependencies_parsed_at":"2024-06-18T12:34:41.453Z","dependency_job_id":"ca926589-bc85-48cf-8a56-bbf78119d92c","html_url":"https://github.com/raspu/Highlightr","commit_stats":{"total_commits":139,"total_committers":20,"mean_commits":6.95,"dds":0.5035971223021583,"last_synced_commit":"628094ff81cdebf31da6bf31be4b4ac758c127a4"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspu%2FHighlightr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspu%2FHighlightr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspu%2FHighlightr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raspu%2FHighlightr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raspu","download_url":"https://codeload.github.com/raspu/Highlightr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235701,"owners_count":22036964,"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":["highlight","ios","ios-lib","macos","sample-gif","swift-library","syntax-highlighting"],"created_at":"2024-09-24T20:09:57.945Z","updated_at":"2025-05-14T22:09:40.685Z","avatar_url":"https://github.com/raspu.png","language":"Swift","readme":"# Highlightr\n\n\n[![Version](https://img.shields.io/cocoapods/v/Highlightr.svg?style=flat)](http://cocoapods.org/pods/Highlightr)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![CocoaPods](https://img.shields.io/cocoapods/metrics/doc-percent/Highlightr.svg)](http://cocoadocs.org/docsets/Highlightr/1.1.0/)\n[![License](https://img.shields.io/cocoapods/l/Highlightr.svg?style=flat)](http://cocoapods.org/pods/Highlightr)\n[![Platform](https://img.shields.io/cocoapods/p/Highlightr.svg?style=flat)](http://cocoapods.org/pods/Highlightr)\n\nHighlightr is an iOS \u0026 macOS syntax highlighter built with Swift. It uses [highlight.js](https://highlightjs.org/) as it core, supports [185 languages and comes with 89 styles](https://highlightjs.org/static/demo/).\n\nTakes your lame string with code and returns a NSAttributtedString with proper syntax highlighting.\n\n![Sample Gif A](https://raw.githubusercontent.com/raspu/Highlightr/master/mix2.gif)\n![Sample Gif B](https://raw.githubusercontent.com/raspu/Highlightr/master/coding.gif)\n\n## Installation\n### Requirements\n- iOS 8.0+\n- macOS 10.10+\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\nTo integrate Highlightr into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'Highlightr'\nend\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 with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate Highlightr into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"raspu/Highlightr\"\n```\n\nRun `carthage update` to build the framework and drag the built `Highlightr.framework` into your Xcode project.Highlightr\n\n## Usage\nHighlightr provides two main classes:\n\n### Highlightr\nThis is the main endpoint, you can use it to convert code strings into NSAttributed strings.\n```Swift\n\tlet highlightr = Highlightr()\n\thighlightr.setTheme(to: \"paraiso-dark\")\n\tlet code = \"let a = 1\"\n\t// You can omit the second parameter to use automatic language detection.\n\tlet highlightedCode = highlightr.highlight(code, as: \"swift\") \n\t\n```\n### CodeAttributedString\nA subclass of NSTextStorage, you can use it to highlight text on real time.\n```Swift\n\tlet textStorage = CodeAttributedString()\n\ttextStorage.language = \"Swift\"\n\tlet layoutManager = NSLayoutManager()\n\ttextStorage.addLayoutManager(layoutManager)\n\n\tlet textContainer = NSTextContainer(size: view.bounds.size)\n\tlayoutManager.addTextContainer(textContainer)\n\n\tlet textView = UITextView(frame: yourFrame, textContainer: textContainer)\n```\n\n## JavaScript?\n\nYes, Highlightr relies on iOS \u0026 macOS [JavaScriptCore](https://developer.apple.com/library/ios/documentation/Carbon/Reference/WebKit_JavaScriptCore_Ref/index.html#//apple_ref/doc/uid/TP40004754) to parse the code using highlight.js. This is actually quite fast!\n\n## Performance\n\nIt will never be as fast as a native solution, but it's fast enough to be used on a real time editor.\n\nIt comes with a custom made HTML parser for creating NSAttributtedStrings, is pre-processing the themes and is preloading the JS libraries. As result it's taking around of 50 ms on my iPhone 6s for processing 500 lines of code.\n\n## Documentation\n\nYou can find the documentation for the latest release on [cocoadocs](http://cocoadocs.org/docsets/Highlightr/).\n\n## License\n\nHighlightr is available under the MIT license. See the LICENSE file for more info.\n\nHighlight.js is available under the BSD license. You can find the [license file here](https://github.com/isagalaev/highlight.js/blob/master/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraspu%2Fhighlightr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraspu%2Fhighlightr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraspu%2Fhighlightr/lists"}