mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 07:04:45 -04:00

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Erik Michelson <github@erik.michelson.eu>
26 lines
820 B
TypeScript
26 lines
820 B
TypeScript
import MarkdownIt from 'markdown-it'
|
|
|
|
export abstract class MarkdownItConfigurator {
|
|
protected configurations:MarkdownIt.PluginSimple[] = [];
|
|
protected postConfigurations:MarkdownIt.PluginSimple[] = [];
|
|
|
|
protected abstract configure(markdownIt: MarkdownIt): void;
|
|
|
|
public pushConfig (plugin: MarkdownIt.PluginSimple): this {
|
|
this.configurations.push(plugin)
|
|
return this
|
|
}
|
|
|
|
public buildConfiguredMarkdownIt (): MarkdownIt {
|
|
const markdownIt = new MarkdownIt('default', {
|
|
html: true,
|
|
breaks: true,
|
|
langPrefix: '',
|
|
typographer: true
|
|
})
|
|
this.configure(markdownIt)
|
|
this.configurations.forEach((configuration) => markdownIt.use(configuration))
|
|
this.postConfigurations.forEach((postConfiguration) => markdownIt.use(postConfiguration))
|
|
return markdownIt
|
|
}
|
|
}
|