@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.mjs
CHANGED
|
@@ -4,8 +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 { LRUCache } from 'lru-cache';
|
|
8
7
|
import he from 'he';
|
|
8
|
+
import * as htmlparser2 from 'htmlparser2';
|
|
9
|
+
import * as domSerializerModule from 'dom-serializer';
|
|
10
|
+
import { LRUCache } from 'lru-cache';
|
|
9
11
|
|
|
10
12
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
13
|
get: (a2, b) => (typeof require !== "undefined" ? require : a2)[b]
|
|
@@ -393,6 +395,12 @@ var getInlineMeta = (el, href) => {
|
|
|
393
395
|
isInline: textMatches || titleMatches
|
|
394
396
|
};
|
|
395
397
|
};
|
|
398
|
+
var addLineBreakBeforePostLink = (el, forApp, isInline) => {
|
|
399
|
+
if (forApp && isInline && el.parentNode) {
|
|
400
|
+
const br = el.ownerDocument.createElement("br");
|
|
401
|
+
el.parentNode.insertBefore(br, el);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
396
404
|
function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
397
405
|
if (!el || !el.parentNode) {
|
|
398
406
|
return;
|
|
@@ -456,6 +464,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
456
464
|
el.setAttribute("href", h);
|
|
457
465
|
el.setAttribute("data-is-inline", "" + isInline);
|
|
458
466
|
}
|
|
467
|
+
addLineBreakBeforePostLink(el, forApp, isInline);
|
|
459
468
|
return;
|
|
460
469
|
}
|
|
461
470
|
const mentionMatch = href.match(MENTION_REGEX);
|
|
@@ -533,6 +542,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
533
542
|
el.setAttribute("href", h);
|
|
534
543
|
el.setAttribute("data-is-inline", "" + isInline);
|
|
535
544
|
}
|
|
545
|
+
addLineBreakBeforePostLink(el, forApp, isInline);
|
|
536
546
|
return;
|
|
537
547
|
}
|
|
538
548
|
}
|
|
@@ -597,6 +607,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
597
607
|
el.setAttribute("href", h);
|
|
598
608
|
el.setAttribute("data-is-inline", "" + isInline);
|
|
599
609
|
}
|
|
610
|
+
addLineBreakBeforePostLink(el, forApp, isInline);
|
|
600
611
|
return;
|
|
601
612
|
}
|
|
602
613
|
}
|
|
@@ -682,6 +693,7 @@ function a(el, forApp, webp, parentDomain = "ecency.com") {
|
|
|
682
693
|
el.setAttribute("href", h);
|
|
683
694
|
el.setAttribute("data-is-inline", "" + isInline);
|
|
684
695
|
}
|
|
696
|
+
addLineBreakBeforePostLink(el, forApp, isInline);
|
|
685
697
|
return;
|
|
686
698
|
}
|
|
687
699
|
const BCmatch = href.match(BITCHUTE_REGEX);
|
|
@@ -1266,6 +1278,7 @@ function traverse(node, forApp, depth = 0, webp = false, state = { firstImageFou
|
|
|
1266
1278
|
function cleanReply(s) {
|
|
1267
1279
|
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>`, "");
|
|
1268
1280
|
}
|
|
1281
|
+
var domSerializer = domSerializerModule.default || domSerializerModule;
|
|
1269
1282
|
var lolight = null;
|
|
1270
1283
|
function getLolightInstance() {
|
|
1271
1284
|
if (!lolight) {
|
|
@@ -1357,8 +1370,6 @@ function markdownToHTML(input, forApp, webp, parentDomain = "ecency.com") {
|
|
|
1357
1370
|
try {
|
|
1358
1371
|
output = md.render(input);
|
|
1359
1372
|
const preSanitized = sanitizeHtml(output);
|
|
1360
|
-
const htmlparser2 = __require("htmlparser2");
|
|
1361
|
-
const domSerializer = __require("dom-serializer").default;
|
|
1362
1373
|
const dom = htmlparser2.parseDocument(preSanitized, {
|
|
1363
1374
|
// lenient options - don't throw on malformed HTML
|
|
1364
1375
|
lowerCaseTags: false,
|
|
@@ -1369,8 +1380,7 @@ function markdownToHTML(input, forApp, webp, parentDomain = "ecency.com") {
|
|
|
1369
1380
|
traverse(doc, forApp, 0, webp, { firstImageFound: false }, parentDomain);
|
|
1370
1381
|
output = serializer.serializeToString(doc);
|
|
1371
1382
|
} catch (fallbackError) {
|
|
1372
|
-
const
|
|
1373
|
-
const escapedContent = he2.encode(output || md.render(input));
|
|
1383
|
+
const escapedContent = he.encode(output || md.render(input));
|
|
1374
1384
|
output = `<p dir="auto">${escapedContent}</p>`;
|
|
1375
1385
|
}
|
|
1376
1386
|
}
|