diff options
Diffstat (limited to 'src/compiler/markdown/micromark-collect-headers.ts')
-rw-r--r-- | src/compiler/markdown/micromark-collect-headers.ts | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/compiler/markdown/micromark-collect-headers.ts b/src/compiler/markdown/micromark-collect-headers.ts deleted file mode 100644 index 69781231a..000000000 --- a/src/compiler/markdown/micromark-collect-headers.ts +++ /dev/null @@ -1,38 +0,0 @@ -import slugger from 'github-slugger'; - -/** - * Create Markdown Headers Collector - * NOTE: micromark has terrible TS types. Instead of fighting with the - * limited/broken TS types that they ship, we just reach for our good friend, "any". - */ -export function createMarkdownHeadersCollector() { - const headers: any[] = []; - let currentHeader: any; - return { - headers, - headersExtension: { - enter: { - atxHeading(node: any) { - currentHeader = {}; - headers.push(currentHeader); - this.buffer(); - }, - atxHeadingSequence(node: any) { - currentHeader.depth = this.sliceSerialize(node).length; - }, - atxHeadingText(node: any) { - currentHeader.text = this.sliceSerialize(node); - }, - } as any, - exit: { - atxHeading(node: any) { - currentHeader.slug = slugger.slug(currentHeader.text); - this.resume(); - this.tag(`<h${currentHeader.depth} id="${currentHeader.slug}">`); - this.raw(currentHeader.text); - this.tag(`</h${currentHeader.depth}>`); - }, - } as any, - } as any, - }; -} |