MCPcopy
hub / github.com/streetwriters/notesnook / normalize

Function normalize

packages/core/src/utils/content-block.ts:45–59  ·  view source on GitHub ↗
(block: ContentBlock, links: InternalLinkWithOffset[])

Source from the content-addressed store, hash-verified

43}
44
45function normalize(block: ContentBlock, links: InternalLinkWithOffset[]) {
46 let diff = 0;
47 for (const link of links) {
48 link.start -= diff;
49 link.end -= diff;
50 block.content =
51 block.content.slice(0, link.start) +
52 link.text +
53 block.content.slice(link.end);
54 diff += link.end - link.start - link.text.length;
55
56 link.end = link.start + link.text.length;
57 }
58 return block;
59}
60
61export type TextSlice = { text: string; highlighted: boolean };
62export function highlightInternalLinks(

Callers 1

highlightInternalLinksFunction · 0.70

Calls 1

sliceMethod · 0.80

Tested by

no test coverage detected