@tryghost/mg-blogger 0.1.8 → 0.1.9
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/lib/process.js +16 -4
- package/package.json +4 -4
package/lib/process.js
CHANGED
|
@@ -48,7 +48,13 @@ const getAllAttributes = function (el) {
|
|
|
48
48
|
const handleFirstImage = (args) => {
|
|
49
49
|
let {postData, html} = args;
|
|
50
50
|
|
|
51
|
-
const $html = $.load(html);
|
|
51
|
+
// const $html = $.load(html);
|
|
52
|
+
|
|
53
|
+
const $html = $.load(html, {
|
|
54
|
+
decodeEntities: false,
|
|
55
|
+
scriptingEnabled: false
|
|
56
|
+
}, false); // This `false` is `isDocument`. If `true`, <html>, <head>, and <body> elements are introduced
|
|
57
|
+
|
|
52
58
|
const firstContentElement = $html('*').first();
|
|
53
59
|
|
|
54
60
|
if (firstContentElement[0].name === 'img') {
|
|
@@ -87,7 +93,10 @@ const processHTMLContent = async (args) => {
|
|
|
87
93
|
|
|
88
94
|
html = autop(html);
|
|
89
95
|
|
|
90
|
-
const $html = $.load(html
|
|
96
|
+
const $html = $.load(html, {
|
|
97
|
+
decodeEntities: false,
|
|
98
|
+
scriptingEnabled: false
|
|
99
|
+
}, false); // This `false` is `isDocument`. If `true`, <html>, <head>, and <body> elements are introduced
|
|
91
100
|
|
|
92
101
|
$html('div.separator').each((i, el) => {
|
|
93
102
|
$(el).replaceWith(`<hr><div>${$(el).html().trim()}</div>`);
|
|
@@ -183,7 +192,7 @@ const processHTMLContent = async (args) => {
|
|
|
183
192
|
$(el).replaceWith(`<p>${$(el).html().trim()}</p>`);
|
|
184
193
|
});
|
|
185
194
|
|
|
186
|
-
$html('div[style="
|
|
195
|
+
$html('div[style="text-align: center;"]').each((i, el) => {
|
|
187
196
|
$(el).replaceWith(`<p>${$(el).html().trim()}</p>`);
|
|
188
197
|
});
|
|
189
198
|
|
|
@@ -216,7 +225,7 @@ const processHTMLContent = async (args) => {
|
|
|
216
225
|
});
|
|
217
226
|
|
|
218
227
|
$html('p').each((i, el) => {
|
|
219
|
-
if ($(el).html().trim() === '' || $(el).html() === ' ') {
|
|
228
|
+
if ($(el).html().trim() === '' || $(el).html() === ' ' || $(el).html().trim() === ' ') {
|
|
220
229
|
$(el).remove();
|
|
221
230
|
}
|
|
222
231
|
});
|
|
@@ -244,6 +253,9 @@ const processHTMLContent = async (args) => {
|
|
|
244
253
|
// Remove first element(s) if <hr>
|
|
245
254
|
html = html.replace(/^(<hr\/?> ?)+/gm, '').trim();
|
|
246
255
|
|
|
256
|
+
// Remove empty attributes
|
|
257
|
+
html = html.replace(/=""/g, '');
|
|
258
|
+
|
|
247
259
|
postData.html = html;
|
|
248
260
|
|
|
249
261
|
if (options?.firstImageAsFeatured) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-blogger",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-blogger",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@tryghost/errors": "1.2.26",
|
|
28
|
-
"@tryghost/kg-default-cards": "9.1.
|
|
28
|
+
"@tryghost/kg-default-cards": "9.1.9",
|
|
29
29
|
"autop": "1.0.1",
|
|
30
|
-
"cheerio": "0.
|
|
30
|
+
"cheerio": "1.0.0-rc.12",
|
|
31
31
|
"node-fetch": "^3.3.1",
|
|
32
32
|
"sanitize-html": "2.11.0",
|
|
33
33
|
"simple-dom": "1.4.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "87eac9f1a90b9e8935ce70d9459db6f8ffec6133"
|
|
36
36
|
}
|