├── .editorconfig ├── .gitignore ├── .jshintignore ├── .jshintrc ├── .travis.yml ├── README.md ├── cli ├── index.js ├── package.json └── test ├── fixture ├── expected-output.txt └── npm-chalk.html ├── index.js └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | node_modules 4 | npm-debug.log 5 | coverage 6 | -------------------------------------------------------------------------------- /.jshintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "newcap": true, 5 | "noarg": true, 6 | "noempty": true, 7 | "nonew": true, 8 | "sub": true, 9 | "validthis": true, 10 | "undef": true, 11 | "trailing": true, 12 | "boss": true, 13 | "eqnull": true, 14 | "strict": true, 15 | "immed": true, 16 | "expr": true, 17 | "latedef": "nofunc", 18 | "quotmark": "single", 19 | "indent": 2, 20 | "node": true 21 | } 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | sudo: false 3 | 4 | node_js: 5 | - '4' 6 | - '5' 7 | 8 | after_script: 9 | - npm run coverage 10 | - npm run publish-coverage 11 | 12 | cache: 13 | directories: 14 | - node_modules 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hget 2 | 3 | > **Render websites in plain text from your terminal** 4 | 5 | A CLI and an API to convert HTML into plain text. Can be used to fetch a site's HTML version and convert it into plain text, or to deliver plain text versions of your site dynamically. 6 | 7 | You can also convert HTML into HTML, ignoring certain document elements, and starting at a root element other than ``. You can choose to take raw Markdown output as well, instead of the default terminal-formatted plain text. 8 | 9 | # Install 10 | 11 | Globally or locally. 12 | 13 | ```shell 14 | npm install hget --save 15 | ``` 16 | 17 | ```shell 18 | npm install hget -g 19 | ``` 20 | 21 | # API 22 | 23 | The API exports a function that takes in HTML and returns a formatted plain text string. It uses colors and formatting provided by [`chalk`][1]. 24 | 25 | ```js 26 | var hget = require('hget'); 27 | var html = '

Hello Nico!

