Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mkgor/highlighter
Library, which allows you to highlight your PHP code in console (terminal)
https://github.com/mkgor/highlighter
ascii code composer-package highlight php syntax syntax-highlighting terminal
Last synced: about 2 months ago
JSON representation
Library, which allows you to highlight your PHP code in console (terminal)
- Host: GitHub
- URL: https://github.com/mkgor/highlighter
- Owner: mkgor
- Created: 2020-04-26T12:50:55.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-04-30T19:02:24.000Z (over 4 years ago)
- Last Synced: 2024-10-13T13:02:34.335Z (3 months ago)
- Topics: ascii, code, composer-package, highlight, php, syntax, syntax-highlighting, terminal
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Highlighter
Library, which allows you to highlight your PHP code in terminal## Installation
Installation via composer:````
composer require mkgor/highlighter
````## Printing whole file
````php
getWholeFile(__FILE__);
````#### Result
![Result](https://i.imgur.com/TC1mP2u.png)## Printing code snippet (and highlighting specified line)
````php
getSnippet(__FILE__, 3);
````#### Result
![Result](https://i.imgur.com/iqEfh0d.png)
## Printing code snippet with specified lines
````php
getSpecifiedSnippet(__FILE__, 3, 5);
````#### Result
![Result](https://i.imgur.com/uuajqgQ.png)
## Printing single line
````php
getLine(__FILE__, 3);
````
#### Result![Result](https://i.imgur.com/qfJWGrP.png)
##
You can use same functions with suffix `WithoutNumbers` to highlight code without line numbers:```php
getWholeFileWithoutNumbers(__FILE__);
```#### Result
![Result](https://i.imgur.com/F7Mo4Rq.png)
## Themes
This highlighter supports custom themes. It has built-in themes, but you can create your own by implementing ```Highlighter\Theme\ThemeInterface```
So, to set theme, just call ```setTheme``` method of Highlighter
```php
setTheme(new Highlighter\Theme\DefaultThemes\Minimalistic());echo $highlighter->getWholeFile(__FILE__);
```#### Built-in themes:
##### Minimalistic
![Theme](https://i.imgur.com/0qGTZ1G.png)
##### Light
![Theme](https://i.imgur.com/zp4i1Di.png)
##### Material
![Theme](https://i.imgur.com/vENEwe1.png)