Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thlorenz/hermit
Prints html in the terminal using colors and simple layout to reflect the document structure.
https://github.com/thlorenz/hermit
Last synced: 5 days ago
JSON representation
Prints html in the terminal using colors and simple layout to reflect the document structure.
- Host: GitHub
- URL: https://github.com/thlorenz/hermit
- Owner: thlorenz
- License: mit
- Created: 2013-01-10T03:00:30.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2022-10-19T09:06:26.000Z (about 2 years ago)
- Last Synced: 2024-10-23T06:16:19.070Z (14 days ago)
- Language: JavaScript
- Homepage:
- Size: 248 KB
- Stars: 36
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hermit [![build status](https://secure.travis-ci.org/thlorenz/hermit.png)](http://next.travis-ci.org/thlorenz/hermit)
Prints html in the terminal using colors and simple layout to reflect the document structure.
## Objective
Provide a simple tool to render html in the terminal in a readable format. It is not supposed to replace your browser.
The main indended use is to render html snippets, e.g., the ones contained in the descriptions of the [json version of
the nodejs documentation](http://nodejs.org/api/assert.json).If you want a terminal browser, try [lynx](http://lynx.browser.org/) instead.
## Installation
npm install hermit
## Usage
### From the Command Line
To use hermit from the command line, you should install it globally:
npm -g install hermit
#### Rendering a File
hermit filename.html
#### Piping an Html String
You can pipe the output of any program that produces an html string into hermit.
**Example:**
curl http://nodejs.org/api/assert.html | hermit
### From Your Code
```js
var hermit = require('hermit')
, html = '';Hello from Hermit
A little paragraph for you
hermit(html, function (err, res) {
console.log(res);
});
```**Output:**
```
Hello from Hermit (in green)
-----------------
A little paragraph for you
```#### Custom Options
In order to affect the way that the printed html is layed out and styled, you can pass in custom properties.
These include a stylesheet with the properties outined in the [default hermit
stylesheet](https://github.com/thlorenz/hermit/blob/master/lib/stylesheet.js).```js
var hermit = require('hermit');
, html = '';Hello from Hermit
A little paragraph for you
, myStylesheet = require('./path/to/my/stylesheet.js');hermit(html, { listIndent: ' ', listStyle: '* ', stylesheet: myStylesheet }, function (err, res) {
console.log(res);
});
```For more information a detailed example read this [hermit test](https://github.com/thlorenz/hermit/blob/master/test/hermit.js#L11-L51)