https://github.com/kuria/php-highlighter
PHP code highlighter
https://github.com/kuria/php-highlighter
highlighter php
Last synced: about 1 year ago
JSON representation
PHP code highlighter
- Host: GitHub
- URL: https://github.com/kuria/php-highlighter
- Owner: kuria
- License: mit
- Created: 2018-01-13T14:28:44.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-01-05T12:16:56.000Z (over 1 year ago)
- Last Synced: 2025-04-14T23:13:08.631Z (about 1 year ago)
- Topics: highlighter, php
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
README
PHP highlighter
###############
PHP code highlighter.
.. image:: https://travis-ci.com/kuria/php-highlighter.svg?branch=master
:target: https://travis-ci.com/kuria/php-highlighter
.. contents::
Features
********
- highlighting files or strings
- highlighting specific line ranges
- marking an active line
- produces an ordered list (``
``) with corresponding line numbers
Requirements
************
- PHP 7.1+
Usage
*****
Highlighting code
=================
- ``PhpHighlighter::file()`` - highlight a PHP file
- ``PhpHighlighter::code()`` - highlight a string of PHP code
.. code:: php
- <?php
-
-
echo "Hello world!";
-
.. NOTE::
In PHP 8.3, output of the ``highlight_file()`` and ``highlight_string()`` functions
(which are used internally) has `changed `_.
If you're using PHP 8.3 or newer, the output will contain regular spaces instead of `` `` entities. You can use
``white-space: pre;`` in your CSS to fix this.
Marking an active line
======================
An active line can be specified using the second argument.
The active line will have a ``class="active"`` attribute.
.. code:: php