1
- import StateCore from 'markdown-it/lib/rules_core/state_core ' ;
2
- import Token from 'markdown-it/lib/token' ;
1
+ import type Core from 'markdown-it/lib/parser_core ' ;
2
+ import type Token from 'markdown-it/lib/token' ;
3
3
import { MarkdownItPluginCb } from './typings' ;
4
4
import { MatchTokenFunction , nestedCloseTokenIdxFactory as closeTokenFactory } from './utils' ;
5
5
@@ -24,7 +24,7 @@ const matchOpenToken = (tokens: Token[], i: number) => {
24
24
const findCloseTokenIdx = closeTokenFactory ( 'Cut' , matchOpenToken , matchCloseToken ) ;
25
25
26
26
const cut : MarkdownItPluginCb = ( md , { path, log} ) => {
27
- const plugin = ( state : StateCore ) => {
27
+ const plugin : Core . RuleCore = ( state ) => {
28
28
const tokens = state . tokens ;
29
29
let i = 0 ;
30
30
@@ -45,8 +45,15 @@ const cut: MarkdownItPluginCb = (md, {path, log}) => {
45
45
const titleOpen = new state . Token ( 'yfm_cut_title_open' , 'div' , 1 ) ;
46
46
titleOpen . attrSet ( 'class' , 'yfm-cut-title' ) ;
47
47
48
- const textTitle = new state . Token ( 'text' , '' , 0 ) ;
49
- textTitle . content = match [ 1 ] === undefined ? 'ad' : match [ 1 ] ;
48
+ const titleInline = new state . Token ( 'inline' , '' , 0 ) ;
49
+ titleInline . content = match [ 1 ] === undefined ? 'ad' : match [ 1 ] ;
50
+ titleInline . children = [ ] ;
51
+ state . md . inline . parse (
52
+ titleInline . content ,
53
+ state . md ,
54
+ state . env ,
55
+ titleInline . children ,
56
+ ) ;
50
57
51
58
const titleClose = new state . Token ( 'yfm_cut_title_close' , 'div' , - 1 ) ;
52
59
@@ -60,7 +67,7 @@ const cut: MarkdownItPluginCb = (md, {path, log}) => {
60
67
const insideTokens = [
61
68
newOpenToken ,
62
69
titleOpen ,
63
- textTitle ,
70
+ titleInline ,
64
71
titleClose ,
65
72
contentOpen ,
66
73
...tokens . slice ( i + 3 , closeTokenIdx ) ,
0 commit comments