Remove TOC replacer

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
Tilman Vatteroth 2020-08-30 00:00:22 +02:00 committed by mrdrogdrog
parent 33648f1645
commit 971421925a
2 changed files with 0 additions and 19 deletions

View file

@ -65,7 +65,6 @@ import { KatexReplacer } from './replace-components/katex/katex-replacer'
import { PdfReplacer } from './replace-components/pdf/pdf-replacer'
import { PossibleWiderReplacer } from './replace-components/possible-wider/possible-wider-replacer'
import { QuoteOptionsReplacer } from './replace-components/quote-options/quote-options-replacer'
import { TocReplacer } from './replace-components/toc/toc-replacer'
import { VimeoReplacer } from './replace-components/vimeo/vimeo-replacer'
import { YoutubeReplacer } from './replace-components/youtube/youtube-replacer'
@ -310,7 +309,6 @@ export const MarkdownRenderer: React.FC<MarkdownRendererProps> = ({ content, onM
new AsciinemaReplacer(),
new PdfReplacer(),
new ImageReplacer(),
new TocReplacer(),
new CsvReplacer(),
new FlowchartReplacer(),
new HighlightedCodeReplacer(),

View file

@ -1,17 +0,0 @@
import { DomElement } from 'domhandler'
import { ComponentReplacer, SubNodeConverter } from '../ComponentReplacer'
export class TocReplacer implements ComponentReplacer {
getReplacement (node: DomElement, index: number, subNodeConverter: SubNodeConverter): React.ReactElement | undefined {
if (node.name !== 'p' || node.children?.length !== 1) {
return
}
const possibleTocDiv = node.children[0]
if (possibleTocDiv.name === 'div' && possibleTocDiv.attribs && possibleTocDiv.attribs.class &&
possibleTocDiv.attribs.class === 'table-of-contents' && possibleTocDiv.children && possibleTocDiv.children.length === 1) {
const listElement = possibleTocDiv.children[0]
listElement.attribs = Object.assign(listElement.attribs || {}, { class: 'table-of-contents' })
return subNodeConverter(listElement, index)
}
}
}