mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2026-08-07 07:14:49 +00:00
feat: import markdown-it-plugins from https://github.com/hedgedoc/markdown-it-plugins
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
import { TocAst } from './toc-ast.js'
|
||||
|
||||
export type TocOptions = {
|
||||
slugify: (name: string, index: number) => string
|
||||
uniqueSlugStartIndex: number
|
||||
containerClass: string
|
||||
containerId: string
|
||||
listClass: string
|
||||
itemClass: string
|
||||
linkClass: string
|
||||
level: number | number[]
|
||||
listType: 'ol' | 'ul'
|
||||
format?: (name: string) => string
|
||||
callback?: (ast: TocAst) => void
|
||||
allowedTokenTypes: string[]
|
||||
}
|
||||
|
||||
function defaultSlugify(name: string) {
|
||||
return encodeURIComponent(String(name).trim().toLowerCase().replace(/\s+/g, '-'))
|
||||
}
|
||||
|
||||
/**
|
||||
* The default options for the toc plugin.
|
||||
*/
|
||||
export const defaultOptions: TocOptions = {
|
||||
uniqueSlugStartIndex: 0,
|
||||
containerClass: 'table-of-contents',
|
||||
containerId: '',
|
||||
listClass: '',
|
||||
itemClass: '',
|
||||
linkClass: '',
|
||||
level: 1,
|
||||
listType: 'ol',
|
||||
allowedTokenTypes: ['text', 'code_inline'],
|
||||
slugify: defaultSlugify
|
||||
}
|
||||
Reference in New Issue
Block a user