@tryghost/mg-jekyll-export 0.3.38 → 0.3.40
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/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/process-html.js +13 -10
- package/package.json +5 -5
package/LICENSE
CHANGED
package/README.md
CHANGED
package/lib/process-html.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as cheerio from 'cheerio';
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
Process the HTML of a single Jekyll Post.
|
|
@@ -7,9 +7,12 @@ Receives raw HTML, returns processed HTML
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
export default (rawHtml, options = {}) => {
|
|
10
|
-
const $html =
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const $html = cheerio.load(rawHtml, {
|
|
11
|
+
xml: {
|
|
12
|
+
xmlMode: false,
|
|
13
|
+
decodeEntities: false,
|
|
14
|
+
scriptingEnabled: false
|
|
15
|
+
}
|
|
13
16
|
}, false); // This `false` is `isDocument`. If `true`, <html>, <head>, and <body> elements are introduced
|
|
14
17
|
|
|
15
18
|
// Convert relative links and image paths to absolute
|
|
@@ -21,32 +24,32 @@ export default (rawHtml, options = {}) => {
|
|
|
21
24
|
const urlOrigin = urlData.origin;
|
|
22
25
|
|
|
23
26
|
$html('a').each((i, anchor) => {
|
|
24
|
-
const thisURL = $(anchor).attr('href');
|
|
27
|
+
const thisURL = $html(anchor).attr('href');
|
|
25
28
|
|
|
26
29
|
// If it starts with a slash, append the base URL
|
|
27
30
|
if (thisURL && thisURL.indexOf('/') === 0) {
|
|
28
31
|
const updatedURL = `${urlOrigin.replace(/^\/|\/$/g, '')}/${thisURL.replace(/^\/|\/$/g, '')}`;
|
|
29
|
-
$(anchor).attr('href', updatedURL);
|
|
32
|
+
$html(anchor).attr('href', updatedURL);
|
|
30
33
|
}
|
|
31
34
|
});
|
|
32
35
|
|
|
33
36
|
$html('img').each((i, img) => {
|
|
34
|
-
const thisSrc = $(img).attr('src');
|
|
37
|
+
const thisSrc = $html(img).attr('src');
|
|
35
38
|
|
|
36
39
|
// If it starts with a slash, append the base URL
|
|
37
40
|
if (thisSrc && thisSrc.indexOf('/') === 0) {
|
|
38
41
|
const updatedURL = `${urlOrigin.replace(/^\/|\/$/g, '')}/${thisSrc.replace(/^\/|\/$/g, '')}`;
|
|
39
|
-
$(img).attr('src', updatedURL);
|
|
42
|
+
$html(img).attr('src', updatedURL);
|
|
40
43
|
}
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
// Unwrap <p> tags that are in <li> tags
|
|
45
48
|
$html('li').each((i, li) => {
|
|
46
|
-
const hasP = $(li).find('p').length;
|
|
49
|
+
const hasP = $html(li).find('p').length;
|
|
47
50
|
|
|
48
51
|
if (hasP) {
|
|
49
|
-
$(li).html($(li).find('p').html());
|
|
52
|
+
$html(li).html($html(li).find('p').html());
|
|
50
53
|
}
|
|
51
54
|
});
|
|
52
55
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-jekyll-export",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.40",
|
|
4
4
|
"description": "tbc",
|
|
5
5
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-jekyll-export",
|
|
6
6
|
"author": "Ghost Foundation",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@tryghost/errors": "1.3.8",
|
|
30
|
-
"@tryghost/mg-fs-utils": "0.16.
|
|
31
|
-
"@tryghost/string": "0.2.
|
|
32
|
-
"cheerio": "1.
|
|
30
|
+
"@tryghost/mg-fs-utils": "0.16.3",
|
|
31
|
+
"@tryghost/string": "0.2.21",
|
|
32
|
+
"cheerio": "1.1.2",
|
|
33
33
|
"front-matter": "4.0.2",
|
|
34
34
|
"markdown-it": "14.1.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "027225930710c0643603f6ae346dc76504d9bb7a"
|
|
37
37
|
}
|