markdown-it-any-block 3.2.12 → 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 +200 -125
- package/dist/mdit-any-block.cjs.map +1 -1
- package/dist/mdit-any-block.js +200 -125
- 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
|
/// 构造函数
|
|
@@ -567,7 +589,7 @@ ABConvert.factory({
|
|
|
567
589
|
const abc_xQuote = ABConvert.factory({
|
|
568
590
|
id: "xQuote",
|
|
569
591
|
name: "去除引用块",
|
|
570
|
-
match:
|
|
592
|
+
match: /^(xQuote|Xquote)$/,
|
|
571
593
|
detail: "在文本的每行前面删除 `> `",
|
|
572
594
|
process_param: ABConvert_IOEnum.text,
|
|
573
595
|
process_return: ABConvert_IOEnum.text,
|
|
@@ -777,6 +799,34 @@ ABConvert.factory({
|
|
|
777
799
|
return newContent.slice(1);
|
|
778
800
|
}
|
|
779
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
|
+
});
|
|
780
830
|
class ListProcess {
|
|
781
831
|
// ----------------------- str -> listData ------------------------
|
|
782
832
|
/**
|
|
@@ -952,7 +1002,7 @@ class ListProcess {
|
|
|
952
1002
|
let codeBlockFlag = "";
|
|
953
1003
|
for (let line of list_text) {
|
|
954
1004
|
if (codeBlockFlag == "") {
|
|
955
|
-
const match = line.match(
|
|
1005
|
+
const match = line.match(ABReg.reg_code);
|
|
956
1006
|
if (match && match[3]) {
|
|
957
1007
|
codeBlockFlag = match[1] + match[3];
|
|
958
1008
|
list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
|
|
@@ -1453,7 +1503,7 @@ class C2ListProcess {
|
|
|
1453
1503
|
let codeBlockFlag = "";
|
|
1454
1504
|
for (const line of list_text) {
|
|
1455
1505
|
if (codeBlockFlag == "") {
|
|
1456
|
-
const match = line.match(
|
|
1506
|
+
const match = line.match(ABReg.reg_code);
|
|
1457
1507
|
if (match && match[3]) {
|
|
1458
1508
|
codeBlockFlag = match[1] + match[3];
|
|
1459
1509
|
current_content += line + "\n";
|
|
@@ -1915,8 +1965,8 @@ class DirProcess {
|
|
|
1915
1965
|
}
|
|
1916
1966
|
}
|
|
1917
1967
|
list_itemInfo2.push({
|
|
1918
|
-
content: list_column_item[column_index],
|
|
1919
|
-
// modi
|
|
1968
|
+
content: list_column_item[column_index].trimEnd(),
|
|
1969
|
+
// modi, 使用内联分割符时,尾空白应该总是无用的
|
|
1920
1970
|
level: row_item.level,
|
|
1921
1971
|
tableRow: row_index,
|
|
1922
1972
|
// modi
|
|
@@ -1989,7 +2039,7 @@ class DirProcess {
|
|
|
1989
2039
|
if (!is_head) {
|
|
1990
2040
|
if (cell_item.type == "folder") {
|
|
1991
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>`;
|
|
1992
|
-
cell_item.content = cell_item.content.slice(0, -1);
|
|
2042
|
+
cell_item.content = cell_item.content.trimEnd().slice(0, -1);
|
|
1993
2043
|
} else {
|
|
1994
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>`;
|
|
1995
2045
|
}
|
|
@@ -1998,7 +2048,11 @@ class DirProcess {
|
|
|
1998
2048
|
const td_cell = document.createElement("div");
|
|
1999
2049
|
td.appendChild(td_cell);
|
|
2000
2050
|
td_cell.classList.add("ab-list-table-witharrow");
|
|
2001
|
-
|
|
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
|
+
}
|
|
2002
2056
|
}
|
|
2003
2057
|
}
|
|
2004
2058
|
{
|
|
@@ -2162,7 +2216,7 @@ function listdata2dirdata(list) {
|
|
|
2162
2216
|
for (let i = 0; i < list.length; i++) {
|
|
2163
2217
|
const item = list[i];
|
|
2164
2218
|
let type;
|
|
2165
|
-
if (item.content.endsWith("/")) {
|
|
2219
|
+
if (item.content.trimEnd().endsWith("/")) {
|
|
2166
2220
|
type = "folder";
|
|
2167
2221
|
} else {
|
|
2168
2222
|
const parts = item.content.split(".");
|
|
@@ -2407,7 +2461,7 @@ ABConvert.factory({
|
|
|
2407
2461
|
}
|
|
2408
2462
|
return content;
|
|
2409
2463
|
}
|
|
2410
|
-
const table = content.
|
|
2464
|
+
const table = content.querySelector("table");
|
|
2411
2465
|
if (table !== null) {
|
|
2412
2466
|
table.style.tableLayout = "fixed";
|
|
2413
2467
|
table.style.width = args.some((arg) => arg.endsWith("%")) ? "100%" : "fit-content";
|
|
@@ -3017,7 +3071,27 @@ ABConvert.factory({
|
|
|
3017
3071
|
process_param: ABConvert_IOEnum.text,
|
|
3018
3072
|
process_return: ABConvert_IOEnum.el,
|
|
3019
3073
|
process: (el, header, content) => {
|
|
3020
|
-
|
|
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
|
|
3021
3095
|
${content}
|
|
3022
3096
|
@tab withoutPlugin
|
|
3023
3097
|
(noPlugin)${content.trimStart()}
|
|
@@ -3025,8 +3099,9 @@ ${content}
|
|
|
3025
3099
|
~~~~~md
|
|
3026
3100
|
${content}
|
|
3027
3101
|
~~~~~`;
|
|
3028
|
-
|
|
3029
|
-
|
|
3102
|
+
abc_mditTabs.process(el, header, newContent);
|
|
3103
|
+
return el;
|
|
3104
|
+
}
|
|
3030
3105
|
}
|
|
3031
3106
|
});
|
|
3032
3107
|
ABConvert.factory({
|
|
@@ -42437,13 +42512,13 @@ function abSelector_squareInline(md, options) {
|
|
|
42437
42512
|
return;
|
|
42438
42513
|
}
|
|
42439
42514
|
if (text2.trim() == "") {
|
|
42440
|
-
if (ab_blankLine_counter
|
|
42515
|
+
if (ab_blockType == "list" && ab_blankLine_counter >= 1) {
|
|
42516
|
+
return;
|
|
42517
|
+
} else {
|
|
42441
42518
|
ab_blankLine_counter++;
|
|
42442
42519
|
ab_content += "\n";
|
|
42443
42520
|
state.line += 1;
|
|
42444
42521
|
return findAbEnd();
|
|
42445
|
-
} else {
|
|
42446
|
-
return;
|
|
42447
42522
|
}
|
|
42448
42523
|
} else {
|
|
42449
42524
|
ab_blankLine_counter = 0;
|
|
@@ -42485,7 +42560,7 @@ function abSelector_squareInline(md, options) {
|
|
|
42485
42560
|
}
|
|
42486
42561
|
} else if (ab_blockType == "heading") {
|
|
42487
42562
|
if (codeBlockFlag == "") {
|
|
42488
|
-
const match = text2.match(
|
|
42563
|
+
const match = text2.match(ABReg.reg_code);
|
|
42489
42564
|
if (match && match[3]) {
|
|
42490
42565
|
codeBlockFlag = match[1] + match[3];
|
|
42491
42566
|
ab_content += "\n" + text2;
|
|
@@ -42523,62 +42598,62 @@ function abSelector_squareInline(md, options) {
|
|
|
42523
42598
|
});
|
|
42524
42599
|
}
|
|
42525
42600
|
function abSelector_container(md, options) {
|
|
42526
|
-
md.block.ruler.before("fence", "AnyBlockMditContainer", (state, startLine, endLine
|
|
42527
|
-
const
|
|
42528
|
-
|
|
42529
|
-
|
|
42530
|
-
|
|
42531
|
-
|
|
42532
|
-
|
|
42533
|
-
|
|
42534
|
-
|
|
42535
|
-
|
|
42536
|
-
|
|
42537
|
-
|
|
42538
|
-
|
|
42539
|
-
|
|
42540
|
-
|
|
42541
|
-
|
|
42542
|
-
|
|
42543
|
-
|
|
42544
|
-
|
|
42545
|
-
|
|
42546
|
-
|
|
42547
|
-
|
|
42548
|
-
// also block seems to be auto closed by end of parent
|
|
42549
|
-
nextLine < endLine
|
|
42550
|
-
) {
|
|
42551
|
-
nextLine++;
|
|
42552
|
-
start = state.bMarks[nextLine];
|
|
42553
|
-
max = state.eMarks[nextLine];
|
|
42554
|
-
if (start < max && state.sCount[nextLine] < state.blkIndent)
|
|
42555
|
-
break;
|
|
42556
|
-
if (
|
|
42557
|
-
// match start
|
|
42558
|
-
state.src[start] === ":" && // closing fence should be indented less than 4 spaces
|
|
42559
|
-
state.sCount[nextLine] - state.blkIndent < 4
|
|
42560
|
-
) {
|
|
42561
|
-
for (pos = start + 1; pos <= max; pos++)
|
|
42562
|
-
if (state.src[pos] !== ":") break;
|
|
42563
|
-
if (pos - start >= markerCount) {
|
|
42564
|
-
pos = state.skipSpaces(pos);
|
|
42565
|
-
if (pos >= max) {
|
|
42566
|
-
autoClosed = true;
|
|
42567
|
-
break;
|
|
42568
|
-
}
|
|
42569
|
-
}
|
|
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;
|
|
42570
42623
|
}
|
|
42571
|
-
ab_content += "\n" + state.src.substring(start, max);
|
|
42572
42624
|
}
|
|
42573
|
-
|
|
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;
|
|
42574
42632
|
const token = state.push("fence", "code", 0);
|
|
42575
42633
|
token.info = "AnyBlock";
|
|
42576
|
-
token.content = `[${
|
|
42577
|
-
${
|
|
42578
|
-
token.map = [
|
|
42579
|
-
token.markup =
|
|
42634
|
+
token.content = `[${mdit_type}]
|
|
42635
|
+
${mdit_content}`;
|
|
42636
|
+
token.map = [mdit_startLine, mdit_endLine];
|
|
42637
|
+
token.markup = mdit_flag;
|
|
42580
42638
|
token.nesting = 0;
|
|
42581
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
|
+
}
|
|
42582
42657
|
});
|
|
42583
42658
|
}
|
|
42584
42659
|
function abRender_fence(md, options) {
|