Download the PHP package demyanovs/php-highlight without Composer
On this page you can find all versions of the php package demyanovs/php-highlight. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download demyanovs/php-highlight
More information about demyanovs/php-highlight
Files in demyanovs/php-highlight
Package php-highlight
Short Description A PHP library for highlighting code syntax.
License MIT
Informations about the package php-highlight
PHPHighlight
PHPHighlight is a PHP syntax highlighting library that can be easily customized and extended.
How it works
The library parses the text, finds the <pre> and <pre><code> tags, reads the attributes (data-lang, data-file, data-theme) and highlights the syntax of the code block.
Recommended: Use <pre><code> pattern for better semantics and compatibility with Markdown output.
Supports style customization. Here are examples of styling:
Requirements
PHP 8.1+
Installation
You can install package via composer
Usage
See full example in examples/index.php
Customization
You can set following attributes in <pre> or <code> tags:
data-langorclass="language-*"- a language of the text. This affects how the parser will highlight the syntax.data-file- show file name in action panel.data-theme- allows to overwrite the global theme.
Note: class="language-*" on <code> tag is automatically recognized (common in Markdown output).
How to create a custom theme
To create a custom theme you need to create an instance of Demyanovs\PHPHighlight\Themes\Theme class
and pass it to Highlighter as a third argument:
Supports language syntax
- PHP
- JavaScript
- XML/HTML
- Bash
- Go
- and others
Themes
- default
- darkula
- railscasts
- obsidian
- far
- vs2015
- c64
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Changelog
See CHANGELOG.md for a list of changes and version history.
License
MIT
All versions of php-highlight with dependencies
ext-dom Version *