@ecency/render-helper 2.4.31 → 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 +17 -17
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +18 -21
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +17 -20
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -4,10 +4,10 @@ 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,14 +168,13 @@ var ALLOWED_ATTRIBUTES = {
|
|
|
168
168
|
"del": [],
|
|
169
169
|
"ins": []
|
|
170
170
|
};
|
|
171
|
-
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
});
|
|
171
|
+
function createParser() {
|
|
172
|
+
return new DOMParser$1({
|
|
173
|
+
onError(level, msg) {
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
var DOMParser = createParser();
|
|
179
178
|
|
|
180
179
|
// src/helper.ts
|
|
181
180
|
function removeDuplicateAttributes(html) {
|
|
@@ -253,6 +252,8 @@ function isValidUsername(username) {
|
|
|
253
252
|
!label.includes("..");
|
|
254
253
|
});
|
|
255
254
|
}
|
|
255
|
+
|
|
256
|
+
// src/methods/get-inner-html.method.ts
|
|
256
257
|
function getSerializedInnerHTML(node) {
|
|
257
258
|
const serializer = new XMLSerializer();
|
|
258
259
|
if (node.childNodes[0]) {
|
|
@@ -1589,8 +1590,7 @@ function markdownToHTML(input, forApp, parentDomain = "ecency.com", seoContext,
|
|
|
1589
1590
|
traverse(doc, forApp, 0, { firstImageFound: false }, parentDomain, seoContext, renderOptions);
|
|
1590
1591
|
output = serializer.serializeToString(doc);
|
|
1591
1592
|
} catch (fallbackError) {
|
|
1592
|
-
|
|
1593
|
-
output = `<p dir="auto">${escapedContent}</p>`;
|
|
1593
|
+
output = sanitizeHtml(output || md.render(input));
|
|
1594
1594
|
}
|
|
1595
1595
|
}
|
|
1596
1596
|
if (forApp && output && entityPlaceholders.length > 0) {
|
|
@@ -1599,7 +1599,7 @@ function markdownToHTML(input, forApp, parentDomain = "ecency.com", seoContext,
|
|
|
1599
1599
|
output = output.split(placeholder).join(entity);
|
|
1600
1600
|
});
|
|
1601
1601
|
}
|
|
1602
|
-
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();
|
|
1603
1603
|
return sanitizeHtml(output);
|
|
1604
1604
|
}
|
|
1605
1605
|
var mdInstance = null;
|
|
@@ -1661,7 +1661,7 @@ function getImage(entry, width = 0, height = 0, format = "match") {
|
|
|
1661
1661
|
}
|
|
1662
1662
|
}
|
|
1663
1663
|
if (meta && typeof meta.image === "string" && meta.image.length > 0) {
|
|
1664
|
-
const decodedImage =
|
|
1664
|
+
const decodedImage = he.decode(meta.image);
|
|
1665
1665
|
if (isGifLink(decodedImage)) {
|
|
1666
1666
|
return proxifyImageSrc(decodedImage, 0, 0, format);
|
|
1667
1667
|
}
|
|
@@ -1669,7 +1669,7 @@ function getImage(entry, width = 0, height = 0, format = "match") {
|
|
|
1669
1669
|
}
|
|
1670
1670
|
if (meta && meta.image && !!meta.image.length && meta.image[0]) {
|
|
1671
1671
|
if (typeof meta.image[0] === "string") {
|
|
1672
|
-
const decodedImage =
|
|
1672
|
+
const decodedImage = he.decode(meta.image[0]);
|
|
1673
1673
|
if (isGifLink(decodedImage)) {
|
|
1674
1674
|
return proxifyImageSrc(decodedImage, 0, 0, format);
|
|
1675
1675
|
}
|
|
@@ -1691,7 +1691,7 @@ function getImage(entry, width = 0, height = 0, format = "match") {
|
|
|
1691
1691
|
if (!src) {
|
|
1692
1692
|
return null;
|
|
1693
1693
|
}
|
|
1694
|
-
const decodedSrc =
|
|
1694
|
+
const decodedSrc = he.decode(src);
|
|
1695
1695
|
if (isGifLink(decodedSrc)) {
|
|
1696
1696
|
return proxifyImageSrc(decodedSrc, 0, 0, format);
|
|
1697
1697
|
}
|
|
@@ -1712,7 +1712,7 @@ function catchPostImage(obj, width = 0, height = 0, format = "match") {
|
|
|
1712
1712
|
if (!src) {
|
|
1713
1713
|
return null;
|
|
1714
1714
|
}
|
|
1715
|
-
const decodedSrc =
|
|
1715
|
+
const decodedSrc = he.decode(src);
|
|
1716
1716
|
if (isGifLink(decodedSrc)) {
|
|
1717
1717
|
return proxifyImageSrc(decodedSrc, 0, 0, format);
|
|
1718
1718
|
}
|
|
@@ -1805,7 +1805,7 @@ function postBodySummary(entryBody, length = 200, platform = "web") {
|
|
|
1805
1805
|
text2 = joint(text2.split(" "), length);
|
|
1806
1806
|
}
|
|
1807
1807
|
if (text2) {
|
|
1808
|
-
text2 =
|
|
1808
|
+
text2 = he.decode(text2);
|
|
1809
1809
|
}
|
|
1810
1810
|
return text2;
|
|
1811
1811
|
}
|