'; 28 | 29 | hget(html); 30 | // <- 'Hello Nico!' 31 | ``` 32 | 33 | You can also pass in a few options. 34 | 35 | ## `hget(html, options)` 36 | 37 | The options are as follows. 38 | 39 | - `root` sets the context root, it defaults to `'body'`. Maybe you want to use `'main'` or something akin to that. 40 | - `ignore` can be a single selector or an array of selectors. Any elements that match the provided selectors will be removed from the document before rendering the terminal-printable output. Keep in mind that these selectors will be rooted in the `root` element. 41 | - `html` means that you'll get HTML back, instead of the default human-readable terminal output 42 | - `markdown` means you'll get Markdown back, instead of the default human-readable terminal output 43 | 44 | # CLI 45 | 46 | Easy and flexible to use! 47 | 48 | ```shell 49 | hget ponyfoo.com 50 | ``` 51 | 52 | ```shell 53 | hget file.html 54 | ``` 55 | 56 | ```shell 57 | cat file.html | hget 58 | ``` 59 | 60 | # Example usage 61 | 62 | Ooh, the CLI also follows redirects. 63 | 64 | ``` 65 | hget ponyfoo.com/articles/last --root article --ignore footer,.mm-count,.at-meta 66 | ``` 67 | 68 | Also, the output will be paged using `$PAGER` for convenience. You can turn this off using `--no-paging`. 69 | 70 | It works well on most sites. Here's just the news links from EchoJS. 71 | 72 | ```shell 73 | hget echojs.com --root #newslist --ignore "article>:not(h2)" 74 | ``` 75 | 76 | ![echojs-output.png][2] 77 | 78 | # License 79 | 80 | MIT 81 | 82 | [1]: https://www.npmjs.org/package/chalk 83 | [2]: http://i.imgur.com/SlwwrqL.png 84 | 85 | [npm-badge]: https://img.shields.io/npm/v/hget.svg 86 | [npm-url]: https://npmjs.com/package/hget 87 | [travis-badge]: https://api.travis-ci.org/bevacqua/hget.svg 88 | [travis-url]: https://travis-ci.org/bevacqua/hget 89 | [coverage-badge]: https://coveralls.io/repos/bevacqua/hget/badge.svg?branch=master&service=github 90 | [coverage-url]: https://coveralls.io/github/bevacqua/hget?branch=master 91 | [david-badge]: https://david-dm.org/bevacqua/hget.svg 92 | [david-url]: https://david-dm.org/bevacqua/hget 93 | -------------------------------------------------------------------------------- /cli: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 'use strict'; 4 | 5 | var fs = require('fs'); 6 | var request = require('request'); 7 | var is = require('type-is'); 8 | var stdin = require('get-stdin'); 9 | var pager = require('default-pager'); 10 | var argv = require('minimist')(process.argv.slice(2), { 11 | alias: { 12 | root: 'r', 13 | ignore: 'i', 14 | paging: 'p', 15 | html: 'h', 16 | markdown: ['md', 'm'] 17 | } 18 | }); 19 | var hget = require('./'); 20 | var resource = argv._[0]; 21 | var parsed; 22 | 23 | if (process.stdin.isTTY) { 24 | fetch(); 25 | } else { 26 | stdin(parse); 27 | } 28 | 29 | function fetch () { 30 | if (fs.existsSync(resource)) { 31 | parse(read(resource)); 32 | } else { 33 | request(normalize(resource), response); 34 | } 35 | } 36 | 37 | function parse (data) { 38 | if (parsed) { 39 | return; 40 | } 41 | parsed = true; 42 | print(hget(data, argv)); 43 | } 44 | 45 | function read (file) { 46 | return fs.readFileSync(file, 'utf8'); 47 | } 48 | 49 | function normalize (url) { 50 | var rurl = /^https?:\/\//i; 51 | if (rurl.test(url) === false) { 52 | return 'http://' + url; 53 | } else { 54 | return url; 55 | } 56 | } 57 | 58 | function response (err, res, body) { 59 | if (err) { 60 | throw err; 61 | } 62 | if (is(res, ['html']) === false) { 63 | throw new Error('Response Content-Type is not HTML.'); 64 | } 65 | parse(typeof body === 'string' ? body : ''); 66 | } 67 | 68 | function print (result) { 69 | if (argv.paging === false || !process.stdin.isTTY) { 70 | console.log(result); 71 | } else { 72 | paged(result); 73 | } 74 | } 75 | 76 | function paged (result) { 77 | var pages = pager(); 78 | pages.write(result); 79 | pages.end(); 80 | } 81 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var stripColorCodes = require('stripcolorcodes'); 4 | var ultramarked = require('ultramarked'); 5 | var cheerio = require('cheerio'); 6 | var htmlmd = require('html-md-2'); 7 | var he = require('he'); 8 | 9 | function filterInput (input, options) { 10 | if (!options.ignore && !options.root) { 11 | return input; 12 | } 13 | var $ = cheerio.load(input); 14 | var ignored; 15 | var ignores = options.ignore; 16 | var rooted = $; 17 | var root = options.root; 18 | if (root) { 19 | rooted = rooted(root).eq(0); 20 | } 21 | if (ignores) { 22 | ignored = Array.isArray(ignores) ? ignores.join(',') : ignores; 23 | rooted.find(ignored).remove(); 24 | } 25 | var html = rooted.html(); 26 | return html; 27 | } 28 | 29 | function parse (input, options) { 30 | var o = options || {}; 31 | if (!o.root) { o.root = 'body,*'; } 32 | var html = filterInput(input, o); 33 | if (o.html) { 34 | return sanitize(html); 35 | } 36 | var md = htmlmd(html); 37 | if (o.markdown) { 38 | return sanitize(md); 39 | } 40 | var term = ultramarked(md, { terminal: true }); 41 | var stripped = stripColorCodes(term); 42 | var sanitized = sanitize(stripped); 43 | return sanitized; 44 | } 45 | 46 | function sanitize (input) { 47 | var decoded = he.decode(input); 48 | var trimmed = decoded.trim(); 49 | return trimmed; 50 | } 51 | 52 | module.exports = parse; 53 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hget", 3 | "description": "Render websites in plain text from your terminal", 4 | "version": "3.1.0", 5 | "homepage": "https://github.com/bevacqua/hget", 6 | "authors": [ 7 | "Nicolas Bevacqua " 8 | ], 9 | "license": "MIT", 10 | "repository": { 11 | "type": "git", 12 | "url": "git://github.com/bevacqua/hget.git" 13 | }, 14 | "bugs": { 15 | "url": "https://github.com/bevacqua/hget/issues" 16 | }, 17 | "bin": { 18 | "hget": "./cli" 19 | }, 20 | "scripts": { 21 | "test": "lab -P test -v", 22 | "coverage": "lab -P test -r lcov -o coverage/lcov.info -r html -o coverage/index.html", 23 | "publish-coverage": "coveralls < coverage/lcov.info" 24 | }, 25 | "engines": { 26 | "node": ">=4.0.0" 27 | }, 28 | "dependencies": { 29 | "cheerio": "^0.22.0", 30 | "default-pager": "^1.1.0", 31 | "get-stdin": "^5.0.1", 32 | "he": "^1.1.0", 33 | "html-md-2": "3.0.0", 34 | "minimist": "^1.2.0", 35 | "request": "^2.79.0", 36 | "stripcolorcodes": "^0.1.0", 37 | "type-is": "^1.6.14", 38 | "ultramarked": "^1.7.0" 39 | }, 40 | "devDependencies": { 41 | "code": "^4.0.0", 42 | "coveralls": "^2.11.15", 43 | "lab": "^11.2.2" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/fixture/expected-output.txt: -------------------------------------------------------------------------------- 1 | * Home (/) 2 | * API (http://npmjs.org/doc/) 3 | * Blog (http://blog.npmjs.org/) 4 | * Node.js (http://nodejs.org/) 5 | * Jobs (http://www.npmjs.com/jobs/) 6 | * Who's Hiring (/whoshiring) 7 | * Jut (http://www.jut.io/) 8 | * + 14 More... (/whoshiring) 9 | * npm Enterprise (/enterprise) 10 | * Try the on-premises solution for private npm. (/enterprise) 11 | 12 | 13 | 14 | (https://secure.gravatar.com/avatar/550d0153dbeee2fcaede98f906e55d02?s=100&d=retro) 15 | Nicolas Bevacqua (/profile) 16 | 17 | Edit Profile (/profile-edit) | Log out (/logout) 18 | 19 | [npm (/static/img/npm.png) 20 | 21 | ]0 (/) 22 | 23 | chalk 24 | 25 | click here to star/unstar this package 26 | 27 | Terminal string styling done right. Created because the `colors` 28 | module does some really horrible things. 29 | 30 | npm install chalk 31 | 32 | Oct 12Oct 19Oct 26Nov 02 33 | 34 | 126416 downloads yesterday Last Published By 35 | 36 | 37 | (https://secure.gravatar.com/avatar/87ae21ae50695ae9e522e7a41d480b30?s=50&d=retro) 38 | jbnicolai (/~jbnicolai) 39 | 40 | Maintainers 41 | 42 | 43 | (https://secure.gravatar.com/avatar/d36a92237c75c5337c17b60d90686bf9?s=50&d=retro) 44 | sindresorhus (/~sindresorhus) 45 | 46 | 47 | (https://secure.gravatar.com/avatar/87ae21ae50695ae9e522e7a41d480b30?s=50&d=retro) 48 | jbnicolai (/~jbnicolai) 49 | 50 | Version 0.5.1 last updated 4 months ago 51 | 52 | License MIT (http://opensource.org/licenses/MIT) 53 | 54 | Keywords color (/browse/keyword/color), colour 55 | (/browse/keyword/colour), colors (/browse/keyword/colors), terminal 56 | (/browse/keyword/terminal), console (/browse/keyword/console), cli 57 | (/browse/keyword/cli), string (/browse/keyword/string), ansi 58 | (/browse/keyword/ansi), styles (/browse/keyword/styles), tty 59 | (/browse/keyword/tty), formatting (/browse/keyword/formatting), rgb 60 | (/browse/keyword/rgb), 256 (/browse/keyword/256), shell 61 | (/browse/keyword/shell), xterm (/browse/keyword/xterm), log 62 | (/browse/keyword/log), logging (/browse/keyword/logging), 63 | command-line (/browse/keyword/command-line), text 64 | (/browse/keyword/text) 65 | 66 | Repository git://github.com/sindresorhus/chalk 67 | (https://github.com/sindresorhus/chalk) (git) 68 | 69 | Homepage https://github.com/sindresorhus/chalk 70 | 71 | Bugs https://github.com/sindresorhus/chalk/issues 72 | 73 | Dependencies ansi-styles (/package/ansi-styles), escape-string-regexp 74 | (/package/escape-string-regexp), has-ansi (/package/has-ansi), 75 | strip-ansi (/package/strip-ansi), supports-color 76 | (/package/supports-color) 77 | 78 | Dependents (1000) generator-evolve (/package/generator-evolve), 79 | cha-cli (/package/cha-cli), generator-langular 80 | (/package/generator-langular), generator-hexo-theme 81 | (/package/generator-hexo-theme), generator-angular-require 82 | (/package/generator-angular-require), build-friend 83 | (/package/build-friend), generator-italystrap 84 | (/package/generator-italystrap), generator-fabricator 85 | (/package/generator-fabricator), generator-pioneerapp 86 | (/package/generator-pioneerapp), generator-mangular 87 | (/package/generator-mangular), generator-meanp-modules 88 | (/package/generator-meanp-modules), assemble-yaml 89 | (/package/assemble-yaml), generator-grunt-maven 90 | (/package/generator-grunt-maven), generator-rwdmail 91 | (/package/generator-rwdmail), connect-resource-pipeline 92 | (/package/connect-resource-pipeline), generator-noyobo 93 | (/package/generator-noyobo), generator-config 94 | (/package/generator-config), generator-gulp-webapp 95 | (/package/generator-gulp-webapp), divshot-cli (/package/divshot-cli), 96 | conventional (/package/conventional), and 980 more 97 | (/browse/depended/chalk) 98 | 99 | Starred by (82) shidhincr (/~shidhincr), tunnckocore (/~tunnckocore), 100 | tengisb (/~tengisb), mohsen (/~mohsen), inderdeep (/~inderdeep), 101 | jclem (/~jclem), oakley349 (/~oakley349), jimnox (/~jimnox), tcauduro 102 | (/~tcauduro), kmck (/~kmck), ali1k (/~ali1k), humantriangle 103 | (/~humantriangle), rickbergfalk (/~rickbergfalk), zlatip (/~zlatip), 104 | jits (/~jits), bcoe (/~bcoe), ivangaravito (/~ivangaravito), 105 | brianchung808 (/~brianchung808), toddtreece (/~toddtreece), jbnicolai 106 | (/~jbnicolai) and 62 more (/browse/star/chalk) 107 | 108 | * Read Me 109 | 110 | 111 | chalk 112 | (https://cdn.rawgit.com/sindresorhus/chalk/77ae94f63ab1ac61389b190e5a59866569d1a376/logo.svg) 113 | 114 | Terminal string styling done right 115 | 116 | Build Status 117 | (https://travis-ci.org/sindresorhus/chalk.svg?branch=master) 118 | (https://travis-ci.org/sindresorhus/chalk) 119 | (http://img.shields.io/badge/unicorn-approved-ff69b4.svg) 120 | 121 | colors.js (https://github.com/Marak/colors.js) is currently the most 122 | popular string styling module, but it has serious deficiencies like 123 | extending String.prototype which causes all kinds of problems 124 | (https://github.com/yeoman/yo/issues/68). Although there are other 125 | ones, they either do too much or not enough. 126 | 127 | Chalk is a clean and focused alternative. 128 | 129 | screenshot 130 | (https://github.com/sindresorhus/ansi-styles/raw/master/screenshot.png) 131 | 132 | Why 133 | 134 | * Highly performant 135 | * Doesn't extend String.prototype 136 | * Expressive API 137 | * Ability to nest styles 138 | * Clean and focused 139 | * Auto-detects color support 140 | * Actively maintained 141 | * Used by 1000+ modules (https://npmjs.org/browse/depended/chalk) 142 | 143 | 144 | Install 145 | 146 | $ npm install --save chalk 147 | 148 | Usage 149 | 150 | Chalk comes with an easy to use composable API where you just chain 151 | and nest the styles you want. 152 | 153 | var chalk = require('chalk'); 154 | 155 | // style a string 156 | console.log( chalk.blue('Hello world!') ); 157 | 158 | // combine styled and normal strings 159 | console.log( chalk.blue('Hello'), 'World' + chalk.red('!') ); 160 | 161 | // compose multiple styles using the chainable API 162 | console.log( chalk.blue.bgRed.bold('Hello world!') ); 163 | 164 | // pass in multiple arguments 165 | console.log( chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 166 | 'baz') ); 167 | 168 | // nest styles 169 | console.log( chalk.red('Hello', chalk.underline.bgBlue('world') + 170 | '!') ); 171 | 172 | // nest styles of the same type even (color, underline, 173 | background) 174 | console.log( chalk.green('I am a green line ' + chalk.blue('with 175 | a blue substring') + ' that becomes green again!') ); 176 | 177 | Easily define your own themes. 178 | 179 | var chalk = require('chalk'); 180 | var error = chalk.bold.red; 181 | console.log(error('Error!')); 182 | 183 | Take advantage of console.log string substitution 184 | (http://nodejs.org/docs/latest/api/console.html#console_console_log_data). 185 | 186 | var name = 'Sindre'; 187 | console.log(chalk.green('Hello %s'), name); 188 | //=> Hello Sindre 189 | 190 | API 191 | 192 | chalk. 14 |
15 | 59 | 60 | 76 | 77 | 78 |
79 |
80 |
81 | 86 |
87 |

