You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/html-to-text/README.md
+20-1Lines changed: 20 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ const text = convert(html, {
50
50
console.log(text); // Hello World
51
51
```
52
52
53
-
Configure `html-to-text` once for batch processing:
53
+
Configure `html-to-text` once for batch processing (recommended for good performance):
54
54
55
55
```js
56
56
const { compile } =require('html-to-text');
@@ -291,6 +291,25 @@ Refer to [generic formatters](https://github.com/html-to-text/node-html-to-text/
291
291
292
292
Refer to [BlockTextBuilder](https://github.com/html-to-text/node-html-to-text/blob/master/packages/base/src/block-text-builder.js) for available functions and arguments.
293
293
294
+
#### Custom metadata
295
+
296
+
If you need to supply extra information about your HTML documents to use in custom formatters - it can be done with the help of metadata object.
297
+
298
+
It is supplied as an extra argument to the convert function:
299
+
300
+
```javascript
301
+
import { compile, convert } from'html-to-text';
302
+
303
+
// for batch use:
304
+
constcompiledConvert=compile(options);
305
+
let text =compiledConvert(html, metadata);
306
+
307
+
// for single use:
308
+
let text =convert(html, options, metadata);
309
+
```
310
+
311
+
And it can be accessed within formatter functions as `builder.metadata`.
312
+
294
313
#### Call other formatters from a custom formatter
295
314
296
315
Most of the times this is *not* what you actually need. Most practical problems can be solved with [selectors](#selectors).
0 commit comments