Welcome to the documentation of Highlightr, a powerful code syntax highlighter for iOS.

Table of Contents


Highlightr can be installed using CocoaPods or manually.

Using CocoaPods

To install Highlightr via CocoaPods, add the following line to your Podfile:

pod 'Highlightr'

Then run the following command:

pod install

Manual Installation

To manually install Highlightr, simply download the source code from the GitHub repository and add the Highlightr folder to your Xcode project.

Basic Usage

To use Highlightr in your project, follow these steps:

  1. Create an instance of `Highlightr`:
  2. let highlightr = Highlightr()
  3. Load the desired syntax theme:
  4. highlightr.setTheme(to: "xcode")
  5. Highlight the code:
  6. let highlightedCode = highlightr.highlight(code, as: language)
  7. Render the highlighted code:
  8. textView.attributedText = highlightedCode

Advanced Usage

Highlightr provides several advanced features to enhance your code syntax highlighting:

  • Line Numbers: You can enable line numbers in the highlighted code.
  • Line Highlighting: You can highlight specific lines in the code.
  • Theme Customization: You can customize the theme colors to match your app’s design.
  • Supported Languages: Highlightr supports a wide range of programming languages.


You can customize the appearance of highlighted code by changing the theme or modifying individual theme colors.

Changing the Theme

To change the theme, simply use the `setTheme(to:)` method:

highlightr.setTheme(to: "monokai-sublime")

Modifying Theme Colors

You can modify individual theme colors using the `setThemeColor(_:to:)` method:

highlightr.setThemeColor(.background, to: UIColor.black)


If you encounter any issues while using Highlightr, please refer to the following:

  • Issue #1: The code is not highlighted correctly.
  • Solution: Ensure that you have set the correct language and theme for the code you want to highlight.

  • Issue #2: The line numbers are not displayed.
  • Solution: Enable line numbers using the appropriate method provided by Highlightr.


If you would like to contribute to the development of Highlightr, please follow the guidelines outlined in the CONTRIBUTING.md file in the GitHub repository.


Highlightr is released under the MIT License. See the LICENSE file for more details.