88 | 91 |

92 |
93 | 94 | 95 |
96 |
97 |

chalk

98 | 99 | 100 |
101 | 102 | 103 | 104 | 105 |

Terminal string styling done right. Created because the `colors` module does some really horrible things.

106 | 107 | 108 |
npm install chalk
109 | 110 | 111 | 112 | 113 |
114 |
115 |
Oct 12Oct 19Oct 26Nov 02
116 |
117 | 118 |
126416 downloads yesterday
119 |
120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 135 | 136 | 137 | 138 | 139 | 140 | 153 | 154 | 155 | 156 | 157 | 166 | 167 | 168 | 169 | 170 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 189 | 190 | 191 | 192 | 193 | 194 | 197 | 198 | 199 | 200 | 201 | 202 | 205 | 206 | 207 | 208 | 209 | 210 | 218 | 219 | 220 | 221 | 222 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 235 | 236 | 237 | 238 | 239 |
240 | 245 | 246 | 247 |
248 |

chalk

249 |
250 |

Terminal string styling done right

251 |
252 |

Build Status 253 |

254 |

colors.js is currently the most popular string styling module, but it has serious deficiencies like extending String.prototype which causes all kinds of problems. Although there are other ones, they either do too much or not enough.

255 |

Chalk is a clean and focused alternative.

