Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/max-mapper/commonjs-html-prettyprinter
easy HTML pretty printing in commonJS
https://github.com/max-mapper/commonjs-html-prettyprinter
Last synced: 26 days ago
JSON representation
easy HTML pretty printing in commonJS
- Host: GitHub
- URL: https://github.com/max-mapper/commonjs-html-prettyprinter
- Owner: max-mapper
- License: mit
- Created: 2011-09-10T22:12:13.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2021-08-06T19:09:16.000Z (over 3 years ago)
- Last Synced: 2024-04-10T01:41:39.319Z (7 months ago)
- Language: JavaScript
- Homepage: http://search.npmjs.org/#/html
- Size: 687 KB
- Stars: 76
- Watchers: 4
- Forks: 18
- Open Issues: 11
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# html prettyprinter
A node port of beautify-html.js by Nochum Sossonko which is based on jsbeautifier by Einar Lielmanis
## Installation
### from npm (node package manager)
``` bash
npm install html
```## Usage (command line)
```
echo "" | html
AwesomeComis awesome
```returns:
``` html
AwesomeCom
is awesome
`````html foo.html` will write the prettified version to `stdout`.
`html *.html` will *update in place* all matching html files with their prettified versions.
## Advanced usage
I find myself constantly using the 'Copy as HTML' feature of the Chrome Inspector:
![Copy as HTML](https://github.com/maxogden/commonjs-html-prettyprinter/raw/master/img/copyashtml.png)
The downside is that that usually the HTML that gets copied is pretty ugly:
![Before pretty printing](https://github.com/maxogden/commonjs-html-prettyprinter/raw/master/img/before.png)
On OS X you can use `pbpaste` and `pbcopy` to stream your clipboard in and out of unix pipes. With the ugly HTML still in your clipboard run this command:
`pbpaste | html | pbcopy`
Now when you paste your clipboard into an editor you will get nice, pretty printed HTML:
![After pretty printing](https://github.com/maxogden/commonjs-html-prettyprinter/raw/master/img/after.png)
## Upgrading
grab the newest `beautify-html.js` from [js-beautifier](https://github.com/einars/js-beautify) and drop it into `lib/` as `html.js`. then add the following code to the bottom of `html.js`:
```javascript
module.exports = { prettyPrint: style_html }
```BSD LICENSE