File tree Expand file tree Collapse file tree 2 files changed +48
-8
lines changed Expand file tree Collapse file tree 2 files changed +48
-8
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ PageForge 支持网格布局语法。
159
159
```
160
160
161
161
::: grid cols-3 gap-6
162
- - __ 🚀 快速上手 __
162
+ - ### 🚀 快速上手
163
163
零配置,开箱即用,
164
164
支持 Markdown 所有基础语法。
165
165
@@ -168,6 +168,10 @@ PageForge 支持网格布局语法。
168
168
支持自定义扩展。
169
169
170
170
- ### 🎨 主题系统
171
- 提供多套主题,
172
- 支持自定义主题。
171
+ 提供多套主题,
172
+ 支持自定义主题。
173
+
174
+ ``` java
175
+ console. log(1 )
176
+ ```
173
177
:::
Original file line number Diff line number Diff line change @@ -54,25 +54,61 @@ const PageForgeGridExtension = {
54
54
const content = src . slice ( headerLength , endIndex ) ;
55
55
const raw = src . slice ( 0 , endIndex + 4 ) ;
56
56
57
- const items = content . split ( / \n (? = \s * [ - * + ] | \s * \d + \. ) / g)
58
- . map ( item => item . trim ( ) )
57
+ // 分割列表项并保持原始格式
58
+ const items = [ ] ;
59
+ let currentItem = '' ;
60
+ let inItem = false ;
61
+
62
+ content . split ( '\n' ) . forEach ( line => {
63
+ const listMarkerMatch = line . match ( / ^ ( \s * ) ( [ - * + ] | \d + \. ) \s / ) ;
64
+
65
+ if ( listMarkerMatch ) {
66
+ // 如果已经在处理一个项目,保存它
67
+ if ( currentItem ) {
68
+ items . push ( currentItem . trim ( ) ) ;
69
+ }
70
+ // 开始新的项目,移除列表标记
71
+ currentItem = line . slice ( listMarkerMatch [ 0 ] . length ) ;
72
+ inItem = true ;
73
+ }
74
+ else if ( inItem ) {
75
+ // 对于项目的后续行,直接添加
76
+ currentItem += '\n' + line ;
77
+ }
78
+ } ) ;
79
+
80
+ // 添加最后一个项目
81
+ if ( currentItem ) {
82
+ items . push ( currentItem . trim ( ) ) ;
83
+ }
84
+
85
+ // 为每个项目创建 tokens
86
+ const processedItems = items
59
87
. filter ( item => item )
60
88
. map ( item => {
61
- return item . replace ( / ^ [ - * + ] \s + | ^ \d + \. \s + / , '' ) ;
89
+ const itemTokens = this . lexer . blockTokens ( item , [ ] ) ;
90
+ return {
91
+ content : item ,
92
+ tokens : itemTokens
93
+ } ;
62
94
} ) ;
63
95
64
96
return {
65
97
type : 'pageforgeGrid' ,
66
98
raw,
67
- content : items ,
99
+ items : processedItems ,
68
100
options : gridOptions ,
69
101
tokens : [ ]
70
102
} ;
71
103
} ,
72
104
73
105
renderer ( token ) {
106
+ const processedItems = token . items . map ( item => {
107
+ return this . parser . parse ( item . tokens ) ;
108
+ } ) ;
109
+
74
110
return loadComponent ( 'grid' , {
75
- content : token . content ,
111
+ content : processedItems ,
76
112
options : token . options ,
77
113
config : config . feature ?. grid ?. options || { }
78
114
} ) ;
You can’t perform that action at this time.
0 commit comments