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:
renovate[bot] 2022-01-22 09:57:50 +00:00 committed by GitHub
parent 241f4df42c
commit f1386b17d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 23 deletions

View file

@ -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)
})
}
}