mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-09 13:51:57 -04:00
test: migrate markdown-it-plugin tests
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
71e0671cc0
commit
727744b2a4
27 changed files with 40 additions and 38 deletions
|
@ -6,7 +6,7 @@
|
|||
import { parseCodeBlockParameters } from './code-block-parameters'
|
||||
import { Optional } from '@mrdrogdrog/optional'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
import type { RuleCore } from 'markdown-it/lib/parser_core'
|
||||
import type { RuleCore } from 'markdown-it/lib/parser_core.mjs'
|
||||
|
||||
const ruleName = 'code-highlighter'
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { LinemarkerMarkdownExtension } from './linemarker-markdown-extension'
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import Token from 'markdown-it/lib/token'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
import Token from 'markdown-it/lib/token.mjs'
|
||||
|
||||
export interface LineMarkers {
|
||||
startLine: number
|
||||
|
|
|
@ -17,7 +17,8 @@ export class LinkifyFixMarkdownExtension extends MarkdownRendererExtension {
|
|||
markdownIt.core.ruler.push('linkify', (state) => {
|
||||
try {
|
||||
state.md.options.linkify = true
|
||||
return linkify(state)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
linkify(state)
|
||||
} finally {
|
||||
state.md.options.linkify = false
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type StateCore from 'markdown-it/lib/rules_core/state_core'
|
||||
import Token from 'markdown-it/lib/token'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
import type StateCore from 'markdown-it/lib/rules_core/state_core.mjs'
|
||||
import Token from 'markdown-it/lib/token.mjs'
|
||||
|
||||
/**
|
||||
* This functions adds a 'section close' token at currentTokenIndex in the state's token array,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { MarkdownRendererExtension } from '../../extensions/_base-classes/markdown-renderer-extension'
|
||||
import MarkdownIt from 'markdown-it/lib'
|
||||
import MarkdownIt from 'markdown-it'
|
||||
import { useMemo } from 'react'
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,7 +9,7 @@ import type { ComponentReplacer } from '../../replace-components/component-repla
|
|||
import { TestNodeProcessor } from './test-node-processor'
|
||||
import { TestReplacer } from './test-replacer'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
import Token from 'markdown-it/lib/token'
|
||||
import Token from 'markdown-it/lib/token.mjs'
|
||||
|
||||
export class TestMarkdownRendererExtension extends MarkdownRendererExtension {
|
||||
constructor(private doAfterCallback: () => void) {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
import { MarkdownRendererExtension } from '../../../components/markdown-renderer/extensions/_base-classes/markdown-renderer-extension'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
import markdownItContainer from 'markdown-it-container'
|
||||
import type Renderer from 'markdown-it/lib/renderer'
|
||||
import type Token from 'markdown-it/lib/token'
|
||||
import type Renderer from 'markdown-it/lib/renderer.mjs'
|
||||
import type Token from 'markdown-it/lib/token.mjs'
|
||||
|
||||
export const alertLevels = ['success', 'danger', 'info', 'warning']
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
import type { BootstrapIconName } from '../../../components/common/icons/bootstrap-icons'
|
||||
import { BlockquoteExtraTagMarkdownExtension } from './blockquote-extra-tag-markdown-extension'
|
||||
import { Optional } from '@mrdrogdrog/optional'
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type { RuleInline } from 'markdown-it/lib/parser_inline'
|
||||
import type StateInline from 'markdown-it/lib/rules_inline/state_inline'
|
||||
import type Token from 'markdown-it/lib/token'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
import type StateInline from 'markdown-it/lib/rules_inline/state_inline.mjs'
|
||||
import type Token from 'markdown-it/lib/token.mjs'
|
||||
import type { RuleInline } from 'markdown-it/lib/parser_inline.mjs'
|
||||
|
||||
export interface QuoteExtraTagValues {
|
||||
labelStartIndex: number
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { ImagePlaceholderMarkdownExtension } from './image-placeholder-markdown-extension'
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
|
||||
/**
|
||||
* A {@link MarkdownIt.PluginSimple markdown it plugin} that adds the line number of the markdown code to every placeholder image.
|
||||
|
|
|
@ -7,7 +7,7 @@ import { MarkdownRendererExtension } from '../../../components/markdown-renderer
|
|||
import type { ComponentReplacer } from '../../../components/markdown-renderer/replace-components/component-replacer'
|
||||
import { addLineToPlaceholderImageTags } from './add-line-to-placeholder-image-tags'
|
||||
import { ImagePlaceholderReplacer } from './image-placeholder-replacer'
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
|
||||
/**
|
||||
* Adds support for {@link ImagePlaceholder}.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import type { RegexOptions } from '../../../external-types/markdown-it-regex/interface'
|
||||
import markdownItRegex from 'markdown-it-regex'
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
|
||||
export const legacyPdfRegex = /^{%pdf\s+(\S*)\s*%}$/
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import type { RegexOptions } from '../../../external-types/markdown-it-regex/interface'
|
||||
import markdownItRegex from 'markdown-it-regex'
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
|
||||
export const legacySlideshareRegex = /^{%slideshare\s+(\w+\/[\w-]+)\s*%}$/
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import type { RegexOptions } from '../../../external-types/markdown-it-regex/interface'
|
||||
import markdownItRegex from 'markdown-it-regex'
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
|
||||
export const legacySpeakerdeckRegex = /^{%speakerdeck\s+(\w+\/[\w-]+)\s*%}$/
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
import { MarkdownRendererExtension } from '../../../components/markdown-renderer/extensions/_base-classes/markdown-renderer-extension'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
import markdownItContainer from 'markdown-it-container'
|
||||
import { escapeHtml } from 'markdown-it/lib/common/utils'
|
||||
import type Token from 'markdown-it/lib/token'
|
||||
import { escapeHtml } from 'markdown-it/lib/common/utils.mjs'
|
||||
import type Token from 'markdown-it/lib/token.mjs'
|
||||
|
||||
/**
|
||||
* Adds support for html spoiler tags.
|
||||
|
|
|
@ -8,7 +8,7 @@ import type { ComponentReplacer } from '../../../components/markdown-renderer/re
|
|||
import { CustomTagWithIdComponentReplacer } from '../../../components/markdown-renderer/replace-components/custom-tag-with-id-component-replacer'
|
||||
import { AsciinemaFrame } from './asciinema-frame'
|
||||
import { replaceAsciinemaLinkMarkdownItPlugin } from './replace-asciinema-link'
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
|
||||
/**
|
||||
* Adds asciinema embeddings to the markdown rendering by detecting asciinema.org links.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { replaceAsciinemaLinkMarkdownItPlugin } from './replace-asciinema-link'
|
||||
import MarkdownIt from 'markdown-it/lib'
|
||||
import MarkdownIt from 'markdown-it'
|
||||
|
||||
describe('Replace asciinema link', () => {
|
||||
let markdownIt: MarkdownIt
|
||||
|
|
|
@ -9,9 +9,10 @@ import { PlantumlNotConfiguredComponentReplacer } from './plantuml-not-configure
|
|||
import { Optional } from '@mrdrogdrog/optional'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
import plantuml from 'markdown-it-plantuml'
|
||||
import type { Options } from 'markdown-it/lib'
|
||||
import type Renderer from 'markdown-it/lib/renderer'
|
||||
import type Token from 'markdown-it/lib/token'
|
||||
import type { Options } from 'markdown-it'
|
||||
import type { RenderRule } from 'markdown-it/lib/renderer.mjs'
|
||||
import type Renderer from 'markdown-it/lib/renderer.mjs'
|
||||
import type Token from 'markdown-it/lib/token.mjs'
|
||||
|
||||
/**
|
||||
* Adds support for chart rendering using plantuml to the markdown rendering using code fences with "plantuml" as language.
|
||||
|
@ -24,7 +25,7 @@ export class PlantumlMarkdownExtension extends MarkdownRendererExtension {
|
|||
}
|
||||
|
||||
private plantumlError(markdownIt: MarkdownIt): void {
|
||||
const defaultRenderer: Renderer.RenderRule = markdownIt.renderer.rules.fence || (() => '')
|
||||
const defaultRenderer: RenderRule = markdownIt.renderer.rules.fence || (() => '')
|
||||
markdownIt.renderer.rules.fence = (tokens: Token[], idx: number, options: Options, env, slf: Renderer) => {
|
||||
return tokens[idx].info === 'plantuml'
|
||||
? '<plantuml-not-configured></plantuml-not-configured>'
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
declare module 'markdown-it-abbr' {
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
const markdownItAbbreviation: MarkdownIt.PluginSimple
|
||||
export = markdownItAbbreviation
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
declare module 'markdown-it-deflist' {
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
const markdownItDefinitionList: MarkdownIt.PluginSimple
|
||||
export = markdownItDefinitionList
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
declare module 'markdown-it-emoji' {
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
import type { EmojiOptions } from './interface'
|
||||
const markdownItEmoji: MarkdownIt.PluginWithOptions<EmojiOptions>
|
||||
const pluginVariations = {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
declare module 'markdown-it-footnote' {
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
const markdownItFootnote: MarkdownIt.PluginSimple
|
||||
export = markdownItFootnote
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
declare module 'markdown-it-ins' {
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
const markdownItInserted: MarkdownIt.PluginSimple
|
||||
export = markdownItInserted
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
declare module 'markdown-it-mark' {
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
const markdownItMark: MarkdownIt.PluginSimple
|
||||
export = markdownItMark
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
declare module 'markdown-it-mathjax' {
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
const markdownItMathJax: (MathJaxOptions) => MarkdownIt.PluginSimple
|
||||
export = markdownItMathJax
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
declare module 'markdown-it-regex' {
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
import type { RegexOptions } from './interface'
|
||||
const markdownItRegex: MarkdownIt.PluginWithOptions<RegexOptions>
|
||||
export = markdownItRegex
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
declare module 'markdown-it-sub' {
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
const markdownItSubscript: MarkdownIt.PluginSimple
|
||||
export = markdownItSubscript
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
declare module 'markdown-it-sup' {
|
||||
import type MarkdownIt from 'markdown-it/lib'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
const markdownItSuperscript: MarkdownIt.PluginSimple
|
||||
export = markdownItSuperscript
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue