hedgedoc/frontend/src/components/markdown-renderer/extensions/headline-anchors-markdown-extension.ts
Tilman Vatteroth f78fd69bf4 fix: replace bootstrap icon html with utf-8 icon
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
2023-03-19 21:02:19 +01:00

24 lines
739 B
TypeScript

/*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { MarkdownRendererExtension } from './base/markdown-renderer-extension'
import type MarkdownIt from 'markdown-it'
import anchor from 'markdown-it-anchor'
/**
* Adds headline anchors to the markdown rendering.
*/
export class HeadlineAnchorsMarkdownExtension extends MarkdownRendererExtension {
public configureMarkdownIt(markdownIt: MarkdownIt): void {
anchor(markdownIt, {
permalink: anchor.permalink.ariaHidden({
symbol: '🔗',
class: 'heading-anchor text-dark',
renderHref: (slug: string): string => `#${slug}`,
placement: 'before'
})
})
}
}