@ecency/render-helper 2.4.32 → 2.4.33
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/dist/browser/index.js +16 -17
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +18 -22
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +16 -20
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { DOMParser as DOMParser$1, XMLSerializer
|
|
1
|
+
import { DOMParser as DOMParser$1, XMLSerializer } from '@xmldom/xmldom';
|
|
2
2
|
import xss from 'xss';
|
|
3
3
|
import multihash from 'multihashes';
|
|
4
4
|
import querystring from 'querystring';
|
|
5
5
|
import { Remarkable } from 'remarkable';
|
|
6
6
|
import { linkify as linkify$1 } from 'remarkable/linkify';
|
|
7
|
-
import he2 from 'he';
|
|
8
7
|
import * as htmlparser2 from 'htmlparser2';
|
|
9
8
|
import * as domSerializerModule from 'dom-serializer';
|
|
10
9
|
import { LRUCache } from 'lru-cache';
|
|
10
|
+
import he from 'he';
|
|
11
11
|
|
|
12
12
|
// src/consts/white-list.const.ts
|
|
13
13
|
var WHITE_LIST = [
|
|
@@ -168,13 +168,13 @@ var ALLOWED_ATTRIBUTES = {
|
|
|
168
168
|
"del": [],
|
|
169
169
|
"ins": []
|
|
170
170
|
};
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
var
|
|
171
|
+
function createParser() {
|
|
172
|
+
return new DOMParser$1({
|
|
173
|
+
onError(level, msg) {
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
var DOMParser = createParser();
|
|
178
178
|
|
|
179
179
|
// src/helper.ts
|
|
180
180
|
function removeDuplicateAttributes(html) {
|
|
@@ -1590,8 +1590,7 @@ function markdownToHTML(input, forApp, parentDomain = "ecency.com", seoContext,
|
|
|
1590
1590
|
traverse(doc, forApp, 0, { firstImageFound: false }, parentDomain, seoContext, renderOptions);
|
|
1591
1591
|
output = serializer.serializeToString(doc);
|
|
1592
1592
|
} catch (fallbackError) {
|
|
1593
|
-
|
|
1594
|
-
output = `<p dir="auto">${escapedContent}</p>`;
|
|
1593
|
+
output = sanitizeHtml(output || md.render(input));
|
|
1595
1594
|
}
|
|
1596
1595
|
}
|
|
1597
1596
|
if (forApp && output && entityPlaceholders.length > 0) {
|
|
@@ -1600,7 +1599,7 @@ function markdownToHTML(input, forApp, parentDomain = "ecency.com", seoContext,
|
|
|
1600
1599
|
output = output.split(placeholder).join(entity);
|
|
1601
1600
|
});
|
|
1602
1601
|
}
|
|
1603
|
-
output = output.replace(/ xmlns="http:\/\/www.w3.org\/1999\/xhtml"/g, "").replace('<body id="root">', "").replace("</body>", "").trim();
|
|
1602
|
+
output = output.replace(/ xmlns="http:\/\/www.w3.org\/1999\/xhtml"/g, "").replace(/^<\?xml[^?]*\?>/, "").replace(/^<!DOCTYPE[^>]*>/i, "").replace(/<\/?html[^>]*>/g, "").replace(/<head[^>]*>[\s\S]*?<\/head>/g, "").replace('<body id="root">', "").replace("</body>", "").trim();
|
|
1604
1603
|
return sanitizeHtml(output);
|
|
1605
1604
|
}
|
|
1606
1605
|
var mdInstance = null;
|
|
@@ -1662,7 +1661,7 @@ function getImage(entry, width = 0, height = 0, format = "match") {
|
|
|
1662
1661
|
}
|
|
1663
1662
|
}
|
|
1664
1663
|
if (meta && typeof meta.image === "string" && meta.image.length > 0) {
|
|
1665
|
-
const decodedImage =
|
|
1664
|
+
const decodedImage = he.decode(meta.image);
|
|
1666
1665
|
if (isGifLink(decodedImage)) {
|
|
1667
1666
|
return proxifyImageSrc(decodedImage, 0, 0, format);
|
|
1668
1667
|
}
|
|
@@ -1670,7 +1669,7 @@ function getImage(entry, width = 0, height = 0, format = "match") {
|
|
|
1670
1669
|
}
|
|
1671
1670
|
if (meta && meta.image && !!meta.image.length && meta.image[0]) {
|
|
1672
1671
|
if (typeof meta.image[0] === "string") {
|
|
1673
|
-
const decodedImage =
|
|
1672
|
+
const decodedImage = he.decode(meta.image[0]);
|
|
1674
1673
|
if (isGifLink(decodedImage)) {
|
|
1675
1674
|
return proxifyImageSrc(decodedImage, 0, 0, format);
|
|
1676
1675
|
}
|
|
@@ -1692,7 +1691,7 @@ function getImage(entry, width = 0, height = 0, format = "match") {
|
|
|
1692
1691
|
if (!src) {
|
|
1693
1692
|
return null;
|
|
1694
1693
|
}
|
|
1695
|
-
const decodedSrc =
|
|
1694
|
+
const decodedSrc = he.decode(src);
|
|
1696
1695
|
if (isGifLink(decodedSrc)) {
|
|
1697
1696
|
return proxifyImageSrc(decodedSrc, 0, 0, format);
|
|
1698
1697
|
}
|
|
@@ -1713,7 +1712,7 @@ function catchPostImage(obj, width = 0, height = 0, format = "match") {
|
|
|
1713
1712
|
if (!src) {
|
|
1714
1713
|
return null;
|
|
1715
1714
|
}
|
|
1716
|
-
const decodedSrc =
|
|
1715
|
+
const decodedSrc = he.decode(src);
|
|
1717
1716
|
if (isGifLink(decodedSrc)) {
|
|
1718
1717
|
return proxifyImageSrc(decodedSrc, 0, 0, format);
|
|
1719
1718
|
}
|
|
@@ -1806,7 +1805,7 @@ function postBodySummary(entryBody, length = 200, platform = "web") {
|
|
|
1806
1805
|
text2 = joint(text2.split(" "), length);
|
|
1807
1806
|
}
|
|
1808
1807
|
if (text2) {
|
|
1809
|
-
text2 =
|
|
1808
|
+
text2 = he.decode(text2);
|
|
1810
1809
|
}
|
|
1811
1810
|
return text2;
|
|
1812
1811
|
}
|