Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeremiah-shaulov/html-to-vt100
Convert HTML to VT100 terminal codes, to print colored and styled messages.
https://github.com/jeremiah-shaulov/html-to-vt100
Last synced: 6 days ago
JSON representation
Convert HTML to VT100 terminal codes, to print colored and styled messages.
- Host: GitHub
- URL: https://github.com/jeremiah-shaulov/html-to-vt100
- Owner: jeremiah-shaulov
- License: mit
- Created: 2020-07-25T23:31:52.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-26T00:46:24.000Z (over 4 years ago)
- Last Synced: 2024-12-15T17:11:58.381Z (about 1 month ago)
- Language: PHP
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# html-to-vt100
Convert HTML to VT100 terminal codes, to print colored and styled messages.
## Installation
Create a directory for your application, `cd` to it, and issue:
```bash
composer require jeremiah-shaulov/html-to-vt100
```## Example
```php
BBBccc
');// to error log
error_log(Vt100::from_html('aaaBBBccc
'));
```CLI applications can echo messages to terminal. Web applications can write them to error log, or to a custom log file, and then view it with
```bash
less -r filename.log
```The written file can be then converted to HTML and presented in browser:
```php
IMPORTANT message
"));
file_put_contents($FILENAME, Vt100::from_html("Notice message
"), FILE_APPEND);
file_put_contents($FILENAME, Vt100::from_html("Warning message
"), FILE_APPEND);// 2. Read and present to browser
echo Vt100::to_html(file_get_contents($FILENAME));
```## What supported
Limited subset of HTML is supported:
- `
`
- `bold`
- `italic`
- `underlined`
- `blink` - Most modern terminals don't support this.
- `inverse fg/bg`
- `` - Produces classic escape codes for black, red, green, yellow, blue, magenta, cyan and white. For other HTML colors - nonclassic.
- `` - Produces nonclassic escape codes.
- ``
- ``
- `bold normal`
- `italic normal`
- `underlined normal`
- `blue`## API
Namespace Vt100 contains one class called Vt100 with 2 static functions:
```php
public static function from_html($str); // Converts HTML to VT100 escape codes.public static function to_html($str); // Converts VT100 escape codes produced by from_html() back to HTML.
```