Welcome to the documentation of Highlightr, a powerful code syntax highlighter for iOS.
Table of Contents
Highlightr can be installed using CocoaPods or manually.
To install Highlightr via CocoaPods, add the following line to your Podfile:
Then run the following command:
To manually install Highlightr, simply download the source code from the GitHub repository and add the Highlightr folder to your Xcode project.
To use Highlightr in your project, follow these steps:
- Create an instance of `Highlightr`:
- Load the desired syntax theme:
- Highlight the code:
- Render the highlighted code:
let highlightr = Highlightr()
let highlightedCode = highlightr.highlight(code, as: language)
textView.attributedText = highlightedCode
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:
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.
- Issue #2: The line numbers are not displayed.
Solution: Ensure that you have set the correct language and theme for the code you want to highlight.
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.