html-to-text
Advanced tools
Comparing version
# Changelog | ||
## Version 9.0.4 | ||
* fixed: `dataTable` formatter was missing some existing cells in incompletely defined tables: [#282](https://github.com/html-to-text/node-html-to-text/issues/282); | ||
* updated readme a bit to clarify the usage: [#281](https://github.com/html-to-text/node-html-to-text/issues/281). | ||
All commits: [9.0.3...9.0.4](https://github.com/html-to-text/node-html-to-text/compare/9.0.3...9.0.4) | ||
## Version 9.0.3 | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "html-to-text", | ||
"version": "9.0.3", | ||
"version": "9.0.4", | ||
"description": "Advanced html to plain text converter", | ||
@@ -52,3 +52,3 @@ "keywords": [ | ||
"@selderee/plugin-htmlparser2": "^0.10.0", | ||
"deepmerge": "^4.2.2", | ||
"deepmerge": "^4.3.0", | ||
"dom-serializer": "^2.0.0", | ||
@@ -55,0 +55,0 @@ "htmlparser2": "^8.0.1", |
@@ -46,10 +46,12 @@ # html-to-text | ||
const html = '<h1>Hello World</h1>'; | ||
const text = convert(html, { | ||
wordwrap: 130 | ||
}); | ||
const options = { | ||
wordwrap: 130, | ||
// ... | ||
}; | ||
const html = '<div>Hello World</div>'; | ||
const text = convert(html, options); | ||
console.log(text); // Hello World | ||
``` | ||
Configure `html-to-text` once for batch processing (recommended for good performance): | ||
Configure `html-to-text` once to convert many documents with the same options (recommended for [good performance](https://github.com/html-to-text/node-html-to-text/issues/265#issuecomment-1337470852) when processing big batches of documents): | ||
@@ -59,18 +61,22 @@ ```js | ||
const convert = compile({ | ||
wordwrap: 130 | ||
}); | ||
const options = { | ||
wordwrap: 130, | ||
// ... | ||
}; | ||
const compiledConvert = compile(options); // options passed here | ||
const htmls = [ | ||
'<h1>Hello World!</h1>', | ||
'<h1>こんにちは世界!</h1>', | ||
'<h1>Привет, мир!</h1>' | ||
'<div>Hello World!</div>', | ||
'<div>こんにちは世界!</div>', | ||
'<div>Привіт Світ!</div>' | ||
]; | ||
const texts = htmls.map(convert); | ||
const texts = htmls.map(compiledConvert); | ||
console.log(texts.join('\n')); | ||
// Hello World! | ||
// こんにちは世界! | ||
// Привет, мир! | ||
// Привіт Світ! | ||
``` | ||
Both `convert` and `compiledConvert` can take one more optional argument - [metadata object](#custom-metadata) that can be used by formatters. | ||
### Options | ||
@@ -77,0 +83,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
173613
1.1%3876
0.83%362
1.69%Updated