Skip to content

Commit 37f5f1c

Browse files
author
Malte Legenhausen
committed
Fixed setEncoding call of stdout. README updated
1 parent 61906dd commit 37f5f1c

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ A simple converter that parses HTML and returns beautiful text. It was mainly de
1616
npm install html-to-text
1717
```
1818

19+
Or when you want to use it as command line interface it is recommended to install it globally via
20+
21+
```
22+
npm install html-to-text -g
23+
```
24+
1925
## Usage
2026
You can read from a file via:
2127

@@ -55,13 +61,13 @@ It is possible to use html-to-text as command line interface. This allows an eas
5561
`html-to-text` uses `stdin` and `stdout` for data in and output. So you can use `html-to-html` the following way:
5662

5763
```
58-
cat examples/test.html | html-to-text > test.txt
64+
cat example/test.html | html-to-text > test.txt
5965
```
6066

6167
There also all options available as described above. You can use them like this:
6268

6369
```
64-
cat examples/test.html | html-to-text --tables=#invoice,.address --wordwrap=100 > test.txt
70+
cat example/test.html | html-to-text --tables=#invoice,.address --wordwrap=100 > test.txt
6571
```
6672

6773
The `tables` option has to be declared as comma separated list without whitespaces.

bin/cli.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ process.stdin.on('data', function data(data) {
1414
text += data;
1515
});
1616

17-
process.stdout.setEncoding('utf8');
1817
process.stdin.on('end', function end() {
1918
text = htmlToText.fromString(text, {
2019
tables: argv.tables.split(','),
2120
wordwrap: argv.wordwrap
2221
});
23-
process.stdout.write(text + '\n');
22+
process.stdout.write(text + '\n', 'utf-8');
2423
});

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "html-to-text",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "Simple html to plain text converter",
55
"main": "index.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
"converter"
2424
],
2525
"engines": {
26-
"node": "*"
26+
"node": "~0.8.0"
2727
},
2828
"bin": {
2929
"html-to-text": "./bin/cli.js"

0 commit comments

Comments
 (0)