An open API service indexing awesome lists of open source software.

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

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


  1. <?php



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