Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/syntax/inline-props.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type MarkdownIt from 'markdown-it'
import type Renderer from 'markdown-it/lib/renderer.mjs'
import type Token from 'markdown-it/lib/token.mjs'

import TokenClass from 'markdown-it/lib/token.mjs'
import { searchProps } from '../parse/props'

export interface MdcInlinePropsOptions {
Expand Down Expand Up @@ -147,9 +147,12 @@ function wrapRenderInline(renderInline: Renderer['renderInline']): Renderer['ren

// If the previous token is a text token, we need to wrap it in a span
if (!prev.tag && prev.type === 'text') {
prev = new TokenClass('mdc_inline_span', 'span', 1)
// Use the token's own class instead of importing `markdown-it/lib/token.mjs`,
// which markdown-it v15 no longer exposes via its `exports` map.
const TokenCtor = token.constructor as typeof Token
prev = new TokenCtor('mdc_inline_span', 'span', 1)
tokens.splice(index - 1, 0, prev)
const close = new TokenClass('mdc_inline_span', 'span', -1)
const close = new TokenCtor('mdc_inline_span', 'span', -1)
tokens.splice(index + 2, 0, close)
}
// If the previous token is a closing tag, we need to find the matching opening tag
Expand Down
Loading