mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 02:05:21 -04:00
Added TOC and anchors for headings (#243)
* Added TOC support and anchors for headings * Moved @types/markdown-it-anchor from devDependencies to dependencies * Add subnode renderer Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Added node-replacer for toc generation ul lists may not be nested inside a p element. Therefore replaces this replacer every p that has a div.table-of-contents inside of it with the div directly. * Add index to replacer function Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Add TOC to example code Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Remove unused import Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Removed unnecessary div wrapper of toc * Fixed toc-renderer Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
cb2ea5fa6e
commit
fd378cf89b
12 changed files with 93 additions and 13 deletions
6
src/external-types/markdown-it-table-of-contents/index.d.ts
vendored
Normal file
6
src/external-types/markdown-it-table-of-contents/index.d.ts
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
declare module 'markdown-it-table-of-contents' {
|
||||
import MarkdownIt from 'markdown-it/lib'
|
||||
import { TOCOptions } from './interface'
|
||||
const markdownItTableOfContents: MarkdownIt.PluginWithOptions<TOCOptions>
|
||||
export = markdownItTableOfContents
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
export interface TOCOptions {
|
||||
includeLevel: number[]
|
||||
containerClass: string
|
||||
slugify: (s: string) => string
|
||||
markerPattern: RegExp
|
||||
listType: 'ul' | 'ol'
|
||||
format: (headingAsString: string) => string
|
||||
forceFullToc: boolean
|
||||
containerHeaderHtml: string
|
||||
containerFooterHtml: string
|
||||
transformLink: (link: string) => string
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue