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