@ecency/render-helper 2.4.26 → 2.4.28
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.d.ts +11 -1
- package/dist/browser/index.js +25 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +25 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +25 -2
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1229,6 +1229,7 @@ function linkify(content, forApp, renderOptions) {
|
|
|
1229
1229
|
}
|
|
1230
1230
|
return `${preceding}<a class="markdown-tag-link" data-tag="${tagLower}">${tag.trim()}</a>`;
|
|
1231
1231
|
});
|
|
1232
|
+
const authorPlaceholders = [];
|
|
1232
1233
|
content = content.replace(
|
|
1233
1234
|
/(^|[^a-zA-Z0-9_!#$%&*@@/]|(^|[^a-zA-Z0-9_+~.-/]))[@@]([a-z][-.a-z\d^/]+[a-z\d])/gi,
|
|
1234
1235
|
(match, preceeding1, preceeding2, user) => {
|
|
@@ -1237,7 +1238,10 @@ function linkify(content, forApp, renderOptions) {
|
|
|
1237
1238
|
if (userLower.indexOf("/") === -1 && isValidUsername(user)) {
|
|
1238
1239
|
if (!forApp) {
|
|
1239
1240
|
const avatarSrc = `https://images.ecency.com/u/${userLower}/avatar/small`;
|
|
1240
|
-
|
|
1241
|
+
const html = `${preceedings}<a class="er-author er-author-link" href="/@${userLower}"><img class="er-author-link-image" src="${avatarSrc}" alt="${userLower}"/><span class="er-author-link-content"><span class="er-author-link-label">Hive account</span><span>@${userLower}</span></span></a>`;
|
|
1242
|
+
const placeholder = `\u200C${authorPlaceholders.length}\u200C`;
|
|
1243
|
+
authorPlaceholders.push({ placeholder, html });
|
|
1244
|
+
return placeholder;
|
|
1241
1245
|
}
|
|
1242
1246
|
return `${preceedings}<a class="markdown-author-link" data-author="${userLower}">@${user}</a>`;
|
|
1243
1247
|
} else {
|
|
@@ -1282,6 +1286,9 @@ function linkify(content, forApp, renderOptions) {
|
|
|
1282
1286
|
firstImageUsed = true;
|
|
1283
1287
|
return createImageHTML(imglink, isLCP);
|
|
1284
1288
|
});
|
|
1289
|
+
authorPlaceholders.forEach(({ placeholder, html }) => {
|
|
1290
|
+
content = content.replace(placeholder, html);
|
|
1291
|
+
});
|
|
1285
1292
|
return content;
|
|
1286
1293
|
}
|
|
1287
1294
|
|
|
@@ -1547,6 +1554,22 @@ function markdownToHTML(input, forApp, parentDomain = "ecency.com", seoContext,
|
|
|
1547
1554
|
output = output.replace(/ xmlns="http:\/\/www.w3.org\/1999\/xhtml"/g, "").replace('<body id="root">', "").replace("</body>", "").trim();
|
|
1548
1555
|
return sanitizeHtml(output);
|
|
1549
1556
|
}
|
|
1557
|
+
var mdInstance = null;
|
|
1558
|
+
function getMd() {
|
|
1559
|
+
if (!mdInstance) {
|
|
1560
|
+
mdInstance = new Remarkable({
|
|
1561
|
+
html: true,
|
|
1562
|
+
breaks: true,
|
|
1563
|
+
typographer: false
|
|
1564
|
+
}).use(linkify$1);
|
|
1565
|
+
}
|
|
1566
|
+
return mdInstance;
|
|
1567
|
+
}
|
|
1568
|
+
function simpleMarkdownToHTML(input) {
|
|
1569
|
+
if (!input) return "";
|
|
1570
|
+
const html = getMd().render(input);
|
|
1571
|
+
return sanitizeHtml(html);
|
|
1572
|
+
}
|
|
1550
1573
|
var cache = new LRUCache({ max: 60 });
|
|
1551
1574
|
function setCacheSize(size) {
|
|
1552
1575
|
cache = new LRUCache({ max: size });
|
|
@@ -1754,6 +1777,6 @@ function getPostBodySummary(obj, length, platform) {
|
|
|
1754
1777
|
return res;
|
|
1755
1778
|
}
|
|
1756
1779
|
|
|
1757
|
-
export { SECTION_LIST, catchPostImage, isValidPermlink, getPostBodySummary as postBodySummary, proxifyImageSrc, markdown2Html as renderPostBody, setCacheSize, setProxyBase };
|
|
1780
|
+
export { SECTION_LIST, catchPostImage, isValidPermlink, getPostBodySummary as postBodySummary, proxifyImageSrc, markdown2Html as renderPostBody, setCacheSize, setProxyBase, simpleMarkdownToHTML };
|
|
1758
1781
|
//# sourceMappingURL=index.mjs.map
|
|
1759
1782
|
//# sourceMappingURL=index.mjs.map
|