highlight.php is a server-side syntax highlighter written in PHP that currently supports 185 languages

Overview

highlight.php

Unit Tests Latest Packagist release Monthly downloads on Packagist

highlight.php is a server-side syntax highlighter written in PHP that currently supports 185 languages. It's a port of highlight.js by Ivan Sagalaev that makes full use of the language and style definitions of the original JavaScript project.

This is the README for highlight.php v10, which is currently under development. The latest stable release is the 9.18.x series.

Table of Contents

Installation + Setup

The recommended approach is to install the project through Composer.

composer require scrivo/highlight.php

If you're not using Composer, ensure that the classes defined in the Highlight namespace can be found either by inclusion or by an autoloader. A trivial autoloader for this purpose is included in this project as Highlight\Autoloader.php

Composer Version Constraints

When requiring this project in your composer.json, it is recommended you use the caret version range and use only the major and minor values; i.e. ^9.14.

It's come to our attention that a lot of tutorials and projects out there are locking themselves into highly specific versions of this project; e.g. "scrivo/highlight.php": "v9.12.0.1". Please do not do this or encourage it. We promise a reliable backward compatibility policy so there's no reason to lock yourself to such a specific version. By doing this, you are preventing yourself or your users from receiving updates to language definitions and bug fixes.

Usage

The \Highlight\Highlighter class contains the syntax highlighting functionality. You can choose between two highlighting modes:

  1. explicit mode
  2. automatic language detection mode

Explicit Mode

In explicit mode, you must define which language you will be highlighting as.

language}\">"; echo $highlighted->value; echo ""; } catch (DomainException $e) { // This is thrown if the specified language does not exist echo "
";
    echo htmlentities($code);
    echo "
"; } ">
// Instantiate the Highlighter.
$hl = new \Highlight\Highlighter();
$code = file_get_contents('some_ruby_script.rb');

try {
    // Highlight some code.
    $highlighted = $hl->highlight('ruby', $code);

    echo "
language}\">";
    echo $highlighted->value;
    echo "
"
; } catch (DomainException $e) { // This is thrown if the specified language does not exist echo "
";
    echo htmlentities($code);
    echo "
"
; }

Automatic Language Detection Mode

Alternatively you can use the automatic detection mode, which highlights your code with the language the library thinks is best. It is highly recommended you explicitly choose the language or limit the number of languages to automatically detect to reduce the number of inaccuracies.

Warning: Auto-detection occurs in a brute force fashion and the language with the most accurate result will be selected. This is extremely inefficient as you supply more languages and may not always be 100% accurate if similar languages are configured.

language}\">"; echo $highlighted->value; echo ""; ">
$hl = new \Highlight\Highlighter();
$hl->setAutodetectLanguages(array('ruby', 'python', 'perl'));

$highlighted = $hl->highlightAuto(file_get_contents('some_ruby_script.rb'));

echo "
language}\">";
echo $highlighted->value;
echo "
"
;

Default Languages

If no autodetect languages are set in the highlighter, then every language will be used and cause significant performance issues.

Stylesheets

The same stylesheets available in the highlight.js project are available in the styles directory of this project and may be included in your own CSS or made accessible to your web server.

Highlighter Utilities

The core of the project is loyal port of highlight.js and is available under the main Highlight namespace. A series of convenience functions are provided under the HighlightUtilities namespace to introduce additional functionality without the need for another dependency.

Available functions:

Versioning

This project will follow the same version numbers as the highlight.js project with regards to languages, meaning that a language definition available in highlight.js 9.12.0 will be available in highlight.php 9.12.0. However, there are times where bugs may arise in this project or its translated definition files, so there'll be one more number appended to the version number. For example, version 9.12.0.1 will contain all of the same languages as highlight.js 9.12.0 but also contain fixes solely to this project. This is done so this project can have version bumps without conflicts should highlight.js release version 9.12.1.

Backward Compatibility Promise

Despite the fact that the semantic versioning used in this project mirrors that of highlight.js, this project will adhere to Symfony's Backward Compatibility Promise. You can rest assured that there will be no breaking changes during 9.x and any deprecations will be marked with @deprecated and won't be removed until the next major release.

Some History

Geert Bergman Sep 30, 2013

