@ecency/render-helper 2.4.5 → 2.4.7
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 +15 -5
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +36 -6
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +15 -5
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -6,15 +6,37 @@ var multihash = require('multihashes');
|
|
|
6
6
|
var querystring = require('querystring');
|
|
7
7
|
var remarkable = require('remarkable');
|
|
8
8
|
var linkify$1 = require('remarkable/linkify');
|
|
9
|
-
var lruCache = require('lru-cache');
|
|
10
9
|
var he = require('he');
|
|
10
|
+
var htmlparser2 = require('htmlparser2');
|
|
11
|
+
var domSerializerModule = require('dom-serializer');
|
|
12
|
+
var lruCache = require('lru-cache');
|
|
11
13
|
|
|
12
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
15
|
|
|
16
|
+
function _interopNamespace(e) {
|
|
17
|
+
if (e && e.__esModule) return e;
|
|
18
|
+
var n = Object.create(null);
|
|
19
|
+
if (e) {
|
|
20
|
+
Object.keys(e).forEach(function (k) {
|
|
21
|
+
if (k !== 'default') {
|
|
22
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return e[k]; }
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
n.default = e;
|
|
31
|
+
return Object.freeze(n);
|
|
32
|
+
}
|
|
33
|
+
|
|
14
34
|
var xss__default = /*#__PURE__*/_interopDefault(xss);
|
|
15
35
|
var multihash__default = /*#__PURE__*/_interopDefault(multihash);
|
|
16
36
|
var querystring__default = /*#__PURE__*/_interopDefault(querystring);
|
|
17
37
|
var he__default = /*#__PURE__*/_interopDefault(he);
|
|
38
|
+
var htmlparser2__namespace = /*#__PURE__*/_interopNamespace(htmlparser2);
|
|
39
|
+
var domSerializerModule__namespace = /*#__PURE__*/_interopNamespace(domSerializerModule);
|
|
18
40
|
|
|
19
41
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
20
42
|
get: (a2, b) => (typeof require !== "undefined" ? require : a2)[b]
|
|
@@ -402,6 +424,12 @@ var getInlineMeta = (el, href) => {
|
|
|
402
424
|
isInline: textMatches || titleMatches
|
|
403
425
|
};
|
|
404
426
|
};
|
|
427
|
+
var addLineBreakBeforePostLink = (el, forApp, isInline) => {
|
|
428
|
+
if (forApp && isInline && el.parentNode) {
|
|
429
|
+
const br = el.ownerDocument.createElement("br");
|
|
430
|
+
el.parentNode.insertBefore(br, el);
|
|
431
|
+
}
|
|
432
|
+
};
|
|
405
433
|
function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
406
434
|
if (!el || !el.parentNode) {
|
|
407
435
|
return;
|
|
@@ -465,6 +493,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
465
493
|
el.setAttribute("href", h);
|
|
466
494
|
el.setAttribute("data-is-inline", "" + isInline);
|
|
467
495
|
}
|
|
496
|
+
addLineBreakBeforePostLink(el, forApp, isInline);
|
|
468
497
|
return;
|
|
469
498
|
}
|
|
470
499
|
const mentionMatch = href.match(MENTION_REGEX);
|
|
@@ -542,6 +571,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
542
571
|
el.setAttribute("href", h);
|
|
543
572
|
el.setAttribute("data-is-inline", "" + isInline);
|
|
544
573
|
}
|
|
574
|
+
addLineBreakBeforePostLink(el, forApp, isInline);
|
|
545
575
|
return;
|
|
546
576
|
}
|
|
547
577
|
}
|
|
@@ -606,6 +636,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
606
636
|
el.setAttribute("href", h);
|
|
607
637
|
el.setAttribute("data-is-inline", "" + isInline);
|
|
608
638
|
}
|
|
639
|
+
addLineBreakBeforePostLink(el, forApp, isInline);
|
|
609
640
|
return;
|
|
610
641
|
}
|
|
611
642
|
}
|
|
@@ -691,6 +722,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
691
722
|
el.setAttribute("href", h);
|
|
692
723
|
el.setAttribute("data-is-inline", "" + isInline);
|
|
693
724
|
}
|
|
725
|
+
addLineBreakBeforePostLink(el, forApp, isInline);
|
|
694
726
|
return;
|
|
695
727
|
}
|
|
696
728
|
const BCmatch = href.match(BITCHUTE_REGEX);
|
|
@@ -1275,6 +1307,7 @@ function traverse(node, forApp, depth = 0, webp = false, state = { firstImageFou
|
|
|
1275
1307
|
function cleanReply(s) {
|
|
1276
1308
|
return (s ? s.split("\n").filter((item) => item.toLowerCase().includes("posted using [partiko") === false).filter((item) => item.toLowerCase().includes("posted using [dapplr") === false).filter((item) => item.toLowerCase().includes("posted using [leofinance") === false).filter((item) => item.toLowerCase().includes("posted via [neoxian") === false).filter((item) => item.toLowerCase().includes("posted using [neoxian") === false).filter((item) => item.toLowerCase().includes("posted with [stemgeeks") === false).filter((item) => item.toLowerCase().includes("posted using [bilpcoin") === false).filter((item) => item.toLowerCase().includes("posted using [inleo") === false).filter((item) => item.toLowerCase().includes("posted using [sportstalksocial]") === false).filter((item) => item.toLowerCase().includes("<center><sub>[posted using aeneas.blog") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [proofofbrain.io") === false).filter((item) => item.toLowerCase().includes("<center>posted on [hypnochain") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [weedcash.network") === false).filter((item) => item.toLowerCase().includes("<center>posted on [naturalmedicine.io") === false).filter((item) => item.toLowerCase().includes("<center><sub>posted via [musicforlife.io") === false).filter((item) => item.toLowerCase().includes("if the truvvl embed is unsupported by your current frontend, click this link to view this story") === false).filter((item) => item.toLowerCase().includes("<center><em>posted from truvvl") === false).filter((item) => item.toLowerCase().includes('view this post <a href="https://travelfeed.io/') === false).filter((item) => item.toLowerCase().includes("read this post on travelfeed.io for the best experience") === false).filter((item) => item.toLowerCase().includes('posted via <a href="https://www.dporn.co/"') === false).filter((item) => item.toLowerCase().includes("\u25B6\uFE0F [watch on 3speak](https://3speak") === false).filter((item) => item.toLowerCase().includes("<sup><sub>posted via [inji.com]") === false).filter((item) => item.toLowerCase().includes("view this post on [liketu]") === false).filter((item) => item.toLowerCase().includes("[via Inbox]") === false).join("\n") : "").replace('Posted via <a href="https://d.buzz" data-link="promote-link">D.Buzz</a>', "").replace('<div class="pull-right"><a href="/@hive.engage"></a></div>', "").replace('<div><a href="https://engage.hivechain.app"></a></div>', "").replace(`<div class="text-center"><img src="https://cdn.steemitimages.com/DQmNp6YwAm2qwquALZw8PdcovDorwaBSFuxQ38TrYziGT6b/A-20.png"><a href="https://bit.ly/actifit-app"><img src="https://cdn.steemitimages.com/DQmQqfpSmcQtfrHAtzfBtVccXwUL9vKNgZJ2j93m8WNjizw/l5.png"></a><a href="https://bit.ly/actifit-ios"><img src="https://cdn.steemitimages.com/DQmbWy8KzKT1UvCvznUTaFPw6wBUcyLtBT5XL9wdbB7Hfmn/l6.png"></a></div>`, "");
|
|
1277
1309
|
}
|
|
1310
|
+
var domSerializer = domSerializerModule__namespace.default || domSerializerModule__namespace;
|
|
1278
1311
|
var lolight = null;
|
|
1279
1312
|
function getLolightInstance() {
|
|
1280
1313
|
if (!lolight) {
|
|
@@ -1366,9 +1399,7 @@ function markdownToHTML(input, forApp, webp, parentDomain = "ecency.com") {
|
|
|
1366
1399
|
try {
|
|
1367
1400
|
output = md.render(input);
|
|
1368
1401
|
const preSanitized = sanitizeHtml(output);
|
|
1369
|
-
const
|
|
1370
|
-
const domSerializer = __require("dom-serializer").default;
|
|
1371
|
-
const dom = htmlparser2.parseDocument(preSanitized, {
|
|
1402
|
+
const dom = htmlparser2__namespace.parseDocument(preSanitized, {
|
|
1372
1403
|
// lenient options - don't throw on malformed HTML
|
|
1373
1404
|
lowerCaseTags: false,
|
|
1374
1405
|
lowerCaseAttributeNames: false
|
|
@@ -1378,8 +1409,7 @@ function markdownToHTML(input, forApp, webp, parentDomain = "ecency.com") {
|
|
|
1378
1409
|
traverse(doc, forApp, 0, webp, { firstImageFound: false }, parentDomain);
|
|
1379
1410
|
output = serializer.serializeToString(doc);
|
|
1380
1411
|
} catch (fallbackError) {
|
|
1381
|
-
const
|
|
1382
|
-
const escapedContent = he2.encode(output || md.render(input));
|
|
1412
|
+
const escapedContent = he__default.default.encode(output || md.render(input));
|
|
1383
1413
|
output = `<p dir="auto">${escapedContent}</p>`;
|
|
1384
1414
|
}
|
|
1385
1415
|
}
|