melabuai
Multi Syntax Highlighter programmed with PHP. Immediately ready for use and can be used anywhere in seconds.
- HTML
- CSS
- LESS
- SASS
- JavaScript
- PHP
- MySQL
- Perl And many more...
Very easy to use and very easy to modify. All you have to do is to include the file, instantiate the class, and call the method method with the string.
This solution extends the vendor autoloader because it calls the files with certain criteria. The extension allows you to call classes wherever the Autloder is involved.
Download Composer local or global. Check for more Tutorial - NetBeans with Composer and Packagist for this one.
You found the package on Packigist - Syntaxo.
Add the Syntaxo dependencie to the composer.json and set the autoload.
{
"autoload": {
"psr-4": { "Syn\\": "src/" }
},
"require": {
"prod3v3loper/syntaxo": ">=1.0"
},
Now run the composer install command with php
php composer.phar install
index.php
require_once __DIR__ . '/vendor/autoload.php';
$HIGHLIGHT = new \Syn\Syntaxo();
echo $HIGHLIGHT->process('
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Highlight</title>
</head>
<body>
<!-- Content -->
</body>
</html>
');
git clone https://github.com/prod3v3loper/syntaxo.git /Users/username/projects/
Get per Git or download and use it.
index.php
require_once './src/Syntaxo.php';
$HIGHLIGHT = new \Syn\Syntaxo();
echo $HIGHLIGHT->process('
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Highlight</title>
</head>
<body>
<!-- Content -->
</body>
</html>
');
Here's a snippet of Syntaxo regex for comments on each language. And you can modify them as needed and get even better results.
// HTML
"/(<\!\-\-[[:space:]]*.*[[:space:]]*\-\->)/isU" => '<span class="c">\\1</span>',
// JavaScript
"/(\/\/.*\n+)/isU" => '<span class="c">\\1</span>',
// CSS
"/(?<!\w)((\/\*\s*|\*\s*)([^\[|\#]*)(\*\/)?)/i" => '<span class="c">\\1</span>',
Please read the contributing.
Samet Tarim prod3v3loper