hedgedoc/src/components/markdown-renderer/markdown-extension/linkify-fix-markdown-extension.ts
Tilman Vatteroth 8a8bacc0aa
Introduce Markdown extensions (#1614)
* Introduce markdown extensions

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
2021-11-15 17:04:49 +01:00

22 lines
636 B
TypeScript

/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { MarkdownExtension } from './markdown-extension'
import linkify from 'markdown-it/lib/rules_core/linkify'
import type MarkdownIt from 'markdown-it'
export class LinkifyFixMarkdownExtension extends MarkdownExtension {
public configureMarkdownItPost(markdownIt: MarkdownIt): void {
markdownIt.core.ruler.push('linkify', (state) => {
try {
state.md.options.linkify = true
return linkify(state)
} finally {
state.md.options.linkify = false
}
})
}
}