markdown-it-any-block 3.2.11 → 3.3.1-beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mdit-any-block.cjs +219 -142
- package/dist/mdit-any-block.cjs.map +1 -1
- package/dist/mdit-any-block.js +219 -142
- package/dist/mdit-any-block.js.map +1 -1
- package/docs/README.md +1 -0
- package/index_mdit.ts +70 -87
- package/package.json +1 -1
package/dist/mdit-any-block.js
CHANGED
|
@@ -165,12 +165,14 @@ const ABReg = {
|
|
|
165
165
|
*/
|
|
166
166
|
// 有前缀版本(给选择器用)
|
|
167
167
|
reg_header: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5].*)\]):?(%%)?\s*$/,
|
|
168
|
+
// 向上检查标志的 头部选择器
|
|
169
|
+
reg_mdit_head: /^((\s|>\s|-\s|\*\s|\+\s)*)(::::*)\s?(.*)/,
|
|
168
170
|
//: /^\s*(>\s)*-\s(.*)$/
|
|
169
|
-
reg_code: /^((\s|>\s|-\s|\*\s|\+\s)*)(
|
|
170
|
-
//: /^\s*(>\s|-\s)*(
|
|
171
|
+
reg_code: /^((\s|>\s|-\s|\*\s|\+\s)*)(````*|~~~~*)(.*)/,
|
|
172
|
+
//: /^\s*(>\s|-\s)*(````*|~~~~*)(.*)$/
|
|
171
173
|
reg_quote: /^((\s|>\s|-\s|\*\s|\+\s)*)(>\s)(.*)/,
|
|
172
174
|
reg_list_noprefix: /^((\s)*)(-\s|\*\s|\+\s)(.*)/,
|
|
173
|
-
reg_code_noprefix: /^((\s)*)(
|
|
175
|
+
reg_code_noprefix: /^((\s)*)(````*|~~~~*)(.*)/,
|
|
174
176
|
reg_quote_noprefix: /^((\s)*)(>\s)(.*)/,
|
|
175
177
|
reg_heading_noprefix: /^((\s)*)(\#+\s)(.*)/,
|
|
176
178
|
reg_table_noprefix: /^((\s)*)(\|(.*)\|)/,
|
|
@@ -184,24 +186,24 @@ function autoABAlias(header, selectorName, content) {
|
|
|
184
186
|
if (!header.trimEnd().endsWith("|")) header = header + "|";
|
|
185
187
|
if (!header.trimStart().startsWith("|")) header = "|" + header;
|
|
186
188
|
if (selectorName == "mdit") {
|
|
187
|
-
header = "|:::
|
|
189
|
+
header = "|:::_140lne" + header.trimStart();
|
|
188
190
|
} else if (selectorName == "list" || ABReg.reg_list_noprefix.test(content.trimStart())) {
|
|
189
|
-
header = "|
|
|
191
|
+
header = "|list_140lne" + header;
|
|
190
192
|
} else if (selectorName == "heading" || ABReg.reg_heading_noprefix.test(content.trimStart())) {
|
|
191
|
-
header = "|
|
|
193
|
+
header = "|heading_140lne" + header;
|
|
192
194
|
} else if (selectorName == "code" || ABReg.reg_code_noprefix.test(content.trimStart())) {
|
|
193
|
-
header = "|
|
|
195
|
+
header = "|code_140lne" + header;
|
|
194
196
|
} else if (selectorName == "quote" || ABReg.reg_quote_noprefix.test(content.trimStart())) {
|
|
195
|
-
header = "|
|
|
197
|
+
header = "|quote_140lne" + header;
|
|
196
198
|
} else if (selectorName == "table" || ABReg.reg_table_noprefix.test(content.trimStart())) {
|
|
197
|
-
header = "|
|
|
199
|
+
header = "|table_140lne" + header;
|
|
198
200
|
}
|
|
199
201
|
for (const item of ABAlias_json) {
|
|
200
202
|
header = header.replace(item.regex, item.replacement);
|
|
201
203
|
}
|
|
202
204
|
for (const item of ABAlias_json_withSub) {
|
|
203
205
|
header = header.replace(item.regex, (match, ...groups) => {
|
|
204
|
-
return item.replacement.replace(/\$(\d+)/g, (_, number) => groups[number - 1]);
|
|
206
|
+
return item.replacement.replace(/\$(\d+)/g, (_, number) => groups[number - 1] ?? "");
|
|
205
207
|
});
|
|
206
208
|
}
|
|
207
209
|
for (const item of ABAlias_json_end) {
|
|
@@ -210,73 +212,93 @@ function autoABAlias(header, selectorName, content) {
|
|
|
210
212
|
return header;
|
|
211
213
|
}
|
|
212
214
|
const ABAlias_json_withSub = [
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
//
|
|
215
|
+
// 分下类,排下序
|
|
216
|
+
// `gfm` 就支持五种: note, tip, important, warning, caution
|
|
217
|
+
// `vuepress` 比gfm多了个: info
|
|
218
|
+
// `obsidian` 不完全是gfm超集,其important和tip一样,caution和warning一样
|
|
219
|
+
// note
|
|
220
|
+
// abstract, summary, tldr
|
|
221
|
+
// info
|
|
222
|
+
// todo
|
|
223
|
+
// tip. hint, Important
|
|
224
|
+
// succcess, check, done
|
|
225
|
+
// question, help, faq
|
|
226
|
+
// warning, caution, attention
|
|
227
|
+
// failure, fail, missing
|
|
228
|
+
// danger, error
|
|
229
|
+
// bug
|
|
230
|
+
// example
|
|
231
|
+
// quote, cite
|
|
232
|
+
// `其他` 避免错字, 我之前加过 warn, tips。后面又删了
|
|
233
|
+
{ regex: /\|(note|warning|caution|attention|error|info|danger|tip|hint|example|abstract|summary|tldr|quote|cite|todo|success|check|done|important|question|help|faq|failure|fail|missing|bug)([+-]?)(\s.*)?\|/, replacement: "|add([!$1]$2$3)|addQuote|" },
|
|
234
|
+
{ regex: /\|callout (\S+)([+-]?)\s?(.*)\|/, replacement: "|add([!$1]$2 $3)|addQuote|" }
|
|
235
|
+
// 注意避免和原上/上面的callout语法冲突,以及自身递归
|
|
216
236
|
];
|
|
217
237
|
const ABAlias_json_mdit = [
|
|
218
|
-
{ regex: /\|:::
|
|
219
|
-
{ regex: "|:::
|
|
220
|
-
{ regex: "|:::
|
|
221
|
-
{ regex: /\|:::
|
|
222
|
-
{ regex: /\|:::
|
|
223
|
-
{ regex: /\|:::
|
|
238
|
+
{ regex: /\|:::_140lne\|(2?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
|
|
239
|
+
{ regex: "|:::_140lne|demo|", replacement: "|mditDemo|" },
|
|
240
|
+
{ regex: "|:::_140lne|abDemo|", replacement: "|mditABDemo|" },
|
|
241
|
+
{ regex: /\|:::_140lne\|(2?col|分栏)\|/, replacement: "|mditCol|" },
|
|
242
|
+
{ regex: /\|:::_140lne\|(2?card|卡片)\|/, replacement: "|mditCard|" },
|
|
243
|
+
{ regex: /\|:::_140lne\|(2?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" }
|
|
224
244
|
];
|
|
225
245
|
const ABAlias_json_title = [
|
|
226
246
|
{ regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" },
|
|
227
247
|
// title - list&title
|
|
228
|
-
{ regex: /\|
|
|
229
|
-
{ regex: /\|
|
|
230
|
-
{ regex: /\|
|
|
231
|
-
{ regex: /\|
|
|
232
|
-
{ regex: /\|
|
|
248
|
+
{ regex: /\|heading_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|" },
|
|
249
|
+
{ regex: /\|heading_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|" },
|
|
250
|
+
{ regex: /\|heading_140lne\|2?(col|分栏)\||\|title2col\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-col)|" },
|
|
251
|
+
{ regex: /\|heading_140lne\|2?(card|卡片)\||\|title2card\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|" },
|
|
252
|
+
{ regex: /\|heading_140lne\|2?(nodes?|节点)\||\|(title2node|title2abMindmap)\|/, replacement: "|title2listdata|listdata2strict|listdata2nodes|" },
|
|
233
253
|
// list - 多叉多层树
|
|
234
|
-
{ regex: /\|
|
|
235
|
-
{ regex: /\|
|
|
236
|
-
{ regex: /\|
|
|
237
|
-
{ regex: /\|
|
|
238
|
-
{ regex: /\|
|
|
239
|
-
{ regex: /\|
|
|
254
|
+
{ regex: /\|heading_140lne\|2?(mermaid|flow|流程图)\|/, replacement: "|title2list|list2mermaid|" },
|
|
255
|
+
{ regex: /\|heading_140lne\|2?(mehrmaid|mdmermaid)\|/, replacement: "|title2list|list2mehrmaidText|code(mehrmaid)|" },
|
|
256
|
+
{ regex: /\|heading_140lne\|2?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|title2list|list2pumlMindmap|" },
|
|
257
|
+
{ regex: /\|heading_140lne\|2?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|title2list|list2markmap|" },
|
|
258
|
+
{ regex: /\|heading_140lne\|2?(wbs|(工作)?分解(图|结构))\|/, replacement: "|title2list|list2pumlWBS|" },
|
|
259
|
+
{ regex: /\|heading_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|title2list|list2table|" },
|
|
240
260
|
// list - lt树 (属于多层一叉树)
|
|
241
|
-
{ regex: /\|
|
|
242
|
-
{ regex: /\|
|
|
243
|
-
{ regex: /\|
|
|
261
|
+
{ regex: /\|heading_140lne\|2?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|title2list|list2lt|" },
|
|
262
|
+
{ regex: /\|heading_140lne\|2?(list|列表)\|/, replacement: "|title2list|list2lt|addClass(ab-listtable-likelist)|" },
|
|
263
|
+
{ regex: /\|heading_140lne\|2?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|title2list|list2dt|" },
|
|
244
264
|
// list - 二层树
|
|
245
|
-
{ regex: /\|
|
|
265
|
+
{ regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" }
|
|
246
266
|
];
|
|
247
267
|
const ABAlias_json_list = [
|
|
248
268
|
{ regex: "|listXinline|", replacement: "|list2listdata|listdata2list|" },
|
|
249
269
|
// list - list&title
|
|
250
|
-
{ regex: /\|
|
|
251
|
-
{ regex: /\|
|
|
252
|
-
{ regex: /\|
|
|
253
|
-
{ regex: /\|
|
|
254
|
-
{ regex: /\|
|
|
270
|
+
{ regex: /\|list_140lne\|2?(timeline|时间线)\|/, replacement: "|list2timeline|" },
|
|
271
|
+
{ regex: /\|list_140lne\|2?(tabs?|标签页?)\||\|list2tabs?\|/, replacement: "|list2c2listdata|c2listdata2tab|" },
|
|
272
|
+
{ regex: /\|list_140lne\|2?(col|分栏)\||\|list2col\|/, replacement: "|list2c2listdata|c2listdata2items|addClass(ab-col)|" },
|
|
273
|
+
{ regex: /\|list_140lne\|2?(card|卡片)\||\|list2card\|/, replacement: "|list2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|" },
|
|
274
|
+
{ regex: /\|list_140lne\|2?(nodes?|节点)\||\|(list2node|list2abMindmap)\|/, replacement: "|list2listdata|listdata2strict|listdata2nodes|" },
|
|
255
275
|
// list - 多叉多层树
|
|
256
|
-
{ regex: /\|
|
|
257
|
-
{ regex: /\|
|
|
258
|
-
{ regex: /\|
|
|
259
|
-
{ regex: /\|
|
|
260
|
-
{ regex: /\|
|
|
261
|
-
{ regex: /\|
|
|
276
|
+
{ regex: /\|list_140lne\|2?(mermaid|flow|流程图)\|/, replacement: "|list2mermaid|" },
|
|
277
|
+
{ regex: /\|list_140lne\|2?(mehrmaid|mdmermaid)\|/, replacement: "|list2mehrmaidText|code(mehrmaid)|" },
|
|
278
|
+
{ regex: /\|list_140lne\|2?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|list2pumlMindmap|" },
|
|
279
|
+
{ regex: /\|list_140lne\|2?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|list2markmap|" },
|
|
280
|
+
{ regex: /\|list_140lne\|2?(wbs|(工作)?分解(图|结构))\|/, replacement: "|list2pumlWBS|" },
|
|
281
|
+
{ regex: /\|list_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|list2table|" },
|
|
262
282
|
// list - lt树 (属于多层一叉树)
|
|
263
|
-
{ regex: /\|
|
|
264
|
-
{ regex: /\|
|
|
265
|
-
{ regex: /\|
|
|
283
|
+
{ regex: /\|list_140lne\|2?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|list2lt|" },
|
|
284
|
+
{ regex: /\|list_140lne\|2?(list|列表)\|/, replacement: "|list2lt|addClass(ab-listtable-likelist)|" },
|
|
285
|
+
{ regex: /\|list_140lne\|2?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|list2dt|" },
|
|
266
286
|
// list - 二层树
|
|
267
|
-
{ regex: /\|
|
|
287
|
+
{ regex: /\|list_140lne\|(fakeList|仿列表)\|/, replacement: "|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" }
|
|
268
288
|
];
|
|
269
289
|
const ABAlias_json_code = [
|
|
270
|
-
{ regex: "|
|
|
271
|
-
{ regex: "|
|
|
290
|
+
{ regex: "|code_140lne|X|", replacement: "|xCode|" },
|
|
291
|
+
{ regex: "|code_140lne|x|", replacement: "|xCode|" },
|
|
292
|
+
{ regex: "|code2list|", replacement: "|xCode|region2indent|addList|" },
|
|
272
293
|
{ regex: "|list2code|", replacement: "|xList|code(js)|" }
|
|
273
294
|
];
|
|
274
295
|
const ABAlias_json_quote = [
|
|
275
|
-
{
|
|
296
|
+
// {regex: "|quote_140lne|X|", replacement: "|xQuote|"},
|
|
297
|
+
// {regex: "|quote_140lne|x|", replacement: "|xQuote|"},
|
|
276
298
|
];
|
|
277
299
|
const ABAlias_json_table = [];
|
|
278
300
|
const ABAlias_json_general = [
|
|
279
|
-
{ regex: "|黑幕|", replacement: "|
|
|
301
|
+
{ regex: "|黑幕|", replacement: "|addClass(ab-deco-heimu)|" },
|
|
280
302
|
{ regex: "|折叠|", replacement: "|fold|" },
|
|
281
303
|
{ regex: "|滚动|", replacement: "|scroll|" },
|
|
282
304
|
{ regex: "|超出折叠|", replacement: "|overfold|" },
|
|
@@ -332,12 +354,12 @@ let ABAlias_json = [
|
|
|
332
354
|
// 设置决定是否停用
|
|
333
355
|
];
|
|
334
356
|
const ABAlias_json_end = [
|
|
335
|
-
{ regex: "|:::
|
|
336
|
-
{ regex: "|
|
|
337
|
-
{ regex: "|
|
|
338
|
-
{ regex: "|
|
|
339
|
-
{ regex: "|
|
|
340
|
-
{ regex: "|
|
|
357
|
+
{ regex: "|:::_140lne", replacement: "" },
|
|
358
|
+
{ regex: "|heading_140lne", replacement: "" },
|
|
359
|
+
{ regex: "|list_140lne", replacement: "" },
|
|
360
|
+
{ regex: "|code_140lne", replacement: "" },
|
|
361
|
+
{ regex: "|qutoe_140lne", replacement: "" },
|
|
362
|
+
{ regex: "|table_140lne", replacement: "" }
|
|
341
363
|
];
|
|
342
364
|
class ABConvertManager {
|
|
343
365
|
/// 构造函数
|
|
@@ -513,9 +535,9 @@ class ABConvertManager {
|
|
|
513
535
|
}
|
|
514
536
|
}
|
|
515
537
|
ABConvert.factory({
|
|
516
|
-
id: "
|
|
538
|
+
id: "addQuote",
|
|
517
539
|
name: "增加引用块",
|
|
518
|
-
match:
|
|
540
|
+
match: "addQuote",
|
|
519
541
|
detail: "在文本的每行前面加上 `> `",
|
|
520
542
|
process_param: ABConvert_IOEnum.text,
|
|
521
543
|
process_return: ABConvert_IOEnum.text,
|
|
@@ -526,23 +548,24 @@ ABConvert.factory({
|
|
|
526
548
|
}
|
|
527
549
|
});
|
|
528
550
|
ABConvert.factory({
|
|
529
|
-
id: "
|
|
551
|
+
id: "addCode",
|
|
530
552
|
name: "增加代码块",
|
|
531
|
-
match: /^code(\((.*)\))?$/,
|
|
553
|
+
match: /^(addCode|code)(\((.*)\))?$/,
|
|
532
554
|
default: "code()",
|
|
533
555
|
detail: "在文本的前后均加上一行代码块围栏。不加`()`表示用原文本的第一行作为代码类型,括号类型为空表示代码类型为空",
|
|
534
556
|
process_param: ABConvert_IOEnum.text,
|
|
535
557
|
process_return: ABConvert_IOEnum.text,
|
|
536
558
|
process: (el, header, content) => {
|
|
537
|
-
let matchs = header.match(/^code(\((.*)\))?$/);
|
|
559
|
+
let matchs = header.match(/^(addCode|code)(\((.*)\))?$/);
|
|
538
560
|
if (!matchs) return content;
|
|
539
|
-
if (matchs[
|
|
561
|
+
if (matchs[2]) content = matchs[3] + "\n" + content;
|
|
540
562
|
return "``````" + content + "\n``````";
|
|
541
563
|
}
|
|
542
564
|
});
|
|
543
|
-
const
|
|
544
|
-
id: "
|
|
565
|
+
const abc_xQuote = ABConvert.factory({
|
|
566
|
+
id: "xQuote",
|
|
545
567
|
name: "去除引用块",
|
|
568
|
+
match: /^(xQuote|Xquote)$/,
|
|
546
569
|
detail: "在文本的每行前面删除 `> `",
|
|
547
570
|
process_param: ABConvert_IOEnum.text,
|
|
548
571
|
process_return: ABConvert_IOEnum.text,
|
|
@@ -552,20 +575,20 @@ const abc_Xquote = ABConvert.factory({
|
|
|
552
575
|
}).join("\n");
|
|
553
576
|
}
|
|
554
577
|
});
|
|
555
|
-
const
|
|
556
|
-
id: "
|
|
578
|
+
const abc_xCode = ABConvert.factory({
|
|
579
|
+
id: "xCode",
|
|
557
580
|
name: "去除代码块",
|
|
558
|
-
match: /^Xcode(\((true|false|)\))?$/,
|
|
559
|
-
default: "
|
|
581
|
+
match: /^(xCode|Xcode)(\((true|false|)\))?$/,
|
|
582
|
+
default: "xCode(true)",
|
|
560
583
|
detail: "参数为是否移除代码类型, Xcode默认为false, Xcode默认为true。记法: code|Xcode 或 code()|Xcode()内容不变",
|
|
561
584
|
process_param: ABConvert_IOEnum.text,
|
|
562
585
|
process_return: ABConvert_IOEnum.text,
|
|
563
586
|
process: (el, header, content) => {
|
|
564
|
-
let matchs = header.match(/^Xcode(\((true|false|)\))?$/);
|
|
587
|
+
let matchs = header.match(/^(xCode|Xcode)(\((true|false|)\))?$/);
|
|
565
588
|
if (!matchs) return content;
|
|
566
589
|
let remove_flag;
|
|
567
|
-
if (matchs[
|
|
568
|
-
else remove_flag = matchs[
|
|
590
|
+
if (matchs[2] == "") remove_flag = false;
|
|
591
|
+
else remove_flag = matchs[3] != "false";
|
|
569
592
|
let list_content = content.split("\n");
|
|
570
593
|
let code_flag = "";
|
|
571
594
|
let line_start = -1;
|
|
@@ -594,8 +617,9 @@ const abc_Xcode = ABConvert.factory({
|
|
|
594
617
|
}
|
|
595
618
|
});
|
|
596
619
|
ABConvert.factory({
|
|
597
|
-
id: "
|
|
620
|
+
id: "x",
|
|
598
621
|
name: "去除代码或引用块",
|
|
622
|
+
match: /^(x|X)$/,
|
|
599
623
|
process_param: ABConvert_IOEnum.text,
|
|
600
624
|
process_return: ABConvert_IOEnum.text,
|
|
601
625
|
process: (el, header, content) => {
|
|
@@ -609,8 +633,8 @@ ABConvert.factory({
|
|
|
609
633
|
break;
|
|
610
634
|
}
|
|
611
635
|
}
|
|
612
|
-
if (flag == "code") return
|
|
613
|
-
else if (flag == "quote") return
|
|
636
|
+
if (flag == "code") return abc_xCode.process(el, header, content);
|
|
637
|
+
else if (flag == "quote") return abc_xQuote.process(el, header, content);
|
|
614
638
|
return content;
|
|
615
639
|
}
|
|
616
640
|
});
|
|
@@ -751,6 +775,34 @@ ABConvert.factory({
|
|
|
751
775
|
return newContent.slice(1);
|
|
752
776
|
}
|
|
753
777
|
});
|
|
778
|
+
ABConvert.factory({
|
|
779
|
+
id: "mdit2code",
|
|
780
|
+
name: "mdit转代码块",
|
|
781
|
+
detail: "mdit转代码块 (允许嵌套)。注意 `:*n` 会转化为 `~*(n+3)`, `@aaa bbb` 会转换为 `# bbb` (h1标题)",
|
|
782
|
+
process_param: ABConvert_IOEnum.text,
|
|
783
|
+
process_return: ABConvert_IOEnum.text,
|
|
784
|
+
process: (el, header, content) => {
|
|
785
|
+
const lists = content.trimEnd().split("\n");
|
|
786
|
+
let newContent = "";
|
|
787
|
+
for (let i = 0; i < lists.length; i++) {
|
|
788
|
+
const item = lists[i];
|
|
789
|
+
const match = item.match(ABReg.reg_mdit_head);
|
|
790
|
+
const match2 = item.trim().match(/^@(\S*?)\s(.*?)$/);
|
|
791
|
+
if (match2) {
|
|
792
|
+
newContent += "\n# " + match2[2];
|
|
793
|
+
} else if (match) {
|
|
794
|
+
const flag = "~".repeat(match[3].length + 3);
|
|
795
|
+
if (match[4].trim() !== "") newContent += "\n" + flag + "anyblock\n[" + match[4].trimStart() + "]";
|
|
796
|
+
else newContent += "\n" + flag;
|
|
797
|
+
continue;
|
|
798
|
+
} else {
|
|
799
|
+
newContent += "\n" + item;
|
|
800
|
+
continue;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
return newContent.slice(1);
|
|
804
|
+
}
|
|
805
|
+
});
|
|
754
806
|
class ListProcess {
|
|
755
807
|
// ----------------------- str -> listData ------------------------
|
|
756
808
|
/**
|
|
@@ -926,7 +978,7 @@ class ListProcess {
|
|
|
926
978
|
let codeBlockFlag = "";
|
|
927
979
|
for (let line of list_text) {
|
|
928
980
|
if (codeBlockFlag == "") {
|
|
929
|
-
const match = line.match(
|
|
981
|
+
const match = line.match(ABReg.reg_code);
|
|
930
982
|
if (match && match[3]) {
|
|
931
983
|
codeBlockFlag = match[1] + match[3];
|
|
932
984
|
list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
|
|
@@ -1427,7 +1479,7 @@ class C2ListProcess {
|
|
|
1427
1479
|
let codeBlockFlag = "";
|
|
1428
1480
|
for (const line of list_text) {
|
|
1429
1481
|
if (codeBlockFlag == "") {
|
|
1430
|
-
const match = line.match(
|
|
1482
|
+
const match = line.match(ABReg.reg_code);
|
|
1431
1483
|
if (match && match[3]) {
|
|
1432
1484
|
codeBlockFlag = match[1] + match[3];
|
|
1433
1485
|
current_content += line + "\n";
|
|
@@ -1889,8 +1941,8 @@ class DirProcess {
|
|
|
1889
1941
|
}
|
|
1890
1942
|
}
|
|
1891
1943
|
list_itemInfo2.push({
|
|
1892
|
-
content: list_column_item[column_index],
|
|
1893
|
-
// modi
|
|
1944
|
+
content: list_column_item[column_index].trimEnd(),
|
|
1945
|
+
// modi, 使用内联分割符时,尾空白应该总是无用的
|
|
1894
1946
|
level: row_item.level,
|
|
1895
1947
|
tableRow: row_index,
|
|
1896
1948
|
// modi
|
|
@@ -1963,7 +2015,7 @@ class DirProcess {
|
|
|
1963
2015
|
if (!is_head) {
|
|
1964
2016
|
if (cell_item.type == "folder") {
|
|
1965
2017
|
td_svg.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M64 480H448c35.3 0 64-28.7 64-64V160c0-35.3-28.7-64-64-64H288c-10.1 0-19.6-4.7-25.6-12.8L243.2 57.6C231.1 41.5 212.1 32 192 32H64C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64z"/></svg>`;
|
|
1966
|
-
cell_item.content = cell_item.content.slice(0, -1);
|
|
2018
|
+
cell_item.content = cell_item.content.trimEnd().slice(0, -1);
|
|
1967
2019
|
} else {
|
|
1968
2020
|
td_svg.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M320 464c8.8 0 16-7.2 16-16l0-288-80 0c-17.7 0-32-14.3-32-32l0-80L64 48c-8.8 0-16 7.2-16 16l0 384c0 8.8 7.2 16 16 16l256 0zM0 64C0 28.7 28.7 0 64 0L229.5 0c17 0 33.3 6.7 45.3 18.7l90.5 90.5c12 12 18.7 28.3 18.7 45.3L384 448c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 64z"/></svg>`;
|
|
1969
2021
|
}
|
|
@@ -1972,7 +2024,11 @@ class DirProcess {
|
|
|
1972
2024
|
const td_cell = document.createElement("div");
|
|
1973
2025
|
td.appendChild(td_cell);
|
|
1974
2026
|
td_cell.classList.add("ab-list-table-witharrow");
|
|
1975
|
-
|
|
2027
|
+
if (cell_item.tableColumn == 0 && is_folder) {
|
|
2028
|
+
td_cell.innerHTML = cell_item.content;
|
|
2029
|
+
} else {
|
|
2030
|
+
ABConvertManager.getInstance().m_renderMarkdownFn(cell_item.content, td_cell);
|
|
2031
|
+
}
|
|
1976
2032
|
}
|
|
1977
2033
|
}
|
|
1978
2034
|
{
|
|
@@ -2136,7 +2192,7 @@ function listdata2dirdata(list) {
|
|
|
2136
2192
|
for (let i = 0; i < list.length; i++) {
|
|
2137
2193
|
const item = list[i];
|
|
2138
2194
|
let type;
|
|
2139
|
-
if (item.content.endsWith("/")) {
|
|
2195
|
+
if (item.content.trimEnd().endsWith("/")) {
|
|
2140
2196
|
type = "folder";
|
|
2141
2197
|
} else {
|
|
2142
2198
|
const parts = item.content.split(".");
|
|
@@ -2381,7 +2437,7 @@ ABConvert.factory({
|
|
|
2381
2437
|
}
|
|
2382
2438
|
return content;
|
|
2383
2439
|
}
|
|
2384
|
-
const table = content.
|
|
2440
|
+
const table = content.querySelector("table");
|
|
2385
2441
|
if (table !== null) {
|
|
2386
2442
|
table.style.tableLayout = "fixed";
|
|
2387
2443
|
table.style.width = args.some((arg) => arg.endsWith("%")) ? "100%" : "fit-content";
|
|
@@ -2991,7 +3047,27 @@ ABConvert.factory({
|
|
|
2991
3047
|
process_param: ABConvert_IOEnum.text,
|
|
2992
3048
|
process_return: ABConvert_IOEnum.el,
|
|
2993
3049
|
process: (el, header, content) => {
|
|
2994
|
-
|
|
3050
|
+
if (ABCSetting.env == "vuepress") {
|
|
3051
|
+
ABConvertManager.getInstance().m_renderMarkdownFn(`::::: tabs
|
|
3052
|
+
|
|
3053
|
+
@tab show
|
|
3054
|
+
|
|
3055
|
+
${content}
|
|
3056
|
+
|
|
3057
|
+
@tab withoutPlugin
|
|
3058
|
+
|
|
3059
|
+
(noPlugin)${content.trimStart()}
|
|
3060
|
+
|
|
3061
|
+
@tab mdSource
|
|
3062
|
+
|
|
3063
|
+
~~~~~md
|
|
3064
|
+
${content}
|
|
3065
|
+
~~~~~
|
|
3066
|
+
|
|
3067
|
+
:::::`, el);
|
|
3068
|
+
return el;
|
|
3069
|
+
} else {
|
|
3070
|
+
const newContent = `@tab show
|
|
2995
3071
|
${content}
|
|
2996
3072
|
@tab withoutPlugin
|
|
2997
3073
|
(noPlugin)${content.trimStart()}
|
|
@@ -2999,8 +3075,9 @@ ${content}
|
|
|
2999
3075
|
~~~~~md
|
|
3000
3076
|
${content}
|
|
3001
3077
|
~~~~~`;
|
|
3002
|
-
|
|
3003
|
-
|
|
3078
|
+
abc_mditTabs.process(el, header, newContent);
|
|
3079
|
+
return el;
|
|
3080
|
+
}
|
|
3004
3081
|
}
|
|
3005
3082
|
});
|
|
3006
3083
|
ABConvert.factory({
|
|
@@ -42411,13 +42488,13 @@ function abSelector_squareInline(md, options) {
|
|
|
42411
42488
|
return;
|
|
42412
42489
|
}
|
|
42413
42490
|
if (text2.trim() == "") {
|
|
42414
|
-
if (ab_blankLine_counter
|
|
42491
|
+
if (ab_blockType == "list" && ab_blankLine_counter >= 1) {
|
|
42492
|
+
return;
|
|
42493
|
+
} else {
|
|
42415
42494
|
ab_blankLine_counter++;
|
|
42416
42495
|
ab_content += "\n";
|
|
42417
42496
|
state.line += 1;
|
|
42418
42497
|
return findAbEnd();
|
|
42419
|
-
} else {
|
|
42420
|
-
return;
|
|
42421
42498
|
}
|
|
42422
42499
|
} else {
|
|
42423
42500
|
ab_blankLine_counter = 0;
|
|
@@ -42459,7 +42536,7 @@ function abSelector_squareInline(md, options) {
|
|
|
42459
42536
|
}
|
|
42460
42537
|
} else if (ab_blockType == "heading") {
|
|
42461
42538
|
if (codeBlockFlag == "") {
|
|
42462
|
-
const match = text2.match(
|
|
42539
|
+
const match = text2.match(ABReg.reg_code);
|
|
42463
42540
|
if (match && match[3]) {
|
|
42464
42541
|
codeBlockFlag = match[1] + match[3];
|
|
42465
42542
|
ab_content += "\n" + text2;
|
|
@@ -42497,62 +42574,62 @@ function abSelector_squareInline(md, options) {
|
|
|
42497
42574
|
});
|
|
42498
42575
|
}
|
|
42499
42576
|
function abSelector_container(md, options) {
|
|
42500
|
-
md.block.ruler.before("fence", "AnyBlockMditContainer", (state, startLine, endLine
|
|
42501
|
-
const
|
|
42502
|
-
|
|
42503
|
-
|
|
42504
|
-
|
|
42505
|
-
|
|
42506
|
-
|
|
42507
|
-
|
|
42508
|
-
|
|
42509
|
-
|
|
42510
|
-
|
|
42511
|
-
|
|
42512
|
-
|
|
42513
|
-
|
|
42514
|
-
|
|
42515
|
-
|
|
42516
|
-
|
|
42517
|
-
|
|
42518
|
-
|
|
42519
|
-
|
|
42520
|
-
|
|
42521
|
-
|
|
42522
|
-
// also block seems to be auto closed by end of parent
|
|
42523
|
-
nextLine < endLine
|
|
42524
|
-
) {
|
|
42525
|
-
nextLine++;
|
|
42526
|
-
start = state.bMarks[nextLine];
|
|
42527
|
-
max = state.eMarks[nextLine];
|
|
42528
|
-
if (start < max && state.sCount[nextLine] < state.blkIndent)
|
|
42529
|
-
break;
|
|
42530
|
-
if (
|
|
42531
|
-
// match start
|
|
42532
|
-
state.src[start] === ":" && // closing fence should be indented less than 4 spaces
|
|
42533
|
-
state.sCount[nextLine] - state.blkIndent < 4
|
|
42534
|
-
) {
|
|
42535
|
-
for (pos = start + 1; pos <= max; pos++)
|
|
42536
|
-
if (state.src[pos] !== ":") break;
|
|
42537
|
-
if (pos - start >= markerCount) {
|
|
42538
|
-
pos = state.skipSpaces(pos);
|
|
42539
|
-
if (pos >= max) {
|
|
42540
|
-
autoClosed = true;
|
|
42541
|
-
break;
|
|
42542
|
-
}
|
|
42543
|
-
}
|
|
42577
|
+
md.block.ruler.before("fence", "AnyBlockMditContainer", (state, startLine, endLine) => {
|
|
42578
|
+
const mdit_whitelist = ["mditABDemo"];
|
|
42579
|
+
const mdit_blacklist = [
|
|
42580
|
+
// "left", "center", "right", "justify", // https://mdit-plugins.github.io/zh/align.html
|
|
42581
|
+
// "note", "warning", "tip", "info", // https://mdit-plugins.github.io/zh/container.html
|
|
42582
|
+
// "demo", "md-demo", "codedemo",
|
|
42583
|
+
// "tabs", // TODO: 可能是 `tabs#fruit` 这种形式的,应该改成手动循环判断,不能以这些开头
|
|
42584
|
+
];
|
|
42585
|
+
let mdit_header;
|
|
42586
|
+
let mdit_match;
|
|
42587
|
+
{
|
|
42588
|
+
state.line = startLine;
|
|
42589
|
+
const pos = state.bMarks[state.line];
|
|
42590
|
+
const max = state.eMarks[state.line];
|
|
42591
|
+
mdit_header = state.src.substring(pos, max);
|
|
42592
|
+
mdit_match = mdit_header.match(ABReg.reg_mdit_head);
|
|
42593
|
+
if (!mdit_match || !mdit_match.length) return false;
|
|
42594
|
+
if (mdit_whitelist.length && !mdit_whitelist.includes(mdit_match[4].split("|")[0].trim())) {
|
|
42595
|
+
return false;
|
|
42596
|
+
}
|
|
42597
|
+
if (mdit_blacklist.length && mdit_blacklist.includes(mdit_match[4].split("|")[0].trim())) {
|
|
42598
|
+
return false;
|
|
42544
42599
|
}
|
|
42545
|
-
ab_content += "\n" + state.src.substring(start, max);
|
|
42546
42600
|
}
|
|
42547
|
-
|
|
42601
|
+
const mdit_flag = mdit_match[3];
|
|
42602
|
+
const mdit_type = mdit_match[4];
|
|
42603
|
+
const mdit_startLine = state.line;
|
|
42604
|
+
let mdit_content = "";
|
|
42605
|
+
state.line += 1;
|
|
42606
|
+
findMditEnd();
|
|
42607
|
+
const mdit_endLine = state.line;
|
|
42548
42608
|
const token = state.push("fence", "code", 0);
|
|
42549
42609
|
token.info = "AnyBlock";
|
|
42550
|
-
token.content = `[${
|
|
42551
|
-
${
|
|
42552
|
-
token.map = [
|
|
42553
|
-
token.markup =
|
|
42610
|
+
token.content = `[${mdit_type}]
|
|
42611
|
+
${mdit_content}`;
|
|
42612
|
+
token.map = [mdit_startLine, mdit_endLine];
|
|
42613
|
+
token.markup = mdit_flag;
|
|
42554
42614
|
token.nesting = 0;
|
|
42555
42615
|
return true;
|
|
42616
|
+
function findMditEnd() {
|
|
42617
|
+
const pos = state.bMarks[state.line];
|
|
42618
|
+
const max = state.eMarks[state.line];
|
|
42619
|
+
const text2 = state.src.substring(pos, max);
|
|
42620
|
+
if (state.line > endLine) {
|
|
42621
|
+
state.line = endLine + 1;
|
|
42622
|
+
return;
|
|
42623
|
+
}
|
|
42624
|
+
if (text2.trim() == mdit_flag) {
|
|
42625
|
+
state.line += 1;
|
|
42626
|
+
return;
|
|
42627
|
+
} else {
|
|
42628
|
+
mdit_content += "\n" + text2;
|
|
42629
|
+
state.line += 1;
|
|
42630
|
+
return findMditEnd();
|
|
42631
|
+
}
|
|
42632
|
+
}
|
|
42556
42633
|
});
|
|
42557
42634
|
}
|
|
42558
42635
|
function abRender_fence(md, options) {
|