@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.
@@ -1258,6 +1258,7 @@ function linkify(content, forApp, renderOptions) {
1258
1258
  }
1259
1259
  return `${preceding}<a class="markdown-tag-link" data-tag="${tagLower}">${tag.trim()}</a>`;
1260
1260
  });
1261
+ const authorPlaceholders = [];
1261
1262
  content = content.replace(
1262
1263
  /(^|[^a-zA-Z0-9_!#$%&*@@/]|(^|[^a-zA-Z0-9_+~.-/]))[@@]([a-z][-.a-z\d^/]+[a-z\d])/gi,
1263
1264
  (match, preceeding1, preceeding2, user) => {
@@ -1266,7 +1267,10 @@ function linkify(content, forApp, renderOptions) {
1266
1267
  if (userLower.indexOf("/") === -1 && isValidUsername(user)) {
1267
1268
  if (!forApp) {
1268
1269
  const avatarSrc = `https://images.ecency.com/u/${userLower}/avatar/small`;
1269
- return `${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>`;
1270
+ 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>`;
1271
+ const placeholder = `\u200C${authorPlaceholders.length}\u200C`;
1272
+ authorPlaceholders.push({ placeholder, html });
1273
+ return placeholder;
1270
1274
  }
1271
1275
  return `${preceedings}<a class="markdown-author-link" data-author="${userLower}">@${user}</a>`;
1272
1276
  } else {
@@ -1311,6 +1315,9 @@ function linkify(content, forApp, renderOptions) {
1311
1315
  firstImageUsed = true;
1312
1316
  return createImageHTML(imglink, isLCP);
1313
1317
  });
1318
+ authorPlaceholders.forEach(({ placeholder, html }) => {
1319
+ content = content.replace(placeholder, html);
1320
+ });
1314
1321
  return content;
1315
1322
  }
1316
1323
 
@@ -1576,6 +1583,22 @@ function markdownToHTML(input, forApp, parentDomain = "ecency.com", seoContext,
1576
1583
  output = output.replace(/ xmlns="http:\/\/www.w3.org\/1999\/xhtml"/g, "").replace('<body id="root">', "").replace("</body>", "").trim();
1577
1584
  return sanitizeHtml(output);
1578
1585
  }
1586
+ var mdInstance = null;
1587
+ function getMd() {
1588
+ if (!mdInstance) {
1589
+ mdInstance = new remarkable.Remarkable({
1590
+ html: true,
1591
+ breaks: true,
1592
+ typographer: false
1593
+ }).use(linkify$1.linkify);
1594
+ }
1595
+ return mdInstance;
1596
+ }
1597
+ function simpleMarkdownToHTML(input) {
1598
+ if (!input) return "";
1599
+ const html = getMd().render(input);
1600
+ return sanitizeHtml(html);
1601
+ }
1579
1602
  var cache = new lruCache.LRUCache({ max: 60 });
1580
1603
  function setCacheSize(size) {
1581
1604
  cache = new lruCache.LRUCache({ max: size });
@@ -1791,5 +1814,6 @@ exports.proxifyImageSrc = proxifyImageSrc;
1791
1814
  exports.renderPostBody = markdown2Html;
1792
1815
  exports.setCacheSize = setCacheSize;
1793
1816
  exports.setProxyBase = setProxyBase;
1817
+ exports.simpleMarkdownToHTML = simpleMarkdownToHTML;
1794
1818
  //# sourceMappingURL=index.cjs.map
1795
1819
  //# sourceMappingURL=index.cjs.map