MCPcopy Create free account
hub / github.com/dailydotdev/apps / inlineMarkdownToHtml

Function inlineMarkdownToHtml

packages/shared/src/lib/markdownConversion.ts:21–42  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

19};
20
21const inlineMarkdownToHtml = (value: string): string => {
22 let result = escapeHtml(value);
23
24 result = result.replace(
25 /!\[([^\]]*)\]\(([^)]+)\)/g,
26 (_, alt: string, url: string) =>
27 `<img src="${escapeAttribute(url)}" alt="${alt}" />`,
28 );
29
30 result = result.replace(
31 /\[([^\]]+)\]\(([^)]+)\)/g,
32 (_, label: string, url: string) =>
33 `<a href="${escapeAttribute(url)}">${label}</a>`,
34 );
35
36 return result
37 .split(/(<[^>]+>)/g)
38 .map((part) =>
39 part.startsWith('<') ? part : applyInlineTextFormatting(part),
40 )
41 .join('');
42};
43
44/**
45 * Converts markdown to HTML using basic markdown syntax.

Callers 1

markdownToHtmlBasicFunction · 0.85

Calls 4

replaceMethod · 0.80
escapeHtmlFunction · 0.70
escapeAttributeFunction · 0.70

Tested by

no test coverage detected