markdown-it-any-block 3.2.12 → 3.3.1
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 +236 -170
- package/dist/mdit-any-block.cjs.map +1 -1
- package/dist/mdit-any-block.js +236 -170
- package/dist/mdit-any-block.js.map +1 -1
- package/docs/README.md +1 -0
- package/index_mdit.ts +71 -88
- package/package.json +1 -1
- package/styles.css +1 -0
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)*)(\|(.*)\|)/,
|
|
@@ -202,30 +204,33 @@ const ABReg = {
|
|
|
202
204
|
// 内联切分。`|`或全角符号+一空格,半角符号+两空格 (后者由于空格压缩,若经历了重渲染可能有问题)
|
|
203
205
|
};
|
|
204
206
|
const ABCSetting = {
|
|
205
|
-
env: "obsidian"
|
|
207
|
+
env: "obsidian",
|
|
208
|
+
// MarkdownPostProcessorContext类型, obsidian专用
|
|
209
|
+
mermaid: void 0
|
|
210
|
+
// obsidian专用,表示使用哪种方式渲染mermaid
|
|
206
211
|
};
|
|
207
212
|
function autoABAlias(header, selectorName, content) {
|
|
208
213
|
if (!header.trimEnd().endsWith("|")) header = header + "|";
|
|
209
214
|
if (!header.trimStart().startsWith("|")) header = "|" + header;
|
|
210
215
|
if (selectorName == "mdit") {
|
|
211
|
-
header = "|:::
|
|
216
|
+
header = "|:::_140lne" + header.trimStart();
|
|
212
217
|
} else if (selectorName == "list" || ABReg.reg_list_noprefix.test(content.trimStart())) {
|
|
213
|
-
header = "|
|
|
218
|
+
header = "|list_140lne" + header;
|
|
214
219
|
} else if (selectorName == "heading" || ABReg.reg_heading_noprefix.test(content.trimStart())) {
|
|
215
|
-
header = "|
|
|
220
|
+
header = "|heading_140lne" + header;
|
|
216
221
|
} else if (selectorName == "code" || ABReg.reg_code_noprefix.test(content.trimStart())) {
|
|
217
|
-
header = "|
|
|
222
|
+
header = "|code_140lne" + header;
|
|
218
223
|
} else if (selectorName == "quote" || ABReg.reg_quote_noprefix.test(content.trimStart())) {
|
|
219
|
-
header = "|
|
|
224
|
+
header = "|quote_140lne" + header;
|
|
220
225
|
} else if (selectorName == "table" || ABReg.reg_table_noprefix.test(content.trimStart())) {
|
|
221
|
-
header = "|
|
|
226
|
+
header = "|table_140lne" + header;
|
|
222
227
|
}
|
|
223
228
|
for (const item of ABAlias_json) {
|
|
224
229
|
header = header.replace(item.regex, item.replacement);
|
|
225
230
|
}
|
|
226
231
|
for (const item of ABAlias_json_withSub) {
|
|
227
232
|
header = header.replace(item.regex, (match, ...groups) => {
|
|
228
|
-
return item.replacement.replace(/\$(\d+)/g, (_, number) => groups[number - 1]);
|
|
233
|
+
return item.replacement.replace(/\$(\d+)/g, (_, number) => groups[number - 1] ?? "");
|
|
229
234
|
});
|
|
230
235
|
}
|
|
231
236
|
for (const item of ABAlias_json_end) {
|
|
@@ -234,73 +239,93 @@ function autoABAlias(header, selectorName, content) {
|
|
|
234
239
|
return header;
|
|
235
240
|
}
|
|
236
241
|
const ABAlias_json_withSub = [
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
//
|
|
242
|
+
// 分下类,排下序
|
|
243
|
+
// `gfm` 就支持五种: note, tip, important, warning, caution
|
|
244
|
+
// `vuepress` 比gfm多了个: info
|
|
245
|
+
// `obsidian` 不完全是gfm超集,其important和tip一样,caution和warning一样
|
|
246
|
+
// note
|
|
247
|
+
// abstract, summary, tldr
|
|
248
|
+
// info
|
|
249
|
+
// todo
|
|
250
|
+
// tip. hint, Important
|
|
251
|
+
// succcess, check, done
|
|
252
|
+
// question, help, faq
|
|
253
|
+
// warning, caution, attention
|
|
254
|
+
// failure, fail, missing
|
|
255
|
+
// danger, error
|
|
256
|
+
// bug
|
|
257
|
+
// example
|
|
258
|
+
// quote, cite
|
|
259
|
+
// `其他` 避免错字, 我之前加过 warn, tips。后面又删了
|
|
260
|
+
{ 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|" },
|
|
261
|
+
{ regex: /\|(callout|alert) ([^+-\s]+)([+-]?)\s?(.*)\|/, replacement: "|add([!$2]$3 $4)|addQuote|" }
|
|
262
|
+
// 注意避免和原上/上面的callout语法冲突,以及自身递归
|
|
240
263
|
];
|
|
241
264
|
const ABAlias_json_mdit = [
|
|
242
|
-
{ regex: /\|:::
|
|
243
|
-
{ regex: "|:::
|
|
244
|
-
{ regex: "|:::
|
|
245
|
-
{ regex: /\|:::
|
|
246
|
-
{ regex: /\|:::
|
|
247
|
-
{ regex: /\|:::
|
|
265
|
+
{ regex: /\|:::_140lne\|(2?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
|
|
266
|
+
{ regex: "|:::_140lne|demo|", replacement: "|mditDemo|" },
|
|
267
|
+
{ regex: "|:::_140lne|abDemo|", replacement: "|mditABDemo|" },
|
|
268
|
+
{ regex: /\|:::_140lne\|(2?col|分栏)\|/, replacement: "|mditCol|" },
|
|
269
|
+
{ regex: /\|:::_140lne\|(2?card|卡片)\|/, replacement: "|mditCard|" },
|
|
270
|
+
{ regex: /\|:::_140lne\|(2?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" }
|
|
248
271
|
];
|
|
249
272
|
const ABAlias_json_title = [
|
|
250
273
|
{ regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" },
|
|
251
274
|
// title - list&title
|
|
252
|
-
{ regex: /\|
|
|
253
|
-
{ regex: /\|
|
|
254
|
-
{ regex: /\|
|
|
255
|
-
{ regex: /\|
|
|
256
|
-
{ regex: /\|
|
|
275
|
+
{ regex: /\|heading_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|" },
|
|
276
|
+
{ regex: /\|heading_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|" },
|
|
277
|
+
{ regex: /\|heading_140lne\|2?(col|分栏)\||\|title2col\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-col)|" },
|
|
278
|
+
{ regex: /\|heading_140lne\|2?(card|卡片)\||\|title2card\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|" },
|
|
279
|
+
{ regex: /\|heading_140lne\|2?(nodes?|节点)\||\|(title2node|title2abMindmap)\|/, replacement: "|title2listdata|listdata2strict|listdata2nodes|" },
|
|
257
280
|
// list - 多叉多层树
|
|
258
|
-
{ regex: /\|
|
|
259
|
-
{ regex: /\|
|
|
260
|
-
{ regex: /\|
|
|
261
|
-
{ regex: /\|
|
|
262
|
-
{ regex: /\|
|
|
263
|
-
{ regex: /\|
|
|
281
|
+
{ regex: /\|heading_140lne\|2?(mermaid|flow|流程图)\|/, replacement: "|title2list|list2mermaid|" },
|
|
282
|
+
{ regex: /\|heading_140lne\|2?(mehrmaid|mdmermaid)\|/, replacement: "|title2list|list2mehrmaidText|code(mehrmaid)|" },
|
|
283
|
+
{ regex: /\|heading_140lne\|2?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|title2list|list2pumlMindmap|" },
|
|
284
|
+
{ regex: /\|heading_140lne\|2?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|title2list|list2markmap|" },
|
|
285
|
+
{ regex: /\|heading_140lne\|2?(wbs|(工作)?分解(图|结构))\|/, replacement: "|title2list|list2pumlWBS|" },
|
|
286
|
+
{ regex: /\|heading_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|title2list|list2table|" },
|
|
264
287
|
// list - lt树 (属于多层一叉树)
|
|
265
|
-
{ regex: /\|
|
|
266
|
-
{ regex: /\|
|
|
267
|
-
{ regex: /\|
|
|
288
|
+
{ regex: /\|heading_140lne\|2?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|title2list|list2lt|" },
|
|
289
|
+
{ regex: /\|heading_140lne\|2?(list|列表)\|/, replacement: "|title2list|list2lt|addClass(ab-listtable-likelist)|" },
|
|
290
|
+
{ regex: /\|heading_140lne\|2?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|title2list|list2dt|" },
|
|
268
291
|
// list - 二层树
|
|
269
|
-
{ regex: /\|
|
|
292
|
+
{ regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" }
|
|
270
293
|
];
|
|
271
294
|
const ABAlias_json_list = [
|
|
272
295
|
{ regex: "|listXinline|", replacement: "|list2listdata|listdata2list|" },
|
|
273
296
|
// list - list&title
|
|
274
|
-
{ regex: /\|
|
|
275
|
-
{ regex: /\|
|
|
276
|
-
{ regex: /\|
|
|
277
|
-
{ regex: /\|
|
|
278
|
-
{ regex: /\|
|
|
297
|
+
{ regex: /\|list_140lne\|2?(timeline|时间线)\|/, replacement: "|list2timeline|" },
|
|
298
|
+
{ regex: /\|list_140lne\|2?(tabs?|标签页?)\||\|list2tabs?\|/, replacement: "|list2c2listdata|c2listdata2tab|" },
|
|
299
|
+
{ regex: /\|list_140lne\|2?(col|分栏)\||\|list2col\|/, replacement: "|list2c2listdata|c2listdata2items|addClass(ab-col)|" },
|
|
300
|
+
{ regex: /\|list_140lne\|2?(card|卡片)\||\|list2card\|/, replacement: "|list2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|" },
|
|
301
|
+
{ regex: /\|list_140lne\|2?(nodes?|节点)\||\|(list2node|list2abMindmap)\|/, replacement: "|list2listdata|listdata2strict|listdata2nodes|" },
|
|
279
302
|
// list - 多叉多层树
|
|
280
|
-
{ regex: /\|
|
|
281
|
-
{ regex: /\|
|
|
282
|
-
{ regex: /\|
|
|
283
|
-
{ regex: /\|
|
|
284
|
-
{ regex: /\|
|
|
285
|
-
{ regex: /\|
|
|
303
|
+
{ regex: /\|list_140lne\|2?(mermaid|flow|流程图)\|/, replacement: "|list2mermaid|" },
|
|
304
|
+
{ regex: /\|list_140lne\|2?(mehrmaid|mdmermaid)\|/, replacement: "|list2mehrmaidText|code(mehrmaid)|" },
|
|
305
|
+
{ regex: /\|list_140lne\|2?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|list2pumlMindmap|" },
|
|
306
|
+
{ regex: /\|list_140lne\|2?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|list2markmap|" },
|
|
307
|
+
{ regex: /\|list_140lne\|2?(wbs|(工作)?分解(图|结构))\|/, replacement: "|list2pumlWBS|" },
|
|
308
|
+
{ regex: /\|list_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|list2table|" },
|
|
286
309
|
// list - lt树 (属于多层一叉树)
|
|
287
|
-
{ regex: /\|
|
|
288
|
-
{ regex: /\|
|
|
289
|
-
{ regex: /\|
|
|
310
|
+
{ regex: /\|list_140lne\|2?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|list2lt|" },
|
|
311
|
+
{ regex: /\|list_140lne\|2?(list|列表)\|/, replacement: "|list2lt|addClass(ab-listtable-likelist)|" },
|
|
312
|
+
{ regex: /\|list_140lne\|2?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|list2dt|" },
|
|
290
313
|
// list - 二层树
|
|
291
|
-
{ regex: /\|
|
|
314
|
+
{ regex: /\|list_140lne\|(fakeList|仿列表)\|/, replacement: "|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" }
|
|
292
315
|
];
|
|
293
316
|
const ABAlias_json_code = [
|
|
294
|
-
{ regex: "|
|
|
295
|
-
{ regex: "|
|
|
317
|
+
{ regex: "|code_140lne|X|", replacement: "|xCode|" },
|
|
318
|
+
{ regex: "|code_140lne|x|", replacement: "|xCode|" },
|
|
319
|
+
{ regex: "|code2list|", replacement: "|xCode|region2indent|addList|" },
|
|
296
320
|
{ regex: "|list2code|", replacement: "|xList|code(js)|" }
|
|
297
321
|
];
|
|
298
322
|
const ABAlias_json_quote = [
|
|
299
|
-
{
|
|
323
|
+
// {regex: "|quote_140lne|X|", replacement: "|xQuote|"},
|
|
324
|
+
// {regex: "|quote_140lne|x|", replacement: "|xQuote|"},
|
|
300
325
|
];
|
|
301
326
|
const ABAlias_json_table = [];
|
|
302
327
|
const ABAlias_json_general = [
|
|
303
|
-
{ regex: "|黑幕|", replacement: "|
|
|
328
|
+
{ regex: "|黑幕|", replacement: "|addClass(ab-deco-heimu)|" },
|
|
304
329
|
{ regex: "|折叠|", replacement: "|fold|" },
|
|
305
330
|
{ regex: "|滚动|", replacement: "|scroll|" },
|
|
306
331
|
{ regex: "|超出折叠|", replacement: "|overfold|" },
|
|
@@ -356,12 +381,12 @@ let ABAlias_json = [
|
|
|
356
381
|
// 设置决定是否停用
|
|
357
382
|
];
|
|
358
383
|
const ABAlias_json_end = [
|
|
359
|
-
{ regex: "|:::
|
|
360
|
-
{ regex: "|
|
|
361
|
-
{ regex: "|
|
|
362
|
-
{ regex: "|
|
|
363
|
-
{ regex: "|
|
|
364
|
-
{ regex: "|
|
|
384
|
+
{ regex: "|:::_140lne", replacement: "" },
|
|
385
|
+
{ regex: "|heading_140lne", replacement: "" },
|
|
386
|
+
{ regex: "|list_140lne", replacement: "" },
|
|
387
|
+
{ regex: "|code_140lne", replacement: "" },
|
|
388
|
+
{ regex: "|qutoe_140lne", replacement: "" },
|
|
389
|
+
{ regex: "|table_140lne", replacement: "" }
|
|
365
390
|
];
|
|
366
391
|
class ABConvertManager {
|
|
367
392
|
/// 构造函数
|
|
@@ -567,7 +592,7 @@ ABConvert.factory({
|
|
|
567
592
|
const abc_xQuote = ABConvert.factory({
|
|
568
593
|
id: "xQuote",
|
|
569
594
|
name: "去除引用块",
|
|
570
|
-
match:
|
|
595
|
+
match: /^(xQuote|Xquote)$/,
|
|
571
596
|
detail: "在文本的每行前面删除 `> `",
|
|
572
597
|
process_param: ABConvert_IOEnum.text,
|
|
573
598
|
process_return: ABConvert_IOEnum.text,
|
|
@@ -777,6 +802,34 @@ ABConvert.factory({
|
|
|
777
802
|
return newContent.slice(1);
|
|
778
803
|
}
|
|
779
804
|
});
|
|
805
|
+
ABConvert.factory({
|
|
806
|
+
id: "mdit2code",
|
|
807
|
+
name: "mdit转代码块",
|
|
808
|
+
detail: "mdit转代码块 (允许嵌套)。注意 `:*n` 会转化为 `~*(n+3)`, `@aaa bbb` 会转换为 `# bbb` (h1标题)",
|
|
809
|
+
process_param: ABConvert_IOEnum.text,
|
|
810
|
+
process_return: ABConvert_IOEnum.text,
|
|
811
|
+
process: (el, header, content) => {
|
|
812
|
+
const lists = content.trimEnd().split("\n");
|
|
813
|
+
let newContent = "";
|
|
814
|
+
for (let i = 0; i < lists.length; i++) {
|
|
815
|
+
const item = lists[i];
|
|
816
|
+
const match = item.match(ABReg.reg_mdit_head);
|
|
817
|
+
const match2 = item.trim().match(/^@(\S*?)\s(.*?)$/);
|
|
818
|
+
if (match2) {
|
|
819
|
+
newContent += "\n# " + match2[2];
|
|
820
|
+
} else if (match) {
|
|
821
|
+
const flag = "~".repeat(match[3].length + 3);
|
|
822
|
+
if (match[4].trim() !== "") newContent += "\n" + flag + "anyblock\n[" + match[4].trimStart() + "]";
|
|
823
|
+
else newContent += "\n" + flag;
|
|
824
|
+
continue;
|
|
825
|
+
} else {
|
|
826
|
+
newContent += "\n" + item;
|
|
827
|
+
continue;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
return newContent.slice(1);
|
|
831
|
+
}
|
|
832
|
+
});
|
|
780
833
|
class ListProcess {
|
|
781
834
|
// ----------------------- str -> listData ------------------------
|
|
782
835
|
/**
|
|
@@ -952,7 +1005,7 @@ class ListProcess {
|
|
|
952
1005
|
let codeBlockFlag = "";
|
|
953
1006
|
for (let line of list_text) {
|
|
954
1007
|
if (codeBlockFlag == "") {
|
|
955
|
-
const match = line.match(
|
|
1008
|
+
const match = line.match(ABReg.reg_code);
|
|
956
1009
|
if (match && match[3]) {
|
|
957
1010
|
codeBlockFlag = match[1] + match[3];
|
|
958
1011
|
list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
|
|
@@ -1453,7 +1506,7 @@ class C2ListProcess {
|
|
|
1453
1506
|
let codeBlockFlag = "";
|
|
1454
1507
|
for (const line of list_text) {
|
|
1455
1508
|
if (codeBlockFlag == "") {
|
|
1456
|
-
const match = line.match(
|
|
1509
|
+
const match = line.match(ABReg.reg_code);
|
|
1457
1510
|
if (match && match[3]) {
|
|
1458
1511
|
codeBlockFlag = match[1] + match[3];
|
|
1459
1512
|
current_content += line + "\n";
|
|
@@ -1915,8 +1968,8 @@ class DirProcess {
|
|
|
1915
1968
|
}
|
|
1916
1969
|
}
|
|
1917
1970
|
list_itemInfo2.push({
|
|
1918
|
-
content: list_column_item[column_index],
|
|
1919
|
-
// modi
|
|
1971
|
+
content: list_column_item[column_index].trimEnd(),
|
|
1972
|
+
// modi, 使用内联分割符时,尾空白应该总是无用的
|
|
1920
1973
|
level: row_item.level,
|
|
1921
1974
|
tableRow: row_index,
|
|
1922
1975
|
// modi
|
|
@@ -1989,7 +2042,7 @@ class DirProcess {
|
|
|
1989
2042
|
if (!is_head) {
|
|
1990
2043
|
if (cell_item.type == "folder") {
|
|
1991
2044
|
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);
|
|
2045
|
+
cell_item.content = cell_item.content.trimEnd().slice(0, -1);
|
|
1993
2046
|
} else {
|
|
1994
2047
|
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
2048
|
}
|
|
@@ -1998,7 +2051,11 @@ class DirProcess {
|
|
|
1998
2051
|
const td_cell = document.createElement("div");
|
|
1999
2052
|
td.appendChild(td_cell);
|
|
2000
2053
|
td_cell.classList.add("ab-list-table-witharrow");
|
|
2001
|
-
|
|
2054
|
+
if (cell_item.tableColumn == 0 && is_folder) {
|
|
2055
|
+
td_cell.innerHTML = cell_item.content;
|
|
2056
|
+
} else {
|
|
2057
|
+
ABConvertManager.getInstance().m_renderMarkdownFn(cell_item.content, td_cell);
|
|
2058
|
+
}
|
|
2002
2059
|
}
|
|
2003
2060
|
}
|
|
2004
2061
|
{
|
|
@@ -2162,7 +2219,7 @@ function listdata2dirdata(list) {
|
|
|
2162
2219
|
for (let i = 0; i < list.length; i++) {
|
|
2163
2220
|
const item = list[i];
|
|
2164
2221
|
let type;
|
|
2165
|
-
if (item.content.endsWith("/")) {
|
|
2222
|
+
if (item.content.trimEnd().endsWith("/")) {
|
|
2166
2223
|
type = "folder";
|
|
2167
2224
|
} else {
|
|
2168
2225
|
const parts = item.content.split(".");
|
|
@@ -2278,23 +2335,22 @@ ABConvert.factory({
|
|
|
2278
2335
|
sub_button.onclick = fn_fold;
|
|
2279
2336
|
mid_el.appendChild(sub_button);
|
|
2280
2337
|
mid_el.appendChild(sub_el);
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
}
|
|
2338
|
+
const isListTable = sub_el.classList.contains("ab-list-table-parent");
|
|
2339
|
+
const listTable_btn = sub_el.querySelector(".ab-table-fold");
|
|
2340
|
+
if (isListTable && listTable_btn) {
|
|
2341
|
+
if (ABCSetting.env == "obsidian" || ABCSetting.env == "obsidian-min") {
|
|
2342
|
+
fn_fold();
|
|
2343
|
+
sub_button.textContent = "折叠/展开";
|
|
2344
|
+
const fn_fold2 = () => {
|
|
2345
|
+
const clickEvent = new MouseEvent("click", {
|
|
2346
|
+
view: window,
|
|
2347
|
+
bubbles: true,
|
|
2348
|
+
cancelable: true
|
|
2349
|
+
});
|
|
2350
|
+
listTable_btn.dispatchEvent(clickEvent);
|
|
2351
|
+
};
|
|
2352
|
+
fn_fold2();
|
|
2353
|
+
sub_button.onclick = fn_fold2;
|
|
2298
2354
|
}
|
|
2299
2355
|
}
|
|
2300
2356
|
return content;
|
|
@@ -2303,18 +2359,17 @@ ABConvert.factory({
|
|
|
2303
2359
|
ABConvert.factory({
|
|
2304
2360
|
id: "scroll",
|
|
2305
2361
|
name: "滚动",
|
|
2306
|
-
match: /^scroll(\((\d+)\))
|
|
2362
|
+
match: /^scroll(X)?(\((\d+)\))?$/,
|
|
2307
2363
|
default: "scroll(460)",
|
|
2364
|
+
detail: "默认是纵向滚动。可以指定溢出滚动的范围,可以使用scrollX进行横向滚动",
|
|
2308
2365
|
process_param: ABConvert_IOEnum.el,
|
|
2309
2366
|
process_return: ABConvert_IOEnum.el,
|
|
2310
2367
|
process: (el, header, content) => {
|
|
2311
|
-
const matchs = header.match(/^scroll(\((\d+)\))
|
|
2368
|
+
const matchs = header.match(/^scroll(X)?(\((\d+)\))?$/);
|
|
2312
2369
|
if (!matchs) return content;
|
|
2313
|
-
let arg1;
|
|
2314
|
-
if (
|
|
2315
|
-
|
|
2316
|
-
if (!matchs[2]) return content;
|
|
2317
|
-
arg1 = Number(matchs[2]);
|
|
2370
|
+
let arg1 = 0;
|
|
2371
|
+
if (matchs[2] && matchs[3]) {
|
|
2372
|
+
arg1 = Number(matchs[3]);
|
|
2318
2373
|
if (isNaN(arg1)) return content;
|
|
2319
2374
|
}
|
|
2320
2375
|
if (content.children.length != 1) return content;
|
|
@@ -2323,13 +2378,14 @@ ABConvert.factory({
|
|
|
2323
2378
|
const mid_el = document.createElement("div");
|
|
2324
2379
|
content.appendChild(mid_el);
|
|
2325
2380
|
mid_el.classList.add("ab-deco-scroll");
|
|
2326
|
-
|
|
2381
|
+
mid_el.appendChild(sub_el);
|
|
2382
|
+
if (!matchs[1]) {
|
|
2327
2383
|
mid_el.classList.add("ab-deco-scroll-y");
|
|
2328
|
-
mid_el.setAttribute("style", `max-height: ${arg1}
|
|
2384
|
+
mid_el.setAttribute("style", `max-height: ${arg1 !== 0 ? arg1 + "px" : "460px"}`);
|
|
2329
2385
|
} else {
|
|
2330
2386
|
mid_el.classList.add("ab-deco-scroll-x");
|
|
2387
|
+
mid_el.setAttribute("style", `max-height: ${arg1 !== 0 ? arg1 + "px" : "100%"}`);
|
|
2331
2388
|
}
|
|
2332
|
-
mid_el.appendChild(sub_el);
|
|
2333
2389
|
return content;
|
|
2334
2390
|
}
|
|
2335
2391
|
});
|
|
@@ -2407,7 +2463,7 @@ ABConvert.factory({
|
|
|
2407
2463
|
}
|
|
2408
2464
|
return content;
|
|
2409
2465
|
}
|
|
2410
|
-
const table = content.
|
|
2466
|
+
const table = content.querySelector("table");
|
|
2411
2467
|
if (table !== null) {
|
|
2412
2468
|
table.style.tableLayout = "fixed";
|
|
2413
2469
|
table.style.width = args.some((arg) => arg.endsWith("%")) ? "100%" : "fit-content";
|
|
@@ -2850,9 +2906,8 @@ ABConvert.factory({
|
|
|
2850
2906
|
}
|
|
2851
2907
|
});
|
|
2852
2908
|
ABConvert.factory({
|
|
2853
|
-
id: "
|
|
2909
|
+
id: "info_converter",
|
|
2854
2910
|
name: "INFO",
|
|
2855
|
-
match: "info",
|
|
2856
2911
|
detail: "查看当前软件版本下的注册处理器表",
|
|
2857
2912
|
process_param: ABConvert_IOEnum.text,
|
|
2858
2913
|
process_return: ABConvert_IOEnum.el,
|
|
@@ -3017,7 +3072,27 @@ ABConvert.factory({
|
|
|
3017
3072
|
process_param: ABConvert_IOEnum.text,
|
|
3018
3073
|
process_return: ABConvert_IOEnum.el,
|
|
3019
3074
|
process: (el, header, content) => {
|
|
3020
|
-
|
|
3075
|
+
if (ABCSetting.env == "vuepress") {
|
|
3076
|
+
ABConvertManager.getInstance().m_renderMarkdownFn(`::::: tabs
|
|
3077
|
+
|
|
3078
|
+
@tab show
|
|
3079
|
+
|
|
3080
|
+
${content}
|
|
3081
|
+
|
|
3082
|
+
@tab withoutPlugin
|
|
3083
|
+
|
|
3084
|
+
(noPlugin)${content.trimStart()}
|
|
3085
|
+
|
|
3086
|
+
@tab mdSource
|
|
3087
|
+
|
|
3088
|
+
~~~~~md
|
|
3089
|
+
${content}
|
|
3090
|
+
~~~~~
|
|
3091
|
+
|
|
3092
|
+
:::::`, el);
|
|
3093
|
+
return el;
|
|
3094
|
+
} else {
|
|
3095
|
+
const newContent = `@tab show
|
|
3021
3096
|
${content}
|
|
3022
3097
|
@tab withoutPlugin
|
|
3023
3098
|
(noPlugin)${content.trimStart()}
|
|
@@ -3025,8 +3100,9 @@ ${content}
|
|
|
3025
3100
|
~~~~~md
|
|
3026
3101
|
${content}
|
|
3027
3102
|
~~~~~`;
|
|
3028
|
-
|
|
3029
|
-
|
|
3103
|
+
abc_mditTabs.process(el, header, newContent);
|
|
3104
|
+
return el;
|
|
3105
|
+
}
|
|
3030
3106
|
}
|
|
3031
3107
|
});
|
|
3032
3108
|
ABConvert.factory({
|
|
@@ -7828,11 +7904,6 @@ function list2ActivityDiagramText(listdata) {
|
|
|
7828
7904
|
let result = "@startuml\n";
|
|
7829
7905
|
const stats = listdata.map((item) => new Stat(item.content.trim(), item.level));
|
|
7830
7906
|
const { result: bodyResult } = processBlock(stats, 0, -1);
|
|
7831
|
-
const swimLanes = bodyResult.split("\n").filter((line) => line.startsWith("|") && line.endsWith("|"));
|
|
7832
|
-
if (swimLanes.length > 0) {
|
|
7833
|
-
result += swimLanes.join("\n");
|
|
7834
|
-
result += "\n";
|
|
7835
|
-
}
|
|
7836
7907
|
result += bodyResult;
|
|
7837
7908
|
result += "@enduml";
|
|
7838
7909
|
return result;
|
|
@@ -7911,7 +7982,6 @@ async function render_pumlText(text2, div) {
|
|
|
7911
7982
|
div.innerHTML = `<img src="${url}">`;
|
|
7912
7983
|
return div;
|
|
7913
7984
|
}
|
|
7914
|
-
let mermaid = null;
|
|
7915
7985
|
function getID(length = 16) {
|
|
7916
7986
|
return Number(Math.random().toString().substr(3, length) + Date.now()).toString(36);
|
|
7917
7987
|
}
|
|
@@ -8084,21 +8154,17 @@ async function data2mindmap(list_itemInfo, div) {
|
|
|
8084
8154
|
return render_mermaidText(mermaidText, div);
|
|
8085
8155
|
}
|
|
8086
8156
|
async function render_mermaidText(mermaidText, div) {
|
|
8087
|
-
if (ABCSetting.env == "obsidian") {
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
ABConvertManager.getInstance().m_renderMarkdownFn("```mermaid\n" + mermaidText + "\n```", div);
|
|
8157
|
+
if ((ABCSetting.env == "obsidian" || ABCSetting.env == "obsidian-min") && ABCSetting.mermaid) {
|
|
8158
|
+
ABCSetting.mermaid.then(async (mermaid) => {
|
|
8159
|
+
const { svg } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
|
|
8160
|
+
div.innerHTML = svg;
|
|
8161
|
+
});
|
|
8093
8162
|
} else {
|
|
8094
8163
|
div.classList.add("ab-raw");
|
|
8095
8164
|
div.innerHTML = `<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`;
|
|
8096
8165
|
}
|
|
8097
8166
|
return div;
|
|
8098
8167
|
}
|
|
8099
|
-
async function init_mermaid() {
|
|
8100
|
-
if (ABCSetting.env !== "obsidian" || true) return;
|
|
8101
|
-
}
|
|
8102
8168
|
function abConvertEvent(d, isCycle = false) {
|
|
8103
8169
|
if (d.querySelector(".ab-super-width")) {
|
|
8104
8170
|
const els_note = d.querySelectorAll(".ab-note");
|
|
@@ -42437,13 +42503,13 @@ function abSelector_squareInline(md, options) {
|
|
|
42437
42503
|
return;
|
|
42438
42504
|
}
|
|
42439
42505
|
if (text2.trim() == "") {
|
|
42440
|
-
if (ab_blankLine_counter
|
|
42506
|
+
if (ab_blockType == "list" && ab_blankLine_counter >= 1) {
|
|
42507
|
+
return;
|
|
42508
|
+
} else {
|
|
42441
42509
|
ab_blankLine_counter++;
|
|
42442
42510
|
ab_content += "\n";
|
|
42443
42511
|
state.line += 1;
|
|
42444
42512
|
return findAbEnd();
|
|
42445
|
-
} else {
|
|
42446
|
-
return;
|
|
42447
42513
|
}
|
|
42448
42514
|
} else {
|
|
42449
42515
|
ab_blankLine_counter = 0;
|
|
@@ -42485,7 +42551,7 @@ function abSelector_squareInline(md, options) {
|
|
|
42485
42551
|
}
|
|
42486
42552
|
} else if (ab_blockType == "heading") {
|
|
42487
42553
|
if (codeBlockFlag == "") {
|
|
42488
|
-
const match = text2.match(
|
|
42554
|
+
const match = text2.match(ABReg.reg_code);
|
|
42489
42555
|
if (match && match[3]) {
|
|
42490
42556
|
codeBlockFlag = match[1] + match[3];
|
|
42491
42557
|
ab_content += "\n" + text2;
|
|
@@ -42523,62 +42589,62 @@ function abSelector_squareInline(md, options) {
|
|
|
42523
42589
|
});
|
|
42524
42590
|
}
|
|
42525
42591
|
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
|
-
}
|
|
42592
|
+
md.block.ruler.before("fence", "AnyBlockMditContainer", (state, startLine, endLine) => {
|
|
42593
|
+
const mdit_whitelist = ["mditABDemo"];
|
|
42594
|
+
const mdit_blacklist = [
|
|
42595
|
+
// "left", "center", "right", "justify", // https://mdit-plugins.github.io/zh/align.html
|
|
42596
|
+
// "note", "warning", "tip", "info", // https://mdit-plugins.github.io/zh/container.html
|
|
42597
|
+
// "demo", "md-demo", "codedemo",
|
|
42598
|
+
// "tabs", // TODO: 可能是 `tabs#fruit` 这种形式的,应该改成手动循环判断,不能以这些开头
|
|
42599
|
+
];
|
|
42600
|
+
let mdit_header;
|
|
42601
|
+
let mdit_match;
|
|
42602
|
+
{
|
|
42603
|
+
state.line = startLine;
|
|
42604
|
+
const pos = state.bMarks[state.line];
|
|
42605
|
+
const max = state.eMarks[state.line];
|
|
42606
|
+
mdit_header = state.src.substring(pos, max);
|
|
42607
|
+
mdit_match = mdit_header.match(ABReg.reg_mdit_head);
|
|
42608
|
+
if (!mdit_match || !mdit_match.length) return false;
|
|
42609
|
+
if (mdit_whitelist.length && !mdit_whitelist.includes(mdit_match[4].split("|")[0].trim())) {
|
|
42610
|
+
return false;
|
|
42611
|
+
}
|
|
42612
|
+
if (mdit_blacklist.length && mdit_blacklist.includes(mdit_match[4].split("|")[0].trim())) {
|
|
42613
|
+
return false;
|
|
42570
42614
|
}
|
|
42571
|
-
ab_content += "\n" + state.src.substring(start, max);
|
|
42572
42615
|
}
|
|
42573
|
-
|
|
42616
|
+
const mdit_flag = mdit_match[3];
|
|
42617
|
+
const mdit_type = mdit_match[4];
|
|
42618
|
+
const mdit_startLine = state.line;
|
|
42619
|
+
let mdit_content = "";
|
|
42620
|
+
state.line += 1;
|
|
42621
|
+
findMditEnd();
|
|
42622
|
+
const mdit_endLine = state.line;
|
|
42574
42623
|
const token = state.push("fence", "code", 0);
|
|
42575
42624
|
token.info = "AnyBlock";
|
|
42576
|
-
token.content = `[${
|
|
42577
|
-
${
|
|
42578
|
-
token.map = [
|
|
42579
|
-
token.markup =
|
|
42625
|
+
token.content = `[${mdit_type}]
|
|
42626
|
+
${mdit_content}`;
|
|
42627
|
+
token.map = [mdit_startLine, mdit_endLine];
|
|
42628
|
+
token.markup = mdit_flag;
|
|
42580
42629
|
token.nesting = 0;
|
|
42581
42630
|
return true;
|
|
42631
|
+
function findMditEnd() {
|
|
42632
|
+
const pos = state.bMarks[state.line];
|
|
42633
|
+
const max = state.eMarks[state.line];
|
|
42634
|
+
const text2 = state.src.substring(pos, max);
|
|
42635
|
+
if (state.line > endLine) {
|
|
42636
|
+
state.line = endLine + 1;
|
|
42637
|
+
return;
|
|
42638
|
+
}
|
|
42639
|
+
if (text2.trim() == mdit_flag) {
|
|
42640
|
+
state.line += 1;
|
|
42641
|
+
return;
|
|
42642
|
+
} else {
|
|
42643
|
+
mdit_content += "\n" + text2;
|
|
42644
|
+
state.line += 1;
|
|
42645
|
+
return findMditEnd();
|
|
42646
|
+
}
|
|
42647
|
+
}
|
|
42582
42648
|
});
|
|
42583
42649
|
}
|
|
42584
42650
|
function abRender_fence(md, options) {
|