/Highlighter

✒️ iOS & macOS Syntax Highlighter.

Primary LanguageSwiftMIT LicenseMIT

Highlighter

highlight.js version Supported platforms

Highlighter is an iOS & macOS syntax highlighter built with Swift. This library is forked of original Highlightr and combined with Code Editor. Also it uses highlight.js as it core, supports 185 languages and comes with 89 styles.

The real reason behind this fork is to use latest version of highlight.js and it's newer themes. You can show your highlighted string with CodeEditor or return it as a NSAttributtedString with proper syntax highlighting with the massive help of Highlightr.

Preview

Installation

Swift Package Manager

The Swift package URL is: https://github.com/Rminsh/Highlighter.git

Usage

See Code Editor and Highlightr.

JavaScript?

Yes, Highlightr relies on iOS & macOS JavaScriptCore to parse the code using highlight.js. This is actually quite fast!

Performance

It will never be as fast as a native solution, but it's fast enough to be used on a real time editor.

It 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.

License

This library is available under the MIT license. See the LICENSE file for more info.

Highlight.js is available under the BSD license. Highlightr (iOS & macOS library) is available under the MIT license. CodeEditor is available under the MIT license.