Skip to content

๐Ÿ”ฎ Highlight your Syntax with one small php class 14.76 KiB and gzip: 4.03 KiB

License

Notifications You must be signed in to change notification settings

prod3v3loper/syntaxo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

77 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Melabuai Logo

Language Packgist PHP Version Packagist Version Repo Siz Code Siz Github Release date MIT License Website

melabuai

๐Ÿ”ฎ SYNTAXO

Multi Syntax Highlighter programmed with PHP. Immediately ready for use and can be used anywhere in seconds.

Theme Page of this Site

Size

  • HTML
  • CSS
  • LESS
  • SASS
  • JavaScript
  • PHP
  • MySQL
  • Perl And many more...

Usage

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.

Packagist with Composer

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 Install

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>
');

REGEX MODIFY

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
"/(&lt;\!\-\-[[:space:]]*.*[[:space:]]*\-\-&gt;)/isU" => '<span class="c">\\1</span>',
// JavaScript
"/(\/\/.*\n+)/isU" => '<span class="c">\\1</span>',
// CSS
"/(?<!\w)((\/\*\s*|\*\s*)([^\[|\#]*)(\*\/)?)/i" => '<span class="c">\\1</span>',

Preview

The index.php preview

Contribute

Please read the contributing.

Authors

Samet Tarim prod3v3loper

License

MIT