MCPcopy
hub / github.com/openclaw/clawsweeper / inline

Function inline

scripts/build-docs-site.mjs:330–343  ·  view source on GitHub ↗
(text, currentRel)

Source from the content-addressed store, hash-verified

328}
329
330function inline(text, currentRel) {
331 const stash = [];
332 let out = text.replace(/`([^`]+)`/g, (_, code) => {
333 stash.push(`<code>${escapeHtml(code)}</code>`);
334 return `@@CODE${stash.length - 1}@@`;
335 });
336 out = escapeHtml(out)
337 .replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>")
338 .replace(
339 /\[([^\]]+)\]\(([^)]+)\)/g,
340 (_, label, href) => `<a href="${escapeAttr(rewriteHref(href, currentRel))}">${label}</a>`,
341 );
342 return out.replace(/@@CODE(\d+)@@/g, (_, i) => stash[Number(i)]);
343}
344
345function rewriteHref(href, currentRel) {
346 if (/^(https?:|mailto:|#)/.test(href)) return href;

Callers 2

flushParagraphFunction · 0.85
markdownToHtmlFunction · 0.85

Calls 3

escapeAttrFunction · 0.85
rewriteHrefFunction · 0.85
escapeHtmlFunction · 0.70

Tested by

no test coverage detected