scrivo / highlight.php

A port of highlight.js by Ivan Sagalaev to PHP
BSD 3-Clause "New" or "Revised" License
695 stars 45 forks source link

Improvements to register custom languages #26

Closed markseuffert closed 6 years ago

markseuffert commented 6 years ago

Hi, this pull request changes two things. First function registerLanguages() will only register files that exist. This allows you to have as few files in the language folder as you need. Second function registerLanguage() has a new argument. This allows you to register custom files in the same way as the automatic registration, the default is to not overwrite language definition in the internal storage.

What problem does this solve? It should give you a bit flexibility and a performance improvement, in case you register custom files with registerLanguage(). For example a large API documentation on my computer (MacBook, PHP 7.1.16) took 200 ms to generate before, 120 ms after.

I am really impressed how fast this syntax highlighter works. The API documentation mentioned above previously took 850 ms to generate with another syntax highlighter. Great work. 👍

markseuffert commented 6 years ago

First time I use php-cs-fixer, code style should be updated now.

allejo commented 6 years ago

Thanks for this PR! I really like these minor improvements. And thanks for adhering to the code style changes 👍