@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/browser/index.d.ts
CHANGED
|
@@ -61,4 +61,14 @@ declare const SECTION_LIST: string[];
|
|
|
61
61
|
|
|
62
62
|
declare function isValidPermlink(permlink: string): boolean;
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Lightweight markdown-to-HTML conversion with sanitization.
|
|
66
|
+
* Unlike the full `markdownToHTML`, this skips Hive-specific transforms
|
|
67
|
+
* (image proxying, link internalizing, DOM traversal, etc.).
|
|
68
|
+
*
|
|
69
|
+
* Intended for editor input (TipTap), chat messages, and other contexts
|
|
70
|
+
* where simple markdown rendering is sufficient.
|
|
71
|
+
*/
|
|
72
|
+
declare function simpleMarkdownToHTML(input: string): string;
|
|
73
|
+
|
|
74
|
+
export { type Entry, type RenderOptions, SECTION_LIST, type SeoContext, catchPostImage, isValidPermlink, getPostBodySummary as postBodySummary, proxifyImageSrc, markdown2Html as renderPostBody, setCacheSize, setProxyBase, simpleMarkdownToHTML };
|
package/dist/browser/index.js
CHANGED
|
@@ -1226,6 +1226,7 @@ function linkify(content, forApp, renderOptions) {
|
|
|
1226
1226
|
}
|
|
1227
1227
|
return `${preceding}<a class="markdown-tag-link" data-tag="${tagLower}">${tag.trim()}</a>`;
|
|
1228
1228
|
});
|
|
1229
|
+
const authorPlaceholders = [];
|
|
1229
1230
|
content = content.replace(
|
|
1230
1231
|
/(^|[^a-zA-Z0-9_!#$%&*@@/]|(^|[^a-zA-Z0-9_+~.-/]))[@@]([a-z][-.a-z\d^/]+[a-z\d])/gi,
|
|
1231
1232
|
(match, preceeding1, preceeding2, user) => {
|
|
@@ -1234,7 +1235,10 @@ function linkify(content, forApp, renderOptions) {
|
|
|
1234
1235
|
if (userLower.indexOf("/") === -1 && isValidUsername(user)) {
|
|
1235
1236
|
if (!forApp) {
|
|
1236
1237
|
const avatarSrc = `https://images.ecency.com/u/${userLower}/avatar/small`;
|
|
1237
|
-
|
|
1238
|
+
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>`;
|
|
1239
|
+
const placeholder = `\u200C${authorPlaceholders.length}\u200C`;
|
|
1240
|
+
authorPlaceholders.push({ placeholder, html });
|
|
1241
|
+
return placeholder;
|
|
1238
1242
|
}
|
|
1239
1243
|
return `${preceedings}<a class="markdown-author-link" data-author="${userLower}">@${user}</a>`;
|
|
1240
1244
|
} else {
|
|
@@ -1279,6 +1283,9 @@ function linkify(content, forApp, renderOptions) {
|
|
|
1279
1283
|
firstImageUsed = true;
|
|
1280
1284
|
return createImageHTML(imglink, isLCP);
|
|
1281
1285
|
});
|
|
1286
|
+
authorPlaceholders.forEach(({ placeholder, html }) => {
|
|
1287
|
+
content = content.replace(placeholder, html);
|
|
1288
|
+
});
|
|
1282
1289
|
return content;
|
|
1283
1290
|
}
|
|
1284
1291
|
|
|
@@ -1544,6 +1551,22 @@ function markdownToHTML(input, forApp, parentDomain = "ecency.com", seoContext,
|
|
|
1544
1551
|
output = output.replace(/ xmlns="http:\/\/www.w3.org\/1999\/xhtml"/g, "").replace('<body id="root">', "").replace("</body>", "").trim();
|
|
1545
1552
|
return sanitizeHtml(output);
|
|
1546
1553
|
}
|
|
1554
|
+
var mdInstance = null;
|
|
1555
|
+
function getMd() {
|
|
1556
|
+
if (!mdInstance) {
|
|
1557
|
+
mdInstance = new Remarkable({
|
|
1558
|
+
html: true,
|
|
1559
|
+
breaks: true,
|
|
1560
|
+
typographer: false
|
|
1561
|
+
}).use(linkify$1);
|
|
1562
|
+
}
|
|
1563
|
+
return mdInstance;
|
|
1564
|
+
}
|
|
1565
|
+
function simpleMarkdownToHTML(input) {
|
|
1566
|
+
if (!input) return "";
|
|
1567
|
+
const html = getMd().render(input);
|
|
1568
|
+
return sanitizeHtml(html);
|
|
1569
|
+
}
|
|
1547
1570
|
var cache = new LRUCache({ max: 60 });
|
|
1548
1571
|
function setCacheSize(size) {
|
|
1549
1572
|
cache = new LRUCache({ max: size });
|
|
@@ -1751,6 +1774,6 @@ function getPostBodySummary(obj, length, platform) {
|
|
|
1751
1774
|
return res;
|
|
1752
1775
|
}
|
|
1753
1776
|
|
|
1754
|
-
export { SECTION_LIST, catchPostImage, isValidPermlink, getPostBodySummary as postBodySummary, proxifyImageSrc, markdown2Html as renderPostBody, setCacheSize, setProxyBase };
|
|
1777
|
+
export { SECTION_LIST, catchPostImage, isValidPermlink, getPostBodySummary as postBodySummary, proxifyImageSrc, markdown2Html as renderPostBody, setCacheSize, setProxyBase, simpleMarkdownToHTML };
|
|
1755
1778
|
//# sourceMappingURL=index.js.map
|
|
1756
1779
|
//# sourceMappingURL=index.js.map
|