JavaScript code highlighting is very convenient and in many cases just what you want to use. Especially for programming blogs I would not advice you to use otherwise. But there are occasions where you're better off with a more 'static' approach, for instance if you want to send highlighted code in an email or for API documents. For this I needed a code highlighting program preferably written in PHP.

I couldn't found any satisfactory PHP solution so I decided to port one from JavaScript. After some comparison of different highlighting programs based on license, technology, language support highlight.js came out most favorable in my opinion.

It was my decision not to make a PHP highlighter but to do a port of highlight.js, these are different things. The goal was to make it work exactly as highlight.js to make as much use as possible of the language definitions and CSS files of the original program.

Happy coding!

License

BSD

Comments
  • Freezing issue with coffeescript regex under some circumstances

    Freezing issue with coffeescript regex under some circumstances

    https://github.com/highlightjs/highlight.js/issues/2375

    You may want to follow this, not sure how important you consider this type of issue. I think it's pretty bad and plan to release 9.18.1 as soon as we have an approved fix.

    bug upstream 
    opened by joshgoebel 20
  • Performance issue

    Performance issue

    I have a table with 25 records and on each row there is a column which needs to be highlighted. Without highlighter it loads in 0.3 ms. With highlighter it loads in 1 min 30 sec.

    Is the performance so bad?

    Thanks!

    bug 
    opened by galiganu 14
  • Highlighter duplicating Russian characters (unicode)

    Highlighter duplicating Russian characters (unicode)

    Source code

    <?php
    use yii\helpers\Html;
    use yii\widgets\ActiveForm;
    
    $form = ActiveForm::begin([
        'id' => 'login-form',
        'options' => ['class' => 'form-horizontal'],
    ]) ?>
        <?= $form->field($model, 'username') ?>
        <?= $form->field($model, 'password')->passwordInput() ?>
    
        <div class="form-group">
            <div class="col-lg-offset-1 col-lg-11">
                <?= Html::submitButton('Вход', ['class' => 'btn btn-primary']) ?>
            </div>
        </div>
    <?php ActiveForm::end() ?>
    

    Highlight code:

    $hl = new \Highlight\Highlighter();
    $highlighted = $hl->highlight('php', $code);
    echo "<pre><code class=\"hljs {$highlighted->language}\">{$highlighted->value}</code></pre>";
    

    Highlighted code, look here - ('Входодд:

    <pre><code class="hljs php"><span class="hljs-meta">&lt;?php</span>
    <span class="hljs-keyword">use</span> <span class="hljs-title">yii</span>\<span class="hljs-title">helpers</span>\<span class="hljs-title">Html</span>;
    <span class="hljs-keyword">use</span> <span class="hljs-title">yii</span>\<span class="hljs-title">widgets</span>\<span class="hljs-title">ActiveForm</span>;
    
    $form = ActiveForm::begin([
        <span class="hljs-string">'id'</span> =&gt; <span class="hljs-string">'login-form'</span>,
        <span class="hljs-string">'options'</span> =&gt; [<span class="hljs-string">'class'</span> =&gt; <span class="hljs-string">'form-horizontal'</span>],
    ]) <span class="hljs-meta">?&gt;</span>
        <span class="hljs-meta">&lt;?</span>= $form-&gt;field($model, <span class="hljs-string">'username'</span>) <span class="hljs-meta">?&gt;</span>
        <span class="hljs-meta">&lt;?</span>= $form-&gt;field($model, <span class="hljs-string">'password'</span>)-&gt;passwordInput() <span class="hljs-meta">?&gt;</span>
    
        &lt;div <span class="hljs-class"><span class="hljs-keyword">class</span>="<span class="hljs-title">form</span>-<span class="hljs-title">group</span>"&gt;
            &lt;<span class="hljs-title">div</span> <span class="hljs-title">class</span>="<span class="hljs-title">col</span>-<span class="hljs-title">lg</span>-<span class="hljs-title">offset</span>-1 <span class="hljs-title">col</span>-<span class="hljs-title">lg</span>-11"&gt;
                &lt;?= <span class="hljs-title">Html</span>::<span class="hljs-title">submitButton</span>('Входодд<span class="hljs-title">class</span>' =&gt; '<span class="hljs-title">btn</span> <span class="hljs-title">btn</span>-<span class="hljs-title">primary</span>']) ?&gt;
            &lt;/<span class="hljs-title">div</span>&gt;
        &lt;/<span class="hljs-title">div</span>&gt;
    &lt;?<span class="hljs-title">php</span> <span class="hljs-title">ActiveForm</span>::<span class="hljs-title">end</span>() ?&gt;</span></code></pre>
    
    bug 
    opened by WinterSilence 12
  • Allow HTML Tags in Code Snippet

    Allow HTML Tags in Code Snippet

    The reason I use highlight.js in my blog was because it allows me to preserve HTML tags inside the code snippet. Knowing that there is a highlight.php project makes everything so perfect! But one thing is missing; that is the ability to retain HTML tags inside the code snippet. I used to add <mark> tags to explain to my readers about the important parts, and maybe some <a> tags to link some piece of code to the documentation page.

    How do I keep the HTML markup in my code snippet? Disabling the “safe mode” does not work for me. It always throws “`self` is not supported at the top-level of a language.” message anyway.

    By the way, I have used your project to complete my content management system extension here. This project fits my environment so well :+1:

    Thanks.

    enhancement wontfix 
    opened by taufik-nurrohman 9
  • Demo took a long time to run & Normal chatacters Rander

    Demo took a long time to run & Normal chatacters Rander

    Maybe there're some bugs in the demo(i didn't use composer) When i ran demo.php, it shows 504 and the CPU dashed to 98%. Then i use php demo.php and it says

    PHP Fatal error: Uncaught Error: Call to undefined function Highlight\mb_strlen() in /home/judge/src/web/light/Highlight/RegEx.php:99 Stack trace: #0 /home/judge/src/web/light/Highlight/Terminators.php(98): Highlight\RegEx->exec('...') #1 /home/judge/src/web/light/Highlight/Highlighter.php(681): Highlight\Terminators->exec('...') #2 /home/judge/src/web/light/Highlight/Highlighter.php(765): Highlight\Highlighter->highlight('xml', '...', false) #3 /home/judge/src/web/light/demo/demo.php(59): Highlight\Highlighter->highlightAuto('...') #4 {main} thrown in /home/judge/src/web/light/Highlight/RegEx.php on line 99

    Can you explain why this happen or fix it? Hope to hear from you.

    question 
    opened by MX-Qulin 8
  • "Invalid" regular expressions in registered languages broke autodetection

    In our Language class, we have a langRe() method, which is tasked with putting together our regular expressions.

    https://github.com/scrivo/highlight.php/blob/a4930dde24bf6b9064fb52c22d71211144567e7f/Highlight/Language.php#L108-L111

    As I was rewriting the unit tests, I noticed that the language files for 1c and ada contained the following two regular expressions:

    • \d{4}([\.\\/:-]?\d{2}){0,5} <- the / is treated as a delimiter
    • []{}%#'" <- the [ and ] aren't escaped

    Since our method isn't very smart, putting these two regular expressions in between / caused E_ERRORs to be thrown. If these languages are registered in Highlighter for autodetection, then it'll fail due to the E_ERROR.

    I manually modified the language files for the affected languages and tagged 9.12.0.1, but this needs a better solution. I'd be opposed to having to manually modify the language files since they're generated directly from highlight.js, so I'd favor improving our regex building in the Language class. Thoughts? Any better solutions?

    /cc @S1SYPHOS

    Edit: We could also add another round of patches to our get_language_definitions.php file, too I guess...

    bug 
    opened by allejo 7
  • RFC: Minimum PHP version for highlight.php 10

    RFC: Minimum PHP version for highlight.php 10

    It looks like highlight.js v10 is in the planning. This means per our BC policy, we'll be removing any deprecated functionality once we release a v10 of this project.

    Additionally, I would like to get feedback from the community about the minimum PHP version for the next major release of this project. I typically align my projects with the LTS versions of other major projects:

    • Symfony 3.4 LTS (EOL: November 2021) PHP >= 5.5
    • Symfony 4.4 LTS (EOL: November 2023) PHP >= 7.1
    • Laravel 5.5 LTS (EOL: August 2020) PHP >= 7.0
    • Laravel 6 LTS (EOL: September 2022) PHP >= 7.2
    • Debian 8 LTS (EOL: June 2020) PHP >= 5.6
    • Debian 9 LTS (EOL: June 2022) PHP >= 7.0
    • Ubuntu 16.04 LTS (EOSS: April 2021) PHP >= 7.0
    • Ubuntu 18.04 LTS (EOSS: April 2023) PHP >= 7.2
    • WordPress PHP >= 5.6

    Given this information, I'd like to hear from the users of this library as to what PHP version they're using and if it's an older version, why they're still supporting it. There's still time until highlight.php v10 but the more information I can get early the better.

    There's nothing in this library that critically relies on a feature in PHP 7.x, so I don't mind keeping the minimum PHP 5.x but if there aren't enough users using an EOL'd version of PHP, I won't bother with it either.

    Related

    • https://github.com/highlightjs/highlight.js/issues/2273
    administrative 
    opened by allejo 6
  • Line numbers demo doesn't work with multi-line comments

    Line numbers demo doesn't work with multi-line comments

    I know that line numbers aren't officially supported by this project, but I wanted to flag that the line numbers demo fails on multi-line comments: Because the <span> tag wraps multiple lines, only the first line of the comment is properly styled once those lines are then placed in table cells.

    Is there a way around this? If each line of the comment were wrapped in a <span> tag instead of the comment in its entirety, that would solve the problem, for example.

    bug 
    opened by gregsullivan 6
  • Ability to list available language aliases

    Ability to list available language aliases

    The purpose of this PR is to introduce ability to access information about the available language aliases via the Highligther class instances.

    This can be particularly helpful in web applications if presenting user with a drop-down list of syntaxes to choose from.

    Although the normalised names should be quite helpful, they can sometimes also be a bit confusing, for example the html language is merely an alias for xml. This is not super-obvious to most users (and in fact for a while I thought the library had no HTML syntax highlighting myself).

    I've also tried to implement tests for methods that got changed/added to help with regression testing.

    All input is welcome, so if you think something needs to be changed/improved, do let me know - especially since PHP is not something I delve into on regular basis :)

    enhancement 
    opened by azaghal 6
  • Enhancements

    Enhancements

    This PR

    • Fixes PHP coding standards issues (PSR1/2)
    • Make the classes extendible (by changing the scope of private to protected methods)
    • Implements code to automatically resolved language dependencies
    • Addresses the issue of invalid regexes #15
    • Implements lazy-loading of language files
    • Allows to fetch language files
    • Simplifies code structure
    • Adds docblocks
    opened by Sommerregen 6
  • Dynamic properties are deprecated in PHP 8.2

    Dynamic properties are deprecated in PHP 8.2

    Hi, I tested the highlighter with PHP 8.2 today and found two potential issues.

    Code in Highlighter::__construct() initialises two properties which don't exist in class RegExMatch:

    $this->lastMatch = new RegExMatch(array());
    $this->lastMatch->type = "";
    $this->lastMatch->rule = null;
    

    Code in Terminators::exec() initialises another property RegExMatch::extra, but apparently is never used:

    $match->extra = array($this->mode->illegal, $this->mode->terminator_end);
    

    Let me know if you need more information. Thanks for investigating.

    bug php-version 
    opened by markseuffert 4
  • Theme Rendering Inconsistency on PHP codes

    Theme Rendering Inconsistency on PHP codes

    Hello, I'm migrating from hihglight.js to hihglight.php.
    I was able to setup basic things to make it work. However I have issue with the rendering.

    In my case I want to highlight some PHP codes with Paraiso Dark theme. BUT the result is bit different. Consider:

    highlightjsphp rendering inconsistencies

    So ones that was done with highlight.js is perfectly rendered, the enum keyword is recognized and so does the self:$key construct inside the match body. While ones that was done with hihglight.php is not as perfect as that.

    I have tried to use both manual mode and auto detect mode but no luck :

    $hl=new Highlighter();
    
    //didn't work 
    $hl->setAutodetectLanguages(["php"]);
    $highlight=$hl->highlightAuto($codes);
    
    //didn't work either
    $highlight=$hl->highlight("php",$codes);
    

    This is my env:

    • PHP 8.2
    • highlight.php v9.18.1.10

    help?

    UPDATE This is also affect other sources too, I've tried to highlight JS code and the rendering is different from it should be

    opened by blackjyn 0
  • PHP code seems to be insufficiently tagged.

    PHP code seems to be insufficiently tagged.

    echo $this->highlighter
        ->highlight(
            'php',
            <<<'CODE'
            <?php
            
            $high = $dog->cat();
            $dog = new Cat();
            CODE
        )
        ->value;
    

    This code echos:

    <span class="hljs-meta">&lt;?php</span>
    
    $high = $dog-&gt;cat();
    $dog = <span class="hljs-keyword">new</span> Cat();
    

    Is there something that I'm doing wrong that prevents.. for example.. the class name to be wrapped in a span? Only the 'new' keyword and '<?php' meta seems to be specified.

    bug needs investigation 
    opened by ShawnMcCool 0
  • C# - Missing keywords

    C# - Missing keywords

    I noticed some missing keywords from the latest versions of C#:

    • record

    Example: public record Movie(string Title);

    • with

    Example: var m = a with { Name = "Test"}

    These were new keywords added in .NET 5 / C# 9. I'm kinda guessing there might be other missing keywords from the latest versions. I haven't noticed any, just these two.

    For reference: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/

    upstream future release 
    opened by makolyte 0
  • PHP Template Language Missing

    PHP Template Language Missing

    The "PHP Template" language is missing. Only "php" can be passed to Highlighter::highlight(), but it should allow something like "php-template" or "php_template".

    See https://highlightjs.org/static/demo/: image

    future release 
    opened by jacobalvarez 3
  • Where is highlight.php v10.x/v11.x?

    Where is highlight.php v10.x/v11.x?

    For anyone curious and before anyone asks, highlight.php 10.x/11.x is planned ~~and development will start in the coming weeks~~. I first need to finish off my semester and a few other commitments.

    highlight.php 10 will require PHP 5.6+ (see #55)

    The current estimated release of highlight.php v10/11 is Winter 2021


    Why the delay?

    highlight.js v10 introduced some breaking changes where grammars can no longer be represented by just JSON; grammars now support JS callbacks. While not many grammars are using this feature as of yet, I'm hesitant to dedicate myself to manually porting JS to PHP.

    Does this mean highlight.php is dead?

    No. Not at all. I do have some ideas for automatically translating JS to PHP to address this problem. I simply have not had time to work on this.

    It's been over a year since this issue was created. Why haven't you done it yet?

    I've had other projects, work, and school that have required my attention/focus/time. Feel free to sponsor me to work on this project :smile: :heart:

    administrative 
    opened by allejo 25
Releases(v9.18.1.10)
  • v9.18.1.10(Dec 17, 2022)

    A holiday maintenance release to fix support for PHP 8.2

    Fixes

    • Declare previous dynamic properties by @phpfui in https://github.com/scrivo/highlight.php/pull/102
    Source code(tar.gz)
    Source code(zip)
  • v9.18.1.9(Dec 24, 2021)

  • v9.18.1.8(Oct 24, 2021)

    Changes

    • Drop mbstring as a hard dependency for the project, which was only used for matching Unicode keywords in languages like 1C. Unless the code being highlighted contains Unicode characters, then we'll default to the faster, normal str* functions (#92)
    Source code(tar.gz)
    Source code(zip)
  • v9.18.1.7(Jul 9, 2021)

    Fixes

    • Fix characters being duplicated or eaten up when the code being highlighted contains Unicode characters (https://github.com/westonruter/syntax-highlighting-code-block/issues/400, https://github.com/scrivo/highlight.php/issues/87, https://github.com/scrivo/highlight.php/pull/90)
    Source code(tar.gz)
    Source code(zip)
  • v9.18.1.6(Dec 22, 2020)

    Fixes

    • Rewrite splitCodeIntoArray yet again to fix more edge cases and have 3x the speed (#85)
      • The ext-dom suggested requirement has been dropped
      • This function no longer throws RuntimeException or UnexpectedValueException

    Thanks to @westonruter for the help on this release 🎉

    Source code(tar.gz)
    Source code(zip)
  • v9.18.1.5(Nov 22, 2020)

  • v9.18.1.4(Nov 1, 2020)

    New

    • Add new $loadAllLanguages parameter to Highlighter constructor to opt-out of automatic language registration. If you opt-out, you must call Highlighter::registerLanguage() for each language that you want.
    • Now that language registration can be opted out of, Highlighter::registerAllLanguages() has been made public to allow registering all bundled languages if you change your mind.
    • Add Highlighter::clearAllLanguages() to allow clearing registered languages
    • Add two new utility functions to HighlightUtilities:
      • getLanguagesFolder() - get the file path to the bundled languages folder
      • getLanguageDefinitionPath() - get the file path to a specific bundled language definition
    • Add new Highlighter::listBundledLanguages() function
    • Add new Highlighter::listRegisteredLanguages() function

    Fixes

    • Fix Highlighter::listLanguages() not getting correctly updated when custom languages were registered

    Deprecations

    • Deprecated Highlighter::listLanguages(), use listBundledLanguages() or listRegisteredLanguages() instead
    Source code(tar.gz)
    Source code(zip)
  • v9.18.1.3(Oct 16, 2020)

    Fixes

    • splitCodeIntoArray() now generates valid HTML when there are nested <span> tags in the highlighted code (#79)
    • splitCodeIntoArray() no longer throws a warning when an empty string was given as a parameter (#80)
    Source code(tar.gz)
    Source code(zip)
  • v9.18.1.2(Aug 27, 2020)

  • v9.18.1.1(Mar 2, 2020)

  • v9.18.1.0(Feb 3, 2020)

  • v9.18.0.0(Jan 29, 2020)

  • v9.17.1.1(Jan 27, 2020)

    Fixes

    • classPrefix and tabReplace settings are now propagated to sub-languages (#61 @taufik-nurrohman)
    • The "safe mode" setting is now propagated down to sub-languages

    Development

    • A lot of improvements to typings via PHPDoc annotations
    • Fix Travis unit testing in PHP 5.4 and 5.5
    • Fix example.php in the demo folder
    Source code(tar.gz)
    Source code(zip)
  • v9.17.1.0(Dec 14, 2019)

    There is no 9.17.0.0 release. The 9.17.1 release of the JS project was a hotfix so both 9.17.0 and 9.17.1 were combined into this one release.

    Changes

    • Ported over language definition and stylesheet changes from the highlight.js 9.17.0 release. See the highlight.js 9.17.1 changelog for more details as to what changed.
    Source code(tar.gz)
    Source code(zip)
  • v9.16.2.0(Dec 13, 2019)

    There are no 9.16.0.0 and 9.16.1.0 releases due to them being very minor JS releases, so they're all combined into a single 9.16.2.0 tag.

    Changes

    • Ported over language definition and stylesheet changes from the highlight.js 9.16.2 release. See the highlight.js 9.16.2 changelog for more details as to what changed.

    Deprecations

    These deprecations only exist because they were never marked as "internal," meaning some crazy library users could potentially be using these functions. These changes will likely not affect you if you're not doing anything crazy.

    • The JsonRef class has been marked as @final. In v10.x, this class will be marked as final through the final keyword.
    • JsonRef::decode() has been deprecated and will be removed in v10.x. It has been replaced by JsonRef::decodeRef().
    • The Language class has been marked as @final and will be made final in v10.x.
    • Language::complete() has been deprecated and will be removed in v10.x.
    • Language::$mode has been deprecated and will no longer be accessible. Any properties originally in $mode will now be available directly from the Language class.
    • Language::$caseInsensitive has been deprecated and has been replaced with Language::$case_insensitive to match highlight.js naming conventions.
    Source code(tar.gz)
    Source code(zip)
  • v9.15.10.0(Aug 27, 2019)

  • v9.15.9.0(Aug 9, 2019)

  • v9.15.8.1(Jul 20, 2019)

    New

    • Added new functions to HighlightUtilities for accessing bundled stylesheets (#47)
      • getAvailableStyleSheets(bool $filePaths = false)
      • getStyleSheet(string $name)
      • getStyleSheetFolder()
      • getStyleSheetPath(string $name)
    Source code(tar.gz)
    Source code(zip)
  • v9.15.8.0(May 31, 2019)

    There is no 9.15.7.0 release.

    Version 9.15.7 was the main release of highlight.js with language updates. However, 9.15.8 was an immediate hotfix so both these versions are bundled up into a single release for highlight.php.

    Changes

    • Ported over core changes, language definitions, and stylesheet changes from the highlight.js 9.15.7 - 9.15.8 releases. See the highlight.js 9.15.8 changelog for more details as to what changed.
    Source code(tar.gz)
    Source code(zip)
  • v9.15.6.1(Apr 2, 2019)

    New

    • The HighlightUtilities namespace was introduced as part of the official package
      • Add new splitCodeIntoArray() utility function to split highlighted results into an array of strings; i.e. an official way of handling line numbers

    Changes

    • License headers for files have been updated to be less of a paradox

    Development

    • The demo.php script no longer times out and it'll just run for a ridiculously long time instead
    Source code(tar.gz)
    Source code(zip)
  • v9.15.6.0(Mar 6, 2019)

    Versions 9.15.2 through 9.15.6 of the highlight.js project have consisted solely of hotfixes for the JS package only. This means that no core changes have been made to the actual highlighter nor have updated definitions been added. The 9.15.6.0 tag for highlight.php is functionally equivalent to 9.15.1.0 and only exists to match the current version of the highlight.js project.

    Source code(tar.gz)
    Source code(zip)
  • v9.15.1.0(Mar 6, 2019)

  • v9.15.0.0(Mar 6, 2019)

  • v9.14.2.0(Feb 8, 2019)

    Changes

    • Ported over language definition, and stylesheet changes from the highlight.js 9.14.2 release. See the highlight.js 9.14.2 changelog for more details as to what changed.

    Development

    • Add new DISABLE_WARN_EXCEPTIONS environment variable to disable the functionality of casting PHP warnings into exceptions in the unit tests for this project
    • preg_match() warnings are now silenced and an exception is thrown instead
      • These warnings would only ever be triggered if a language definition had invalid regular expressions; this shouldn't have any side effects as language definitions maintained by the project should have valid regex anyways. This change will affect you if you have written your own custom language definitions and you have invalid regex in them. Instead of an E_ERROR or E_WARNING, you'll get an exception now.
    Source code(tar.gz)
    Source code(zip)
  • v9.14.1.0(Feb 8, 2019)

  • v9.14.0.0(Feb 8, 2019)

  • v9.13.1.1(Jan 15, 2019)

    Thanks a lot to @assertchris for helping fix PHP 7.3 support! 🎉 The way references are handled in the language and the PCRE engine were changed, so this tag incorporates the necessary changes for this project to run on PHP 7.3. Support for PHP 5.4+ remains unchanged.

    Changes

    • Fix support for PHP 7.3 (#34)
    Source code(tar.gz)
    Source code(zip)
  • v9.13.1.0(Nov 23, 2018)

    Changes

    • Ported over core, language definition, and stylesheet changes from the highlight.js 9.13.1 release. See the highlight.js 9.13.1 changelog for more details as to what changed.

    Development

    • Added composer test script for quicker unit testing
    • Added java and shell as known auto-detection test failures
    • Auto-detection test failures will now display relevance scores
    Source code(tar.gz)
    Source code(zip)
  • v9.13.0.0(Nov 23, 2018)

    Changes

    • Ported over core, language definition, and stylesheet changes from the highlight.js 9.13.0 release. See the highlight.js 9.13.0 changelog for more details as to what changed.
    • A dependency on ext-json and ext-mbstring has been added to composer.json. The dependency on these extensions has existed for years, it's just never been explicitly listed. This change should not have any adverse side effects.
    Source code(tar.gz)
    Source code(zip)
  • v9.12.0.5(Aug 24, 2018)

    Changes

    • Minor performance improvements during language registration (#26)

    Development

    • Configure Travis to run unit tests and style checks
    • Add demo for how to use line numbers with the highlighted code
    Source code(tar.gz)
    Source code(zip)
Owner
Geert Bergman
Geert Bergman
A lightweight php class for formatting sql statements. Handles automatic indentation and syntax highlighting.

SqlFormatter A lightweight php class for formatting sql statements. It can automatically indent and add line breaks in addition to syntax highlighting

Jeremy Dorn 3.9k Jan 1, 2023
A lightweight php class for formatting sql statements. Handles automatic indentation and syntax highlighting.

SqlFormatter A lightweight php class for formatting sql statements. It can automatically indent and add line breaks in addition to syntax highlighting

Jeremy Dorn 3.9k Jan 3, 2023
ATOMASTIC 14 Mar 12, 2022
A PHP string manipulation library with multibyte support. Compatible with PHP 5.4+, PHP 7+, and HHVM.

A PHP string manipulation library with multibyte support. Compatible with PHP 5.4+, PHP 7+, and HHVM. s('string')->toTitleCase()->ensureRight('y') ==

Daniel St. Jules 2.5k Dec 28, 2022
"結巴"中文分詞:做最好的 PHP 中文分詞、中文斷詞組件。 / "Jieba" (Chinese for "to stutter") Chinese text segmentation: built to be the best PHP Chinese word segmentation module.

jieba-php "結巴"中文分詞:做最好的 PHP 中文分詞、中文斷詞組件,目前翻譯版本為 jieba-0.33 版本,未來再慢慢往上升級,效能也需要再改善,請有興趣的開發者一起加入開發!若想使用 Python 版本請前往 fxsjy/jieba 現在已經可以支援繁體中文!只要將字典切換為 bi

Fukuball Lin 1.2k Dec 31, 2022
Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

Motto: "Every business should have a detection script to detect mobile readers." About Mobile Detect is a lightweight PHP class for detecting mobile d

Şerban Ghiţă 10.2k Jan 4, 2023
A PHP library for generating universally unique identifiers (UUIDs).

ramsey/uuid A PHP library for generating and working with UUIDs. ramsey/uuid is a PHP library for generating and working with universally unique ident

Ben Ramsey 11.9k Jan 8, 2023
👮 A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

Agent A PHP desktop/mobile user agent parser with support for Laravel, based on Mobile Detect with desktop support and additional functionality. Insta

Jens Segers 4.2k Jan 5, 2023
A PHP string manipulation library with multibyte support

A PHP string manipulation library with multibyte support. Compatible with PHP 5.4+, PHP 7+, and HHVM. s('string')->toTitleCase()->ensureRight('y') ==

Daniel St. Jules 2.5k Jan 3, 2023
A sane interface for php's built in preg_* functions

Making regex great again Php's built in preg_* functions require some odd patterns like passing variables by reference and treating false or null valu

Spatie 1.1k Jan 4, 2023
A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

URLify for PHP A fast PHP slug generator and transliteration library, started as a PHP port of URLify.js from the Django project. Handles symbols from

Aband*nthecar 667 Dec 20, 2022
🉑 Portable UTF-8 library - performance optimized (unicode) string functions for php.

?? Portable UTF-8 Description It is written in PHP (PHP 7+) and can work without "mbstring", "iconv" or any other extra encoding php-extension on your

Lars Moelleken 474 Dec 22, 2022
ColorJizz is a PHP library for manipulating and converting colors.

#Getting started: ColorJizz-PHP uses the PSR-0 standards for namespaces, so there should be no trouble using with frameworks like Symfony 2. ###Autolo

Mikeemoo 281 Nov 25, 2022
🔡 Portable ASCII library - performance optimized (ascii) string functions for php.

?? Portable ASCII Description It is written in PHP (PHP 7+) and can work without "mbstring", "iconv" or any other extra encoding php-extension on your

Lars Moelleken 380 Jan 6, 2023
:clamp: HtmlMin: HTML Compressor and Minifier via PHP

??️ HtmlMin: HTML Compressor and Minifier for PHP Description HtmlMin is a fast and very easy to use PHP library that minifies given HTML5 source by r

Lars Moelleken 135 Dec 8, 2022
Generate Heroku-like random names to use in your php applications.

HaikunatorPHP Generate Heroku-like random names to use in your PHP applications. Installation composer require atrox/haikunator Usage Haikunator is p

Atrox 99 Jul 19, 2022
Extensive, portable and performant handling of UTF-8 and grapheme clusters for PHP

Patchwork UTF-8 for PHP Patchwork UTF-8 gives PHP developpers extensive, portable and performant handling of UTF-8 and grapheme clusters. It provides

Nicolas Grekas 80 Sep 28, 2022
PHP library to parse urls from string input

Url highlight - PHP library to parse URLs from string input. Works with complex URLs, edge cases and encoded input. Features: Replace URLs in string b

Volodymyr Stelmakh 77 Sep 16, 2022
:accept: Stringy - A PHP string manipulation library with multibyte support, performance optimized

?? Stringy A PHP string manipulation library with multibyte support. Compatible with PHP 7+ 100% compatible with the original "Stringy" library, but t

Lars Moelleken 144 Dec 12, 2022