turndown 7.1.3 → 7.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/dist/turndown.js +6 -5
- package/lib/turndown.browser.cjs.js +6 -5
- package/lib/turndown.browser.es.js +6 -5
- package/lib/turndown.browser.umd.js +6 -5
- package/lib/turndown.cjs.js +7 -6
- package/lib/turndown.es.js +7 -6
- package/lib/turndown.umd.js +7 -6
- package/package.json +3 -3
package/README.md
CHANGED
package/dist/turndown.js
CHANGED
|
@@ -140,10 +140,6 @@ var TurndownService = (function () {
|
|
|
140
140
|
filter: 'li',
|
|
141
141
|
|
|
142
142
|
replacement: function (content, node, options) {
|
|
143
|
-
content = content
|
|
144
|
-
.replace(/^\n+/, '') // remove leading newlines
|
|
145
|
-
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
146
|
-
.replace(/\n/gm, '\n '); // indent
|
|
147
143
|
var prefix = options.bulletListMarker + ' ';
|
|
148
144
|
var parent = node.parentNode;
|
|
149
145
|
if (parent.nodeName === 'OL') {
|
|
@@ -151,6 +147,10 @@ var TurndownService = (function () {
|
|
|
151
147
|
var index = Array.prototype.indexOf.call(parent.children, node);
|
|
152
148
|
prefix = (start ? Number(start) + index : index + 1) + '. ';
|
|
153
149
|
}
|
|
150
|
+
content = content
|
|
151
|
+
.replace(/^\n+/, '') // remove leading newlines
|
|
152
|
+
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
153
|
+
.replace(/\n/gm, '\n' + ' '.repeat(prefix.length)); // indent
|
|
154
154
|
return (
|
|
155
155
|
prefix + content + (node.nextSibling && !/\n$/.test(content) ? '\n' : '')
|
|
156
156
|
)
|
|
@@ -231,8 +231,9 @@ var TurndownService = (function () {
|
|
|
231
231
|
|
|
232
232
|
replacement: function (content, node) {
|
|
233
233
|
var href = node.getAttribute('href');
|
|
234
|
+
if (href) href = href.replace(/([()])/g, '\\$1');
|
|
234
235
|
var title = cleanAttribute(node.getAttribute('title'));
|
|
235
|
-
if (title) title = ' "' + title + '"';
|
|
236
|
+
if (title) title = ' "' + title.replace(/"/g, '\\"') + '"';
|
|
236
237
|
return '[' + content + '](' + href + title + ')'
|
|
237
238
|
}
|
|
238
239
|
};
|
|
@@ -139,10 +139,6 @@ rules.listItem = {
|
|
|
139
139
|
filter: 'li',
|
|
140
140
|
|
|
141
141
|
replacement: function (content, node, options) {
|
|
142
|
-
content = content
|
|
143
|
-
.replace(/^\n+/, '') // remove leading newlines
|
|
144
|
-
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
145
|
-
.replace(/\n/gm, '\n '); // indent
|
|
146
142
|
var prefix = options.bulletListMarker + ' ';
|
|
147
143
|
var parent = node.parentNode;
|
|
148
144
|
if (parent.nodeName === 'OL') {
|
|
@@ -150,6 +146,10 @@ rules.listItem = {
|
|
|
150
146
|
var index = Array.prototype.indexOf.call(parent.children, node);
|
|
151
147
|
prefix = (start ? Number(start) + index : index + 1) + '. ';
|
|
152
148
|
}
|
|
149
|
+
content = content
|
|
150
|
+
.replace(/^\n+/, '') // remove leading newlines
|
|
151
|
+
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
152
|
+
.replace(/\n/gm, '\n' + ' '.repeat(prefix.length)); // indent
|
|
153
153
|
return (
|
|
154
154
|
prefix + content + (node.nextSibling && !/\n$/.test(content) ? '\n' : '')
|
|
155
155
|
)
|
|
@@ -230,8 +230,9 @@ rules.inlineLink = {
|
|
|
230
230
|
|
|
231
231
|
replacement: function (content, node) {
|
|
232
232
|
var href = node.getAttribute('href');
|
|
233
|
+
if (href) href = href.replace(/([()])/g, '\\$1');
|
|
233
234
|
var title = cleanAttribute(node.getAttribute('title'));
|
|
234
|
-
if (title) title = ' "' + title + '"';
|
|
235
|
+
if (title) title = ' "' + title.replace(/"/g, '\\"') + '"';
|
|
235
236
|
return '[' + content + '](' + href + title + ')'
|
|
236
237
|
}
|
|
237
238
|
};
|
|
@@ -137,10 +137,6 @@ rules.listItem = {
|
|
|
137
137
|
filter: 'li',
|
|
138
138
|
|
|
139
139
|
replacement: function (content, node, options) {
|
|
140
|
-
content = content
|
|
141
|
-
.replace(/^\n+/, '') // remove leading newlines
|
|
142
|
-
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
143
|
-
.replace(/\n/gm, '\n '); // indent
|
|
144
140
|
var prefix = options.bulletListMarker + ' ';
|
|
145
141
|
var parent = node.parentNode;
|
|
146
142
|
if (parent.nodeName === 'OL') {
|
|
@@ -148,6 +144,10 @@ rules.listItem = {
|
|
|
148
144
|
var index = Array.prototype.indexOf.call(parent.children, node);
|
|
149
145
|
prefix = (start ? Number(start) + index : index + 1) + '. ';
|
|
150
146
|
}
|
|
147
|
+
content = content
|
|
148
|
+
.replace(/^\n+/, '') // remove leading newlines
|
|
149
|
+
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
150
|
+
.replace(/\n/gm, '\n' + ' '.repeat(prefix.length)); // indent
|
|
151
151
|
return (
|
|
152
152
|
prefix + content + (node.nextSibling && !/\n$/.test(content) ? '\n' : '')
|
|
153
153
|
)
|
|
@@ -228,8 +228,9 @@ rules.inlineLink = {
|
|
|
228
228
|
|
|
229
229
|
replacement: function (content, node) {
|
|
230
230
|
var href = node.getAttribute('href');
|
|
231
|
+
if (href) href = href.replace(/([()])/g, '\\$1');
|
|
231
232
|
var title = cleanAttribute(node.getAttribute('title'));
|
|
232
|
-
if (title) title = ' "' + title + '"';
|
|
233
|
+
if (title) title = ' "' + title.replace(/"/g, '\\"') + '"';
|
|
233
234
|
return '[' + content + '](' + href + title + ')'
|
|
234
235
|
}
|
|
235
236
|
};
|
|
@@ -143,10 +143,6 @@
|
|
|
143
143
|
filter: 'li',
|
|
144
144
|
|
|
145
145
|
replacement: function (content, node, options) {
|
|
146
|
-
content = content
|
|
147
|
-
.replace(/^\n+/, '') // remove leading newlines
|
|
148
|
-
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
149
|
-
.replace(/\n/gm, '\n '); // indent
|
|
150
146
|
var prefix = options.bulletListMarker + ' ';
|
|
151
147
|
var parent = node.parentNode;
|
|
152
148
|
if (parent.nodeName === 'OL') {
|
|
@@ -154,6 +150,10 @@
|
|
|
154
150
|
var index = Array.prototype.indexOf.call(parent.children, node);
|
|
155
151
|
prefix = (start ? Number(start) + index : index + 1) + '. ';
|
|
156
152
|
}
|
|
153
|
+
content = content
|
|
154
|
+
.replace(/^\n+/, '') // remove leading newlines
|
|
155
|
+
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
156
|
+
.replace(/\n/gm, '\n' + ' '.repeat(prefix.length)); // indent
|
|
157
157
|
return (
|
|
158
158
|
prefix + content + (node.nextSibling && !/\n$/.test(content) ? '\n' : '')
|
|
159
159
|
)
|
|
@@ -234,8 +234,9 @@
|
|
|
234
234
|
|
|
235
235
|
replacement: function (content, node) {
|
|
236
236
|
var href = node.getAttribute('href');
|
|
237
|
+
if (href) href = href.replace(/([()])/g, '\\$1');
|
|
237
238
|
var title = cleanAttribute(node.getAttribute('title'));
|
|
238
|
-
if (title) title = ' "' + title + '"';
|
|
239
|
+
if (title) title = ' "' + title.replace(/"/g, '\\"') + '"';
|
|
239
240
|
return '[' + content + '](' + href + title + ')'
|
|
240
241
|
}
|
|
241
242
|
};
|
package/lib/turndown.cjs.js
CHANGED
|
@@ -139,10 +139,6 @@ rules.listItem = {
|
|
|
139
139
|
filter: 'li',
|
|
140
140
|
|
|
141
141
|
replacement: function (content, node, options) {
|
|
142
|
-
content = content
|
|
143
|
-
.replace(/^\n+/, '') // remove leading newlines
|
|
144
|
-
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
145
|
-
.replace(/\n/gm, '\n '); // indent
|
|
146
142
|
var prefix = options.bulletListMarker + ' ';
|
|
147
143
|
var parent = node.parentNode;
|
|
148
144
|
if (parent.nodeName === 'OL') {
|
|
@@ -150,6 +146,10 @@ rules.listItem = {
|
|
|
150
146
|
var index = Array.prototype.indexOf.call(parent.children, node);
|
|
151
147
|
prefix = (start ? Number(start) + index : index + 1) + '. ';
|
|
152
148
|
}
|
|
149
|
+
content = content
|
|
150
|
+
.replace(/^\n+/, '') // remove leading newlines
|
|
151
|
+
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
152
|
+
.replace(/\n/gm, '\n' + ' '.repeat(prefix.length)); // indent
|
|
153
153
|
return (
|
|
154
154
|
prefix + content + (node.nextSibling && !/\n$/.test(content) ? '\n' : '')
|
|
155
155
|
)
|
|
@@ -230,8 +230,9 @@ rules.inlineLink = {
|
|
|
230
230
|
|
|
231
231
|
replacement: function (content, node) {
|
|
232
232
|
var href = node.getAttribute('href');
|
|
233
|
+
if (href) href = href.replace(/([()])/g, '\\$1');
|
|
233
234
|
var title = cleanAttribute(node.getAttribute('title'));
|
|
234
|
-
if (title) title = ' "' + title + '"';
|
|
235
|
+
if (title) title = ' "' + title.replace(/"/g, '\\"') + '"';
|
|
235
236
|
return '[' + content + '](' + href + title + ')'
|
|
236
237
|
}
|
|
237
238
|
};
|
|
@@ -581,7 +582,7 @@ function createHTMLParser () {
|
|
|
581
582
|
var Parser = function () {};
|
|
582
583
|
|
|
583
584
|
{
|
|
584
|
-
var domino = require('domino');
|
|
585
|
+
var domino = require('@mixmark-io/domino');
|
|
585
586
|
Parser.prototype.parseFromString = function (string) {
|
|
586
587
|
return domino.createDocument(string)
|
|
587
588
|
};
|
package/lib/turndown.es.js
CHANGED
|
@@ -137,10 +137,6 @@ rules.listItem = {
|
|
|
137
137
|
filter: 'li',
|
|
138
138
|
|
|
139
139
|
replacement: function (content, node, options) {
|
|
140
|
-
content = content
|
|
141
|
-
.replace(/^\n+/, '') // remove leading newlines
|
|
142
|
-
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
143
|
-
.replace(/\n/gm, '\n '); // indent
|
|
144
140
|
var prefix = options.bulletListMarker + ' ';
|
|
145
141
|
var parent = node.parentNode;
|
|
146
142
|
if (parent.nodeName === 'OL') {
|
|
@@ -148,6 +144,10 @@ rules.listItem = {
|
|
|
148
144
|
var index = Array.prototype.indexOf.call(parent.children, node);
|
|
149
145
|
prefix = (start ? Number(start) + index : index + 1) + '. ';
|
|
150
146
|
}
|
|
147
|
+
content = content
|
|
148
|
+
.replace(/^\n+/, '') // remove leading newlines
|
|
149
|
+
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
150
|
+
.replace(/\n/gm, '\n' + ' '.repeat(prefix.length)); // indent
|
|
151
151
|
return (
|
|
152
152
|
prefix + content + (node.nextSibling && !/\n$/.test(content) ? '\n' : '')
|
|
153
153
|
)
|
|
@@ -228,8 +228,9 @@ rules.inlineLink = {
|
|
|
228
228
|
|
|
229
229
|
replacement: function (content, node) {
|
|
230
230
|
var href = node.getAttribute('href');
|
|
231
|
+
if (href) href = href.replace(/([()])/g, '\\$1');
|
|
231
232
|
var title = cleanAttribute(node.getAttribute('title'));
|
|
232
|
-
if (title) title = ' "' + title + '"';
|
|
233
|
+
if (title) title = ' "' + title.replace(/"/g, '\\"') + '"';
|
|
233
234
|
return '[' + content + '](' + href + title + ')'
|
|
234
235
|
}
|
|
235
236
|
};
|
|
@@ -579,7 +580,7 @@ function createHTMLParser () {
|
|
|
579
580
|
var Parser = function () {};
|
|
580
581
|
|
|
581
582
|
{
|
|
582
|
-
var domino = require('domino');
|
|
583
|
+
var domino = require('@mixmark-io/domino');
|
|
583
584
|
Parser.prototype.parseFromString = function (string) {
|
|
584
585
|
return domino.createDocument(string)
|
|
585
586
|
};
|
package/lib/turndown.umd.js
CHANGED
|
@@ -143,10 +143,6 @@
|
|
|
143
143
|
filter: 'li',
|
|
144
144
|
|
|
145
145
|
replacement: function (content, node, options) {
|
|
146
|
-
content = content
|
|
147
|
-
.replace(/^\n+/, '') // remove leading newlines
|
|
148
|
-
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
149
|
-
.replace(/\n/gm, '\n '); // indent
|
|
150
146
|
var prefix = options.bulletListMarker + ' ';
|
|
151
147
|
var parent = node.parentNode;
|
|
152
148
|
if (parent.nodeName === 'OL') {
|
|
@@ -154,6 +150,10 @@
|
|
|
154
150
|
var index = Array.prototype.indexOf.call(parent.children, node);
|
|
155
151
|
prefix = (start ? Number(start) + index : index + 1) + '. ';
|
|
156
152
|
}
|
|
153
|
+
content = content
|
|
154
|
+
.replace(/^\n+/, '') // remove leading newlines
|
|
155
|
+
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one
|
|
156
|
+
.replace(/\n/gm, '\n' + ' '.repeat(prefix.length)); // indent
|
|
157
157
|
return (
|
|
158
158
|
prefix + content + (node.nextSibling && !/\n$/.test(content) ? '\n' : '')
|
|
159
159
|
)
|
|
@@ -234,8 +234,9 @@
|
|
|
234
234
|
|
|
235
235
|
replacement: function (content, node) {
|
|
236
236
|
var href = node.getAttribute('href');
|
|
237
|
+
if (href) href = href.replace(/([()])/g, '\\$1');
|
|
237
238
|
var title = cleanAttribute(node.getAttribute('title'));
|
|
238
|
-
if (title) title = ' "' + title + '"';
|
|
239
|
+
if (title) title = ' "' + title.replace(/"/g, '\\"') + '"';
|
|
239
240
|
return '[' + content + '](' + href + title + ')'
|
|
240
241
|
}
|
|
241
242
|
};
|
|
@@ -585,7 +586,7 @@
|
|
|
585
586
|
var Parser = function () {};
|
|
586
587
|
|
|
587
588
|
{
|
|
588
|
-
var domino = require('domino');
|
|
589
|
+
var domino = require('@mixmark-io/domino');
|
|
589
590
|
Parser.prototype.parseFromString = function (string) {
|
|
590
591
|
return domino.createDocument(string)
|
|
591
592
|
};
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turndown",
|
|
3
3
|
"description": "A library that converts HTML to Markdown",
|
|
4
|
-
"version": "7.1
|
|
4
|
+
"version": "7.2.1",
|
|
5
5
|
"author": "Dom Christie",
|
|
6
6
|
"main": "lib/turndown.cjs.js",
|
|
7
7
|
"module": "lib/turndown.es.js",
|
|
8
8
|
"jsnext:main": "lib/turndown.es.js",
|
|
9
9
|
"browser": {
|
|
10
|
-
"domino": false,
|
|
10
|
+
"@mixmark-io/domino": false,
|
|
11
11
|
"./lib/turndown.cjs.js": "./lib/turndown.browser.cjs.js",
|
|
12
12
|
"./lib/turndown.es.js": "./lib/turndown.browser.es.js",
|
|
13
13
|
"./lib/turndown.umd.js": "./lib/turndown.browser.umd.js"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"domino": "^2.
|
|
16
|
+
"@mixmark-io/domino": "^2.2.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@rollup/plugin-commonjs": "^19.0.0",
|