mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-21 10:45:20 -04:00
Update definitely typed (#1789)
* Update definitely typed Signed-off-by: Renovate Bot <bot@renovateapp.com> * Fix type changes Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
241f4df42c
commit
f1386b17d4
3 changed files with 21 additions and 23 deletions
|
@ -13,24 +13,22 @@ import { escapeHtml } from 'markdown-it/lib/common/utils'
|
|||
export class SpoilerMarkdownExtension extends MarkdownExtension {
|
||||
private static readonly spoilerRegEx = /^spoiler\s+(.*)$/
|
||||
|
||||
private createSpoilerContainer(): (tokens: Token[], index: number) => void {
|
||||
return (tokens: Token[], index: number) => {
|
||||
const matches = SpoilerMarkdownExtension.spoilerRegEx.exec(tokens[index].info.trim())
|
||||
private static createSpoilerContainer(tokens: Token[], index: number): string {
|
||||
const matches = SpoilerMarkdownExtension.spoilerRegEx.exec(tokens[index].info.trim())
|
||||
|
||||
if (tokens[index].nesting === 1 && matches && matches[1]) {
|
||||
// opening tag
|
||||
return `<details><summary>${escapeHtml(matches[1])}</summary>`
|
||||
} else {
|
||||
// closing tag
|
||||
return '</details>\n'
|
||||
}
|
||||
if (tokens[index].nesting === 1 && matches && matches[1]) {
|
||||
// opening tag
|
||||
return `<details><summary>${escapeHtml(matches[1])}</summary>`
|
||||
} else {
|
||||
// closing tag
|
||||
return '</details>\n'
|
||||
}
|
||||
}
|
||||
|
||||
public configureMarkdownIt(markdownIt: MarkdownIt): void {
|
||||
markdownItContainer(markdownIt, 'spoiler', {
|
||||
validate: (params: string) => SpoilerMarkdownExtension.spoilerRegEx.test(params),
|
||||
render: () => this.createSpoilerContainer()
|
||||
render: SpoilerMarkdownExtension.createSpoilerContainer.bind(this)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue