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
var text =htmlToText.fromString('<h1>Hello World</h1>', {
49
-
wordwrap:130
49
+
wordwrap:130
50
50
});
51
51
console.log(text);
52
52
```
@@ -72,23 +72,24 @@ You can configure the behaviour of html-to-text with the following options:
72
72
*`wrapCharacters` is an array containing the characters that may be wrapped on, these are used in order
73
73
*`forceWrapOnLimit` defines whether to break long words on the limit if `true`.
74
74
*`format` pass an object to enable custom formatting for specific elements (see below)
75
+
*`unorderedListItemPrefix` defines the string that is used as item prefix for unordered lists `<ol>`. Default: `' * '`
75
76
76
77
### Override formatting for specific elements
77
78
78
79
By using the `format` option, you can specify formatting for these elements: `text`, `image`, `lineBreak`, `paragraph`, `anchor`, `heading`, `table`, `orderedList`, `unorderedList`, `listItem`, `horizontalLine`.
79
80
80
-
Each key must be a function which eventually receive `node` (the current node), `fn` (the next formatting function) and `options` (the options passed to html-to-text).
81
+
Each key must be a function which eventually receive `elem` (the current elem), `fn` (the next formatting function) and `options` (the options passed to html-to-text).
81
82
82
83
```js
83
84
var htmlToText =require('html-to-text');
84
85
85
86
var text =htmlToText.fromString('<h1>Hello World</h1>', {
86
-
format: {
87
-
heading:function (elem, fn, options) {
88
-
var h =fn(elem.children, options);
89
-
return'====\n'+h.toUpperCase() +'\n====';
90
-
}
91
-
}
87
+
format: {
88
+
heading:function (elem, fn, options) {
89
+
var h =fn(elem.children, options);
90
+
return'====\n'+h.toUpperCase() +'\n====';
91
+
}
92
+
}
92
93
});
93
94
94
95
console.log(text);
@@ -116,133 +117,133 @@ The `tables` option has to be declared as comma separated list without whitespac
116
117
117
118
```html
118
119
<html>
119
-
<head>
120
-
<metacharset="utf-8">
121
-
</head>
122
-
123
-
<body>
124
-
<tablecellpadding="0"cellspacing="0"border="0">
125
-
<tr>
126
-
<td>
127
-
<h2>Paragraphs</h2>
128
-
<pclass="normal-space">At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. <ahref="www.github.com">Github</a>
129
-
</p>
130
-
<pclass="normal-space">At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
<pclass="normal-space">At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. <ahref="www.github.com">Github</a>
130
+
</p>
131
+
<pclass="normal-space">At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
0 commit comments