@tryghost/kg-mobiledoc-html-renderer 5.3.2 → 5.3.3
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const SimpleDom = require('simple-dom');
|
|
2
|
-
const semver = require('semver');
|
|
3
2
|
const Renderer = require('mobiledoc-dom-renderer').default;
|
|
3
|
+
const {slugify} = require('@tryghost/kg-utils');
|
|
4
4
|
|
|
5
5
|
const walkDom = function (node, func) {
|
|
6
6
|
func(node);
|
|
@@ -24,29 +24,6 @@ const nodeTextContent = function (node) {
|
|
|
24
24
|
return textContent;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
const slugify = function (inputString, {ghostVersion = '4.0'} = {}) {
|
|
28
|
-
const version = semver.coerce(ghostVersion);
|
|
29
|
-
|
|
30
|
-
if (semver.satisfies(version, '<4.x')) {
|
|
31
|
-
// backwards compatible slugs used in Ghost 2.x to 3.x mobiledoc
|
|
32
|
-
return inputString.replace(/[<>&"?]/g, '')
|
|
33
|
-
.trim()
|
|
34
|
-
.replace(/[^\w]/g, '-')
|
|
35
|
-
.replace(/-{2,}/g, '-')
|
|
36
|
-
.toLowerCase();
|
|
37
|
-
} else {
|
|
38
|
-
// news slugs introduced in 4.0
|
|
39
|
-
// allows all chars except symbols but will urlEncode everything
|
|
40
|
-
// produces %-encoded chars in src but browsers show real chars in status bar and url bar
|
|
41
|
-
return encodeURIComponent(inputString.trim()
|
|
42
|
-
.toLowerCase()
|
|
43
|
-
.replace(/[\][!"#$%&'()*+,./:;<=>?@\\^_{|}~]/g, '')
|
|
44
|
-
.replace(/\s+/g, '-')
|
|
45
|
-
.replace(/^-|-{2,}|-$/g, '')
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
27
|
// used to walk the rendered SimpleDOM output and modify elements before
|
|
51
28
|
// serializing to HTML. Saves having a large HTML parsing dependency such as
|
|
52
29
|
// jsdom that may break on malformed HTML in MD or HTML cards
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/kg-mobiledoc-html-renderer",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.3",
|
|
4
4
|
"repository": "https://github.com/TryGhost/Koenig/tree/master/packages/kg-mobiledoc-html-renderer",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@tryghost/kg-utils": "^1.0.0",
|
|
25
26
|
"mobiledoc-dom-renderer": "^0.7.0",
|
|
26
|
-
"semver": "^7.3.4",
|
|
27
27
|
"simple-dom": "^1.4.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"c8": "7.11.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "615a20445876522e113a8770ada332e8c00d939b"
|
|
33
33
|
}
|