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.cjs
CHANGED
|
@@ -189,12 +189,14 @@ const ABReg = {
|
|
|
189
189
|
*/
|
|
190
190
|
// 有前缀版本(给选择器用)
|
|
191
191
|
reg_header: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5].*)\]):?(%%)?\s*$/,
|
|
192
|
+
// 向上检查标志的 头部选择器
|
|
193
|
+
reg_mdit_head: /^((\s|>\s|-\s|\*\s|\+\s)*)(::::*)\s?(.*)/,
|
|
192
194
|
//: /^\s*(>\s)*-\s(.*)$/
|
|
193
|
-
reg_code: /^((\s|>\s|-\s|\*\s|\+\s)*)(
|
|
194
|
-
//: /^\s*(>\s|-\s)*(
|
|
195
|
+
reg_code: /^((\s|>\s|-\s|\*\s|\+\s)*)(````*|~~~~*)(.*)/,
|
|
196
|
+
//: /^\s*(>\s|-\s)*(````*|~~~~*)(.*)$/
|
|
195
197
|
reg_quote: /^((\s|>\s|-\s|\*\s|\+\s)*)(>\s)(.*)/,
|
|
196
198
|
reg_list_noprefix: /^((\s)*)(-\s|\*\s|\+\s)(.*)/,
|
|
197
|
-
reg_code_noprefix: /^((\s)*)(
|
|
199
|
+
reg_code_noprefix: /^((\s)*)(````*|~~~~*)(.*)/,
|
|
198
200
|
reg_quote_noprefix: /^((\s)*)(>\s)(.*)/,
|
|
199
201
|
reg_heading_noprefix: /^((\s)*)(\#+\s)(.*)/,
|
|
200
202
|
reg_table_noprefix: /^((\s)*)(\|(.*)\|)/,
|
|
@@ -208,24 +210,24 @@ function autoABAlias(header, selectorName, content) {
|
|
|
208
210
|
if (!header.trimEnd().endsWith("|")) header = header + "|";
|
|
209
211
|
if (!header.trimStart().startsWith("|")) header = "|" + header;
|
|
210
212
|
if (selectorName == "mdit") {
|
|
211
|
-
header = "|:::
|
|
213
|
+
header = "|:::_140lne" + header.trimStart();
|
|
212
214
|
} else if (selectorName == "list" || ABReg.reg_list_noprefix.test(content.trimStart())) {
|
|
213
|
-
header = "|
|
|
215
|
+
header = "|list_140lne" + header;
|
|
214
216
|
} else if (selectorName == "heading" || ABReg.reg_heading_noprefix.test(content.trimStart())) {
|
|
215
|
-
header = "|
|
|
217
|
+
header = "|heading_140lne" + header;
|
|
216
218
|
} else if (selectorName == "code" || ABReg.reg_code_noprefix.test(content.trimStart())) {
|
|
217
|
-
header = "|
|
|
219
|
+
header = "|code_140lne" + header;
|
|
218
220
|
} else if (selectorName == "quote" || ABReg.reg_quote_noprefix.test(content.trimStart())) {
|
|
219
|
-
header = "|
|
|
221
|
+
header = "|quote_140lne" + header;
|
|
220
222
|
} else if (selectorName == "table" || ABReg.reg_table_noprefix.test(content.trimStart())) {
|
|
221
|
-
header = "|
|
|
223
|
+
header = "|table_140lne" + header;
|
|
222
224
|
}
|
|
223
225
|
for (const item of ABAlias_json) {
|
|
224
226
|
header = header.replace(item.regex, item.replacement);
|
|
225
227
|
}
|
|
226
228
|
for (const item of ABAlias_json_withSub) {
|
|
227
229
|
header = header.replace(item.regex, (match, ...groups) => {
|
|
228
|
-
return item.replacement.replace(/\$(\d+)/g, (_, number) => groups[number - 1]);
|
|
230
|
+
return item.replacement.replace(/\$(\d+)/g, (_, number) => groups[number - 1] ?? "");
|
|
229
231
|
});
|
|
230
232
|
}
|
|
231
233
|
for (const item of ABAlias_json_end) {
|
|
@@ -234,73 +236,93 @@ function autoABAlias(header, selectorName, content) {
|
|
|
234
236
|
return header;
|
|
235
237
|
}
|
|
236
238
|
const ABAlias_json_withSub = [
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
//
|
|
239
|
+
// 分下类,排下序
|
|
240
|
+
// `gfm` 就支持五种: note, tip, important, warning, caution
|
|
241
|
+
// `vuepress` 比gfm多了个: info
|
|
242
|
+
// `obsidian` 不完全是gfm超集,其important和tip一样,caution和warning一样
|
|
243
|
+
// note
|
|
244
|
+
// abstract, summary, tldr
|
|
245
|
+
// info
|
|
246
|
+
// todo
|
|
247
|
+
// tip. hint, Important
|
|
248
|
+
// succcess, check, done
|
|
249
|
+
// question, help, faq
|
|
250
|
+
// warning, caution, attention
|
|
251
|
+
// failure, fail, missing
|
|
252
|
+
// danger, error
|
|
253
|
+
// bug
|
|
254
|
+
// example
|
|
255
|
+
// quote, cite
|
|
256
|
+
// `其他` 避免错字, 我之前加过 warn, tips。后面又删了
|
|
257
|
+
{ 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|" },
|
|
258
|
+
{ regex: /\|callout (\S+)([+-]?)\s?(.*)\|/, replacement: "|add([!$1]$2 $3)|addQuote|" }
|
|
259
|
+
// 注意避免和原上/上面的callout语法冲突,以及自身递归
|
|
240
260
|
];
|
|
241
261
|
const ABAlias_json_mdit = [
|
|
242
|
-
{ regex: /\|:::
|
|
243
|
-
{ regex: "|:::
|
|
244
|
-
{ regex: "|:::
|
|
245
|
-
{ regex: /\|:::
|
|
246
|
-
{ regex: /\|:::
|
|
247
|
-
{ regex: /\|:::
|
|
262
|
+
{ regex: /\|:::_140lne\|(2?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
|
|
263
|
+
{ regex: "|:::_140lne|demo|", replacement: "|mditDemo|" },
|
|
264
|
+
{ regex: "|:::_140lne|abDemo|", replacement: "|mditABDemo|" },
|
|
265
|
+
{ regex: /\|:::_140lne\|(2?col|分栏)\|/, replacement: "|mditCol|" },
|
|
266
|
+
{ regex: /\|:::_140lne\|(2?card|卡片)\|/, replacement: "|mditCard|" },
|
|
267
|
+
{ regex: /\|:::_140lne\|(2?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" }
|
|
248
268
|
];
|
|
249
269
|
const ABAlias_json_title = [
|
|
250
270
|
{ regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" },
|
|
251
271
|
// title - list&title
|
|
252
|
-
{ regex: /\|
|
|
253
|
-
{ regex: /\|
|
|
254
|
-
{ regex: /\|
|
|
255
|
-
{ regex: /\|
|
|
256
|
-
{ regex: /\|
|
|
272
|
+
{ regex: /\|heading_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|" },
|
|
273
|
+
{ regex: /\|heading_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|" },
|
|
274
|
+
{ regex: /\|heading_140lne\|2?(col|分栏)\||\|title2col\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-col)|" },
|
|
275
|
+
{ regex: /\|heading_140lne\|2?(card|卡片)\||\|title2card\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|" },
|
|
276
|
+
{ regex: /\|heading_140lne\|2?(nodes?|节点)\||\|(title2node|title2abMindmap)\|/, replacement: "|title2listdata|listdata2strict|listdata2nodes|" },
|
|
257
277
|
// list - 多叉多层树
|
|
258
|
-
{ regex: /\|
|
|
259
|
-
{ regex: /\|
|
|
260
|
-
{ regex: /\|
|
|
261
|
-
{ regex: /\|
|
|
262
|
-
{ regex: /\|
|
|
263
|
-
{ regex: /\|
|
|
278
|
+
{ regex: /\|heading_140lne\|2?(mermaid|flow|流程图)\|/, replacement: "|title2list|list2mermaid|" },
|
|
279
|
+
{ regex: /\|heading_140lne\|2?(mehrmaid|mdmermaid)\|/, replacement: "|title2list|list2mehrmaidText|code(mehrmaid)|" },
|
|
280
|
+
{ regex: /\|heading_140lne\|2?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|title2list|list2pumlMindmap|" },
|
|
281
|
+
{ regex: /\|heading_140lne\|2?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|title2list|list2markmap|" },
|
|
282
|
+
{ regex: /\|heading_140lne\|2?(wbs|(工作)?分解(图|结构))\|/, replacement: "|title2list|list2pumlWBS|" },
|
|
283
|
+
{ regex: /\|heading_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|title2list|list2table|" },
|
|
264
284
|
// list - lt树 (属于多层一叉树)
|
|
265
|
-
{ regex: /\|
|
|
266
|
-
{ regex: /\|
|
|
267
|
-
{ regex: /\|
|
|
285
|
+
{ regex: /\|heading_140lne\|2?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|title2list|list2lt|" },
|
|
286
|
+
{ regex: /\|heading_140lne\|2?(list|列表)\|/, replacement: "|title2list|list2lt|addClass(ab-listtable-likelist)|" },
|
|
287
|
+
{ regex: /\|heading_140lne\|2?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|title2list|list2dt|" },
|
|
268
288
|
// list - 二层树
|
|
269
|
-
{ regex: /\|
|
|
289
|
+
{ regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" }
|
|
270
290
|
];
|
|
271
291
|
const ABAlias_json_list = [
|
|
272
292
|
{ regex: "|listXinline|", replacement: "|list2listdata|listdata2list|" },
|
|
273
293
|
// list - list&title
|
|
274
|
-
{ regex: /\|
|
|
275
|
-
{ regex: /\|
|
|
276
|
-
{ regex: /\|
|
|
277
|
-
{ regex: /\|
|
|
278
|
-
{ regex: /\|
|
|
294
|
+
{ regex: /\|list_140lne\|2?(timeline|时间线)\|/, replacement: "|list2timeline|" },
|
|
295
|
+
{ regex: /\|list_140lne\|2?(tabs?|标签页?)\||\|list2tabs?\|/, replacement: "|list2c2listdata|c2listdata2tab|" },
|
|
296
|
+
{ regex: /\|list_140lne\|2?(col|分栏)\||\|list2col\|/, replacement: "|list2c2listdata|c2listdata2items|addClass(ab-col)|" },
|
|
297
|
+
{ regex: /\|list_140lne\|2?(card|卡片)\||\|list2card\|/, replacement: "|list2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|" },
|
|
298
|
+
{ regex: /\|list_140lne\|2?(nodes?|节点)\||\|(list2node|list2abMindmap)\|/, replacement: "|list2listdata|listdata2strict|listdata2nodes|" },
|
|
279
299
|
// list - 多叉多层树
|
|
280
|
-
{ regex: /\|
|
|
281
|
-
{ regex: /\|
|
|
282
|
-
{ regex: /\|
|
|
283
|
-
{ regex: /\|
|
|
284
|
-
{ regex: /\|
|
|
285
|
-
{ regex: /\|
|
|
300
|
+
{ regex: /\|list_140lne\|2?(mermaid|flow|流程图)\|/, replacement: "|list2mermaid|" },
|
|
301
|
+
{ regex: /\|list_140lne\|2?(mehrmaid|mdmermaid)\|/, replacement: "|list2mehrmaidText|code(mehrmaid)|" },
|
|
302
|
+
{ regex: /\|list_140lne\|2?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|list2pumlMindmap|" },
|
|
303
|
+
{ regex: /\|list_140lne\|2?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|list2markmap|" },
|
|
304
|
+
{ regex: /\|list_140lne\|2?(wbs|(工作)?分解(图|结构))\|/, replacement: "|list2pumlWBS|" },
|
|
305
|
+
{ regex: /\|list_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|list2table|" },
|
|
286
306
|
// list - lt树 (属于多层一叉树)
|
|
287
|
-
{ regex: /\|
|
|
288
|
-
{ regex: /\|
|
|
289
|
-
{ regex: /\|
|
|
307
|
+
{ regex: /\|list_140lne\|2?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|list2lt|" },
|
|
308
|
+
{ regex: /\|list_140lne\|2?(list|列表)\|/, replacement: "|list2lt|addClass(ab-listtable-likelist)|" },
|
|
309
|
+
{ regex: /\|list_140lne\|2?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|list2dt|" },
|
|
290
310
|
// list - 二层树
|
|
291
|
-
{ regex: /\|
|
|
311
|
+
{ regex: /\|list_140lne\|(fakeList|仿列表)\|/, replacement: "|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" }
|
|
292
312
|
];
|
|
293
313
|
const ABAlias_json_code = [
|
|
294
|
-
{ regex: "|
|
|
295
|
-
{ regex: "|
|
|
314
|
+
{ regex: "|code_140lne|X|", replacement: "|xCode|" },
|
|
315
|
+
{ regex: "|code_140lne|x|", replacement: "|xCode|" },
|
|
316
|
+
{ regex: "|code2list|", replacement: "|xCode|region2indent|addList|" },
|
|
296
317
|
{ regex: "|list2code|", replacement: "|xList|code(js)|" }
|
|
297
318
|
];
|
|
298
319
|
const ABAlias_json_quote = [
|
|
299
|
-
{
|
|
320
|
+
// {regex: "|quote_140lne|X|", replacement: "|xQuote|"},
|
|
321
|
+
// {regex: "|quote_140lne|x|", replacement: "|xQuote|"},
|
|
300
322
|
];
|
|
301
323
|
const ABAlias_json_table = [];
|
|
302
324
|
const ABAlias_json_general = [
|
|
303
|
-
{ regex: "|黑幕|", replacement: "|
|
|
325
|
+
{ regex: "|黑幕|", replacement: "|addClass(ab-deco-heimu)|" },
|
|
304
326
|
{ regex: "|折叠|", replacement: "|fold|" },
|
|
305
327
|
{ regex: "|滚动|", replacement: "|scroll|" },
|
|
306
328
|
{ regex: "|超出折叠|", replacement: "|overfold|" },
|
|
@@ -356,12 +378,12 @@ let ABAlias_json = [
|
|
|
356
378
|
// 设置决定是否停用
|
|
357
379
|
];
|
|
358
380
|
const ABAlias_json_end = [
|
|
359
|
-
{ regex: "|:::
|
|
360
|
-
{ regex: "|
|
|
361
|
-
{ regex: "|
|
|
362
|
-
{ regex: "|
|
|
363
|
-
{ regex: "|
|
|
364
|
-
{ regex: "|
|
|
381
|
+
{ regex: "|:::_140lne", replacement: "" },
|
|
382
|
+
{ regex: "|heading_140lne", replacement: "" },
|
|
383
|
+
{ regex: "|list_140lne", replacement: "" },
|
|
384
|
+
{ regex: "|code_140lne", replacement: "" },
|
|
385
|
+
{ regex: "|qutoe_140lne", replacement: "" },
|
|
386
|
+
{ regex: "|table_140lne", replacement: "" }
|
|
365
387
|
];
|
|
366
388
|
class ABConvertManager {
|
|
367
389
|
/// 构造函数
|
|
@@ -537,9 +559,9 @@ class ABConvertManager {
|
|
|
537
559
|
}
|
|
538
560
|
}
|
|
539
561
|
ABConvert.factory({
|
|
540
|
-
id: "
|
|
562
|
+
id: "addQuote",
|
|
541
563
|
name: "增加引用块",
|
|
542
|
-
match:
|
|
564
|
+
match: "addQuote",
|
|
543
565
|
detail: "在文本的每行前面加上 `> `",
|
|
544
566
|
process_param: ABConvert_IOEnum.text,
|
|
545
567
|
process_return: ABConvert_IOEnum.text,
|
|
@@ -550,23 +572,24 @@ ABConvert.factory({
|
|
|
550
572
|
}
|
|
551
573
|
});
|
|
552
574
|
ABConvert.factory({
|
|
553
|
-
id: "
|
|
575
|
+
id: "addCode",
|
|
554
576
|
name: "增加代码块",
|
|
555
|
-
match: /^code(\((.*)\))?$/,
|
|
577
|
+
match: /^(addCode|code)(\((.*)\))?$/,
|
|
556
578
|
default: "code()",
|
|
557
579
|
detail: "在文本的前后均加上一行代码块围栏。不加`()`表示用原文本的第一行作为代码类型,括号类型为空表示代码类型为空",
|
|
558
580
|
process_param: ABConvert_IOEnum.text,
|
|
559
581
|
process_return: ABConvert_IOEnum.text,
|
|
560
582
|
process: (el, header, content) => {
|
|
561
|
-
let matchs = header.match(/^code(\((.*)\))?$/);
|
|
583
|
+
let matchs = header.match(/^(addCode|code)(\((.*)\))?$/);
|
|
562
584
|
if (!matchs) return content;
|
|
563
|
-
if (matchs[
|
|
585
|
+
if (matchs[2]) content = matchs[3] + "\n" + content;
|
|
564
586
|
return "``````" + content + "\n``````";
|
|
565
587
|
}
|
|
566
588
|
});
|
|
567
|
-
const
|
|
568
|
-
id: "
|
|
589
|
+
const abc_xQuote = ABConvert.factory({
|
|
590
|
+
id: "xQuote",
|
|
569
591
|
name: "去除引用块",
|
|
592
|
+
match: /^(xQuote|Xquote)$/,
|
|
570
593
|
detail: "在文本的每行前面删除 `> `",
|
|
571
594
|
process_param: ABConvert_IOEnum.text,
|
|
572
595
|
process_return: ABConvert_IOEnum.text,
|
|
@@ -576,20 +599,20 @@ const abc_Xquote = ABConvert.factory({
|
|
|
576
599
|
}).join("\n");
|
|
577
600
|
}
|
|
578
601
|
});
|
|
579
|
-
const
|
|
580
|
-
id: "
|
|
602
|
+
const abc_xCode = ABConvert.factory({
|
|
603
|
+
id: "xCode",
|
|
581
604
|
name: "去除代码块",
|
|
582
|
-
match: /^Xcode(\((true|false|)\))?$/,
|
|
583
|
-
default: "
|
|
605
|
+
match: /^(xCode|Xcode)(\((true|false|)\))?$/,
|
|
606
|
+
default: "xCode(true)",
|
|
584
607
|
detail: "参数为是否移除代码类型, Xcode默认为false, Xcode默认为true。记法: code|Xcode 或 code()|Xcode()内容不变",
|
|
585
608
|
process_param: ABConvert_IOEnum.text,
|
|
586
609
|
process_return: ABConvert_IOEnum.text,
|
|
587
610
|
process: (el, header, content) => {
|
|
588
|
-
let matchs = header.match(/^Xcode(\((true|false|)\))?$/);
|
|
611
|
+
let matchs = header.match(/^(xCode|Xcode)(\((true|false|)\))?$/);
|
|
589
612
|
if (!matchs) return content;
|
|
590
613
|
let remove_flag;
|
|
591
|
-
if (matchs[
|
|
592
|
-
else remove_flag = matchs[
|
|
614
|
+
if (matchs[2] == "") remove_flag = false;
|
|
615
|
+
else remove_flag = matchs[3] != "false";
|
|
593
616
|
let list_content = content.split("\n");
|
|
594
617
|
let code_flag = "";
|
|
595
618
|
let line_start = -1;
|
|
@@ -618,8 +641,9 @@ const abc_Xcode = ABConvert.factory({
|
|
|
618
641
|
}
|
|
619
642
|
});
|
|
620
643
|
ABConvert.factory({
|
|
621
|
-
id: "
|
|
644
|
+
id: "x",
|
|
622
645
|
name: "去除代码或引用块",
|
|
646
|
+
match: /^(x|X)$/,
|
|
623
647
|
process_param: ABConvert_IOEnum.text,
|
|
624
648
|
process_return: ABConvert_IOEnum.text,
|
|
625
649
|
process: (el, header, content) => {
|
|
@@ -633,8 +657,8 @@ ABConvert.factory({
|
|
|
633
657
|
break;
|
|
634
658
|
}
|
|
635
659
|
}
|
|
636
|
-
if (flag == "code") return
|
|
637
|
-
else if (flag == "quote") return
|
|
660
|
+
if (flag == "code") return abc_xCode.process(el, header, content);
|
|
661
|
+
else if (flag == "quote") return abc_xQuote.process(el, header, content);
|
|
638
662
|
return content;
|
|
639
663
|
}
|
|
640
664
|
});
|
|
@@ -775,6 +799,34 @@ ABConvert.factory({
|
|
|
775
799
|
return newContent.slice(1);
|
|
776
800
|
}
|
|
777
801
|
});
|
|
802
|
+
ABConvert.factory({
|
|
803
|
+
id: "mdit2code",
|
|
804
|
+
name: "mdit转代码块",
|
|
805
|
+
detail: "mdit转代码块 (允许嵌套)。注意 `:*n` 会转化为 `~*(n+3)`, `@aaa bbb` 会转换为 `# bbb` (h1标题)",
|
|
806
|
+
process_param: ABConvert_IOEnum.text,
|
|
807
|
+
process_return: ABConvert_IOEnum.text,
|
|
808
|
+
process: (el, header, content) => {
|
|
809
|
+
const lists = content.trimEnd().split("\n");
|
|
810
|
+
let newContent = "";
|
|
811
|
+
for (let i = 0; i < lists.length; i++) {
|
|
812
|
+
const item = lists[i];
|
|
813
|
+
const match = item.match(ABReg.reg_mdit_head);
|
|
814
|
+
const match2 = item.trim().match(/^@(\S*?)\s(.*?)$/);
|
|
815
|
+
if (match2) {
|
|
816
|
+
newContent += "\n# " + match2[2];
|
|
817
|
+
} else if (match) {
|
|
818
|
+
const flag = "~".repeat(match[3].length + 3);
|
|
819
|
+
if (match[4].trim() !== "") newContent += "\n" + flag + "anyblock\n[" + match[4].trimStart() + "]";
|
|
820
|
+
else newContent += "\n" + flag;
|
|
821
|
+
continue;
|
|
822
|
+
} else {
|
|
823
|
+
newContent += "\n" + item;
|
|
824
|
+
continue;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return newContent.slice(1);
|
|
828
|
+
}
|
|
829
|
+
});
|
|
778
830
|
class ListProcess {
|
|
779
831
|
// ----------------------- str -> listData ------------------------
|
|
780
832
|
/**
|
|
@@ -950,7 +1002,7 @@ class ListProcess {
|
|
|
950
1002
|
let codeBlockFlag = "";
|
|
951
1003
|
for (let line of list_text) {
|
|
952
1004
|
if (codeBlockFlag == "") {
|
|
953
|
-
const match = line.match(
|
|
1005
|
+
const match = line.match(ABReg.reg_code);
|
|
954
1006
|
if (match && match[3]) {
|
|
955
1007
|
codeBlockFlag = match[1] + match[3];
|
|
956
1008
|
list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
|
|
@@ -1451,7 +1503,7 @@ class C2ListProcess {
|
|
|
1451
1503
|
let codeBlockFlag = "";
|
|
1452
1504
|
for (const line of list_text) {
|
|
1453
1505
|
if (codeBlockFlag == "") {
|
|
1454
|
-
const match = line.match(
|
|
1506
|
+
const match = line.match(ABReg.reg_code);
|
|
1455
1507
|
if (match && match[3]) {
|
|
1456
1508
|
codeBlockFlag = match[1] + match[3];
|
|
1457
1509
|
current_content += line + "\n";
|
|
@@ -1913,8 +1965,8 @@ class DirProcess {
|
|
|
1913
1965
|
}
|
|
1914
1966
|
}
|
|
1915
1967
|
list_itemInfo2.push({
|
|
1916
|
-
content: list_column_item[column_index],
|
|
1917
|
-
// modi
|
|
1968
|
+
content: list_column_item[column_index].trimEnd(),
|
|
1969
|
+
// modi, 使用内联分割符时,尾空白应该总是无用的
|
|
1918
1970
|
level: row_item.level,
|
|
1919
1971
|
tableRow: row_index,
|
|
1920
1972
|
// modi
|
|
@@ -1987,7 +2039,7 @@ class DirProcess {
|
|
|
1987
2039
|
if (!is_head) {
|
|
1988
2040
|
if (cell_item.type == "folder") {
|
|
1989
2041
|
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>`;
|
|
1990
|
-
cell_item.content = cell_item.content.slice(0, -1);
|
|
2042
|
+
cell_item.content = cell_item.content.trimEnd().slice(0, -1);
|
|
1991
2043
|
} else {
|
|
1992
2044
|
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>`;
|
|
1993
2045
|
}
|
|
@@ -1996,7 +2048,11 @@ class DirProcess {
|
|
|
1996
2048
|
const td_cell = document.createElement("div");
|
|
1997
2049
|
td.appendChild(td_cell);
|
|
1998
2050
|
td_cell.classList.add("ab-list-table-witharrow");
|
|
1999
|
-
|
|
2051
|
+
if (cell_item.tableColumn == 0 && is_folder) {
|
|
2052
|
+
td_cell.innerHTML = cell_item.content;
|
|
2053
|
+
} else {
|
|
2054
|
+
ABConvertManager.getInstance().m_renderMarkdownFn(cell_item.content, td_cell);
|
|
2055
|
+
}
|
|
2000
2056
|
}
|
|
2001
2057
|
}
|
|
2002
2058
|
{
|
|
@@ -2160,7 +2216,7 @@ function listdata2dirdata(list) {
|
|
|
2160
2216
|
for (let i = 0; i < list.length; i++) {
|
|
2161
2217
|
const item = list[i];
|
|
2162
2218
|
let type;
|
|
2163
|
-
if (item.content.endsWith("/")) {
|
|
2219
|
+
if (item.content.trimEnd().endsWith("/")) {
|
|
2164
2220
|
type = "folder";
|
|
2165
2221
|
} else {
|
|
2166
2222
|
const parts = item.content.split(".");
|
|
@@ -2405,7 +2461,7 @@ ABConvert.factory({
|
|
|
2405
2461
|
}
|
|
2406
2462
|
return content;
|
|
2407
2463
|
}
|
|
2408
|
-
const table = content.
|
|
2464
|
+
const table = content.querySelector("table");
|
|
2409
2465
|
if (table !== null) {
|
|
2410
2466
|
table.style.tableLayout = "fixed";
|
|
2411
2467
|
table.style.width = args.some((arg) => arg.endsWith("%")) ? "100%" : "fit-content";
|
|
@@ -3015,7 +3071,27 @@ ABConvert.factory({
|
|
|
3015
3071
|
process_param: ABConvert_IOEnum.text,
|
|
3016
3072
|
process_return: ABConvert_IOEnum.el,
|
|
3017
3073
|
process: (el, header, content) => {
|
|
3018
|
-
|
|
3074
|
+
if (ABCSetting.env == "vuepress") {
|
|
3075
|
+
ABConvertManager.getInstance().m_renderMarkdownFn(`::::: tabs
|
|
3076
|
+
|
|
3077
|
+
@tab show
|
|
3078
|
+
|
|
3079
|
+
${content}
|
|
3080
|
+
|
|
3081
|
+
@tab withoutPlugin
|
|
3082
|
+
|
|
3083
|
+
(noPlugin)${content.trimStart()}
|
|
3084
|
+
|
|
3085
|
+
@tab mdSource
|
|
3086
|
+
|
|
3087
|
+
~~~~~md
|
|
3088
|
+
${content}
|
|
3089
|
+
~~~~~
|
|
3090
|
+
|
|
3091
|
+
:::::`, el);
|
|
3092
|
+
return el;
|
|
3093
|
+
} else {
|
|
3094
|
+
const newContent = `@tab show
|
|
3019
3095
|
${content}
|
|
3020
3096
|
@tab withoutPlugin
|
|
3021
3097
|
(noPlugin)${content.trimStart()}
|
|
@@ -3023,8 +3099,9 @@ ${content}
|
|
|
3023
3099
|
~~~~~md
|
|
3024
3100
|
${content}
|
|
3025
3101
|
~~~~~`;
|
|
3026
|
-
|
|
3027
|
-
|
|
3102
|
+
abc_mditTabs.process(el, header, newContent);
|
|
3103
|
+
return el;
|
|
3104
|
+
}
|
|
3028
3105
|
}
|
|
3029
3106
|
});
|
|
3030
3107
|
ABConvert.factory({
|
|
@@ -42435,13 +42512,13 @@ function abSelector_squareInline(md, options) {
|
|
|
42435
42512
|
return;
|
|
42436
42513
|
}
|
|
42437
42514
|
if (text2.trim() == "") {
|
|
42438
|
-
if (ab_blankLine_counter
|
|
42515
|
+
if (ab_blockType == "list" && ab_blankLine_counter >= 1) {
|
|
42516
|
+
return;
|
|
42517
|
+
} else {
|
|
42439
42518
|
ab_blankLine_counter++;
|
|
42440
42519
|
ab_content += "\n";
|
|
42441
42520
|
state.line += 1;
|
|
42442
42521
|
return findAbEnd();
|
|
42443
|
-
} else {
|
|
42444
|
-
return;
|
|
42445
42522
|
}
|
|
42446
42523
|
} else {
|
|
42447
42524
|
ab_blankLine_counter = 0;
|
|
@@ -42483,7 +42560,7 @@ function abSelector_squareInline(md, options) {
|
|
|
42483
42560
|
}
|
|
42484
42561
|
} else if (ab_blockType == "heading") {
|
|
42485
42562
|
if (codeBlockFlag == "") {
|
|
42486
|
-
const match = text2.match(
|
|
42563
|
+
const match = text2.match(ABReg.reg_code);
|
|
42487
42564
|
if (match && match[3]) {
|
|
42488
42565
|
codeBlockFlag = match[1] + match[3];
|
|
42489
42566
|
ab_content += "\n" + text2;
|
|
@@ -42521,62 +42598,62 @@ function abSelector_squareInline(md, options) {
|
|
|
42521
42598
|
});
|
|
42522
42599
|
}
|
|
42523
42600
|
function abSelector_container(md, options) {
|
|
42524
|
-
md.block.ruler.before("fence", "AnyBlockMditContainer", (state, startLine, endLine
|
|
42525
|
-
const
|
|
42526
|
-
|
|
42527
|
-
|
|
42528
|
-
|
|
42529
|
-
|
|
42530
|
-
|
|
42531
|
-
|
|
42532
|
-
|
|
42533
|
-
|
|
42534
|
-
|
|
42535
|
-
|
|
42536
|
-
|
|
42537
|
-
|
|
42538
|
-
|
|
42539
|
-
|
|
42540
|
-
|
|
42541
|
-
|
|
42542
|
-
|
|
42543
|
-
|
|
42544
|
-
|
|
42545
|
-
|
|
42546
|
-
// also block seems to be auto closed by end of parent
|
|
42547
|
-
nextLine < endLine
|
|
42548
|
-
) {
|
|
42549
|
-
nextLine++;
|
|
42550
|
-
start = state.bMarks[nextLine];
|
|
42551
|
-
max = state.eMarks[nextLine];
|
|
42552
|
-
if (start < max && state.sCount[nextLine] < state.blkIndent)
|
|
42553
|
-
break;
|
|
42554
|
-
if (
|
|
42555
|
-
// match start
|
|
42556
|
-
state.src[start] === ":" && // closing fence should be indented less than 4 spaces
|
|
42557
|
-
state.sCount[nextLine] - state.blkIndent < 4
|
|
42558
|
-
) {
|
|
42559
|
-
for (pos = start + 1; pos <= max; pos++)
|
|
42560
|
-
if (state.src[pos] !== ":") break;
|
|
42561
|
-
if (pos - start >= markerCount) {
|
|
42562
|
-
pos = state.skipSpaces(pos);
|
|
42563
|
-
if (pos >= max) {
|
|
42564
|
-
autoClosed = true;
|
|
42565
|
-
break;
|
|
42566
|
-
}
|
|
42567
|
-
}
|
|
42601
|
+
md.block.ruler.before("fence", "AnyBlockMditContainer", (state, startLine, endLine) => {
|
|
42602
|
+
const mdit_whitelist = ["mditABDemo"];
|
|
42603
|
+
const mdit_blacklist = [
|
|
42604
|
+
// "left", "center", "right", "justify", // https://mdit-plugins.github.io/zh/align.html
|
|
42605
|
+
// "note", "warning", "tip", "info", // https://mdit-plugins.github.io/zh/container.html
|
|
42606
|
+
// "demo", "md-demo", "codedemo",
|
|
42607
|
+
// "tabs", // TODO: 可能是 `tabs#fruit` 这种形式的,应该改成手动循环判断,不能以这些开头
|
|
42608
|
+
];
|
|
42609
|
+
let mdit_header;
|
|
42610
|
+
let mdit_match;
|
|
42611
|
+
{
|
|
42612
|
+
state.line = startLine;
|
|
42613
|
+
const pos = state.bMarks[state.line];
|
|
42614
|
+
const max = state.eMarks[state.line];
|
|
42615
|
+
mdit_header = state.src.substring(pos, max);
|
|
42616
|
+
mdit_match = mdit_header.match(ABReg.reg_mdit_head);
|
|
42617
|
+
if (!mdit_match || !mdit_match.length) return false;
|
|
42618
|
+
if (mdit_whitelist.length && !mdit_whitelist.includes(mdit_match[4].split("|")[0].trim())) {
|
|
42619
|
+
return false;
|
|
42620
|
+
}
|
|
42621
|
+
if (mdit_blacklist.length && mdit_blacklist.includes(mdit_match[4].split("|")[0].trim())) {
|
|
42622
|
+
return false;
|
|
42568
42623
|
}
|
|
42569
|
-
ab_content += "\n" + state.src.substring(start, max);
|
|
42570
42624
|
}
|
|
42571
|
-
|
|
42625
|
+
const mdit_flag = mdit_match[3];
|
|
42626
|
+
const mdit_type = mdit_match[4];
|
|
42627
|
+
const mdit_startLine = state.line;
|
|
42628
|
+
let mdit_content = "";
|
|
42629
|
+
state.line += 1;
|
|
42630
|
+
findMditEnd();
|
|
42631
|
+
const mdit_endLine = state.line;
|
|
42572
42632
|
const token = state.push("fence", "code", 0);
|
|
42573
42633
|
token.info = "AnyBlock";
|
|
42574
|
-
token.content = `[${
|
|
42575
|
-
${
|
|
42576
|
-
token.map = [
|
|
42577
|
-
token.markup =
|
|
42634
|
+
token.content = `[${mdit_type}]
|
|
42635
|
+
${mdit_content}`;
|
|
42636
|
+
token.map = [mdit_startLine, mdit_endLine];
|
|
42637
|
+
token.markup = mdit_flag;
|
|
42578
42638
|
token.nesting = 0;
|
|
42579
42639
|
return true;
|
|
42640
|
+
function findMditEnd() {
|
|
42641
|
+
const pos = state.bMarks[state.line];
|
|
42642
|
+
const max = state.eMarks[state.line];
|
|
42643
|
+
const text2 = state.src.substring(pos, max);
|
|
42644
|
+
if (state.line > endLine) {
|
|
42645
|
+
state.line = endLine + 1;
|
|
42646
|
+
return;
|
|
42647
|
+
}
|
|
42648
|
+
if (text2.trim() == mdit_flag) {
|
|
42649
|
+
state.line += 1;
|
|
42650
|
+
return;
|
|
42651
|
+
} else {
|
|
42652
|
+
mdit_content += "\n" + text2;
|
|
42653
|
+
state.line += 1;
|
|
42654
|
+
return findMditEnd();
|
|
42655
|
+
}
|
|
42656
|
+
}
|
|
42580
42657
|
});
|
|
42581
42658
|
}
|
|
42582
42659
|
function abRender_fence(md, options) {
|