MCPcopy Create free account
hub / github.com/Hashnode/starter-kit / extractMentions

Function extractMentions

packages/utils/renderer/markdownToHtml.ts:69–77  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

67};
68
69const extractMentions = (content: string) => {
70 const regex = /@<a([^>]*)href="@(\S+)"([^>]*)>((?:.(?!\<\/a\>))*.)<\/a>/g;
71
72 const replacer = (substring: string, ...args: any[]) => {
73 const [p1, p2, p3, p4] = args;
74 return `<a target='_blank' rel='noopener noreferrer' href="https://hashnode.com/@${p2}">${p4}</a>`;
75 };
76 return content.replace(regex, replacer);
77};
78
79const getSanitizedHTML = (content: string) => {
80 return sanitizeHtml(content, sanitizeHtmlOptions);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected