(block: ContentBlock, links: InternalLinkWithOffset[])
| 43 | } |
| 44 | |
| 45 | function 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 | |
| 61 | export type TextSlice = { text: string; highlighted: boolean }; |
| 62 | export function highlightInternalLinks( |
no test coverage detected