256 |

screenshot

257 |

Why

258 |
    259 |
  • Highly performant
  • 260 |
  • Doesn't extend String.prototype
  • 261 |
  • Expressive API
  • 262 |
  • Ability to nest styles
  • 263 |
  • Clean and focused
  • 264 |
  • Auto-detects color support
  • 265 |
  • Actively maintained
  • 266 |
  • Used by 1000+ modules
  • 267 |
268 |

Install

269 |
$ npm install --save chalk
270 | 
271 |

Usage

272 |

Chalk comes with an easy to use composable API where you just chain and nest the styles you want.

273 |
var chalk = require('chalk');
274 | 
275 | // style a string
276 | console.log(  chalk.blue('Hello world!')  );
277 | 
278 | // combine styled and normal strings
279 | console.log(  chalk.blue('Hello'), 'World' + chalk.red('!')  );
280 | 
281 | // compose multiple styles using the chainable API
282 | console.log(  chalk.blue.bgRed.bold('Hello world!')  );
283 | 
284 | // pass in multiple arguments
285 | console.log(  chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz')  );
286 | 
287 | // nest styles
288 | console.log(  chalk.red('Hello', chalk.underline.bgBlue('world') + '!')  );
289 | 
290 | // nest styles of the same type even (color, underline, background)
291 | console.log(  chalk.green('I am a green line ' + chalk.blue('with a blue substring') + ' that becomes green again!')  );
292 | 
293 |

Easily define your own themes.

294 |
var chalk = require('chalk');
295 | var error = chalk.bold.red;
296 | console.log(error('Error!'));
297 | 
298 |

Take advantage of console.log string substitution.

299 |
var name = 'Sindre';
300 | console.log(chalk.green('Hello %s'), name);
301 | //=> Hello Sindre
302 | 
303 |

API

304 |

chalk.<style>[.<style>...](string, [string...])

305 |

Example: chalk.red.bold.underline('Hello', 'world');

306 |

Chain styles and call the last one as a method with a string argument. Order doesn't matter.

307 |

Multiple arguments will be separated by space.

308 |

chalk.enabled

309 |

Color support is automatically detected, but you can override it.

310 |

chalk.supportsColor

311 |

Detect whether the terminal supports color.

312 |

Can be overridden by the user with the flags --color and --no-color.

313 |

Used internally and handled for you, but exposed for convenience.

314 |

chalk.styles

315 |

Exposes the styles as ANSI escape codes.

316 |

Generally not useful, but you might need just the .open or .close escape code if you're mixing externally styled strings with yours.

317 |
var chalk = require('chalk');
318 | 
319 | console.log(chalk.styles.red);
320 | //=> {open: '\u001b[31m', close: '\u001b[39m'}
321 | 
322 | console.log(chalk.styles.red.open + 'Hello' + chalk.styles.red.close);
323 | 
324 |

chalk.hasColor(string)

325 |

Check whether a string has color.

326 |

chalk.stripColor(string)

327 |

Strip color from a string.

328 |

Can be useful in combination with .supportsColor to strip color on externally styled text when it's not supported.

329 |

Example:

330 |
var chalk = require('chalk');
331 | var styledString = getText();
332 | 
333 | if (!chalk.supportsColor) {
334 |     styledString = chalk.stripColor(styledString);
335 | }
336 | 
337 |

Styles

338 |

General

339 |
    340 |
  • reset
  • 341 |
  • bold
  • 342 |
  • dim
  • 343 |
  • italic (not widely supported)
  • 344 |
  • underline
  • 345 |
  • inverse
  • 346 |
  • hidden
  • 347 |
  • strikethrough (not widely supported)
  • 348 |
349 |

Text colors

350 |
    351 |
  • black
  • 352 |
  • red
  • 353 |
  • green
  • 354 |
  • yellow
  • 355 |
  • blue
  • 356 |
  • magenta
  • 357 |
  • cyan
  • 358 |
  • white
  • 359 |
  • gray
  • 360 |
361 |

Background colors

362 |
    363 |
  • bgBlack
  • 364 |
  • bgRed
  • 365 |
  • bgGreen
  • 366 |
  • bgYellow
  • 367 |
  • bgBlue
  • 368 |
  • bgMagenta
  • 369 |
  • bgCyan
  • 370 |
  • bgWhite
  • 371 |
372 |

License

373 |

MIT © Sindre Sorhus

374 | 375 |
376 | 377 |
378 |
379 | 380 |
381 |
382 | 383 | 396 | 397 | npm loves you 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var htmlterminal = require('..'); 3 | var html = htmlterminal(fs.readFileSync(__dirname + '/fixture/npm-chalk.html', 'utf8'), {}); 4 | 5 | console.log(html); 6 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | var Lab = require('lab'); 2 | var Code = require('code'); 3 | 4 | var lab = exports.lab = Lab.script(); 5 | var describe = lab.describe; 6 | var it = lab.it; 7 | var expect = Code.expect; 8 | 9 | var fs = require('fs'); 10 | var hget = require('..'); 11 | 12 | describe('hget', function () { 13 | it('work has expected', function (done) { 14 | 15 | var html = hget(fs.readFileSync(__dirname + '/fixture/npm-chalk.html', 'utf8'), {}); 16 | 17 | var output = fs.readFileSync(__dirname + '/fixture/expected-output.txt', 'utf8') 18 | 19 | expect(html.replace(/\s+/g, ' ') + ' ').to.equal(output.replace(/\s+/g, ' ')) 20 | done() 21 | }); 22 | 23 | }); 24 | --------------------------------------------------------------------------------