Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Zauberbutter committed Nov 24, 2017
0 parents commit 9bc508b
Show file tree
Hide file tree
Showing 10 changed files with 1,269 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# SynHigh - Syntax Highlight Module

Easy to use php syntax highlight module.

## Supported Languages/Configurations

* HTML
* CSS
* PHP (with PHP `highlight_string`)
* JS (with PHP `highlight_string`)
* HTACCESS

## Features

* Modular
* Expandable

## Using

Download the `dist/synhigh.zip`, unzip and put it into to your project directory. Then load the module in your `.php` file with:

```php
require_once('synParser.php')
```

Initialize with:

```php
new synhigh(string $source, string $language, bool $lineNumbers, int $lineBegin, int $lineEnd);
```

* `$source`: string to highlight
* `$language`: language name
* `php`, for PHP or JS
* `html`, for HTML and mixed HTML/PHP
* `css`
* `htaccess`
* `$lineNumbers`: when `true` synhigh will append line numbers [optional]
* `$lineBegin`: line where the source begins [optional]
* `$lineEnd`: line where the source ends [optional]

Functions:

* `$myVar->parseCode()`, returns the output as string
* `$myVar->setWithinLine(true)`, formats the output for using within a line
* Setter:
* `$myVar->setSource($source)` string
* `$myVar->setLang($lang)` string
* `$myVar->setLineNumbers($lineNumbers)` boolean
* `$myVar->setLineBegin($lineBegin)` integer
* `$myVar->setLineEnd($lineEnd)` integer

## License

Check the LICENSE file.
43 changes: 43 additions & 0 deletions lang/abstractLang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* SynHigh - Syntax Highlight Module
*
* Abstract Class For All Language Files
*/

abstract class abstractLang
{
// Required Functions

abstract protected function getCode($source);

// CSS Variables

// Fonts
protected $cssFont = 's';
// Comments
protected $cssComment = 'c';
// Keywords
protected $cssKeyword = 'k';
// Highlighted
protected $cssHighlight = 'h';
// Bold
protected $cssBold = 'b';
// Underline
protected $cssUnderline = 'u';

// Common Methods

/**
* Gets The Code
*
* @param string Source
* @return string Highlighted Source
*/
public function parse($source) {
return $this->getCode($source);
}
}

?>
Loading

0 comments on commit 9bc508b

Please sign in to comment.