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.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
|
/// 构造函数
|
|
@@ -543,7 +565,7 @@ ABConvert.factory({
|
|
|
543
565
|
const abc_xQuote = ABConvert.factory({
|
|
544
566
|
id: "xQuote",
|
|
545
567
|
name: "去除引用块",
|
|
546
|
-
match:
|
|
568
|
+
match: /^(xQuote|Xquote)$/,
|
|
547
569
|
detail: "在文本的每行前面删除 `> `",
|
|
548
570
|
process_param: ABConvert_IOEnum.text,
|
|
549
571
|
process_return: ABConvert_IOEnum.text,
|
|
@@ -753,6 +775,34 @@ ABConvert.factory({
|
|
|
753
775
|
return newContent.slice(1);
|
|
754
776
|
}
|
|
755
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
|
+
});
|
|
756
806
|
class ListProcess {
|
|
757
807
|
// ----------------------- str -> listData ------------------------
|
|
758
808
|
/**
|
|
@@ -928,7 +978,7 @@ class ListProcess {
|
|
|
928
978
|
let codeBlockFlag = "";
|
|
929
979
|
for (let line of list_text) {
|
|
930
980
|
if (codeBlockFlag == "") {
|
|
931
|
-
const match = line.match(
|
|
981
|
+
const match = line.match(ABReg.reg_code);
|
|
932
982
|
if (match && match[3]) {
|
|
933
983
|
codeBlockFlag = match[1] + match[3];
|
|
934
984
|
list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
|
|
@@ -1429,7 +1479,7 @@ class C2ListProcess {
|
|
|
1429
1479
|
let codeBlockFlag = "";
|
|
1430
1480
|
for (const line of list_text) {
|
|
1431
1481
|
if (codeBlockFlag == "") {
|
|
1432
|
-
const match = line.match(
|
|
1482
|
+
const match = line.match(ABReg.reg_code);
|
|
1433
1483
|
if (match && match[3]) {
|
|
1434
1484
|
codeBlockFlag = match[1] + match[3];
|
|
1435
1485
|
current_content += line + "\n";
|
|
@@ -1891,8 +1941,8 @@ class DirProcess {
|
|
|
1891
1941
|
}
|
|
1892
1942
|
}
|
|
1893
1943
|
list_itemInfo2.push({
|
|
1894
|
-
content: list_column_item[column_index],
|
|
1895
|
-
// modi
|
|
1944
|
+
content: list_column_item[column_index].trimEnd(),
|
|
1945
|
+
// modi, 使用内联分割符时,尾空白应该总是无用的
|
|
1896
1946
|
level: row_item.level,
|
|
1897
1947
|
tableRow: row_index,
|
|
1898
1948
|
// modi
|
|
@@ -1965,7 +2015,7 @@ class DirProcess {
|
|
|
1965
2015
|
if (!is_head) {
|
|
1966
2016
|
if (cell_item.type == "folder") {
|
|
1967
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>`;
|
|
1968
|
-
cell_item.content = cell_item.content.slice(0, -1);
|
|
2018
|
+
cell_item.content = cell_item.content.trimEnd().slice(0, -1);
|
|
1969
2019
|
} else {
|
|
1970
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>`;
|
|
1971
2021
|
}
|
|
@@ -1974,7 +2024,11 @@ class DirProcess {
|
|
|
1974
2024
|
const td_cell = document.createElement("div");
|
|
1975
2025
|
td.appendChild(td_cell);
|
|
1976
2026
|
td_cell.classList.add("ab-list-table-witharrow");
|
|
1977
|
-
|
|
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
|
+
}
|
|
1978
2032
|
}
|
|
1979
2033
|
}
|
|
1980
2034
|
{
|
|
@@ -2138,7 +2192,7 @@ function listdata2dirdata(list) {
|
|
|
2138
2192
|
for (let i = 0; i < list.length; i++) {
|
|
2139
2193
|
const item = list[i];
|
|
2140
2194
|
let type;
|
|
2141
|
-
if (item.content.endsWith("/")) {
|
|
2195
|
+
if (item.content.trimEnd().endsWith("/")) {
|
|
2142
2196
|
type = "folder";
|
|
2143
2197
|
} else {
|
|
2144
2198
|
const parts = item.content.split(".");
|
|
@@ -2383,7 +2437,7 @@ ABConvert.factory({
|
|
|
2383
2437
|
}
|
|
2384
2438
|
return content;
|
|
2385
2439
|
}
|
|
2386
|
-
const table = content.
|
|
2440
|
+
const table = content.querySelector("table");
|
|
2387
2441
|
if (table !== null) {
|
|
2388
2442
|
table.style.tableLayout = "fixed";
|
|
2389
2443
|
table.style.width = args.some((arg) => arg.endsWith("%")) ? "100%" : "fit-content";
|
|
@@ -2993,7 +3047,27 @@ ABConvert.factory({
|
|
|
2993
3047
|
process_param: ABConvert_IOEnum.text,
|
|
2994
3048
|
process_return: ABConvert_IOEnum.el,
|
|
2995
3049
|
process: (el, header, content) => {
|
|
2996
|
-
|
|
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
|
|
2997
3071
|
${content}
|
|
2998
3072
|
@tab withoutPlugin
|
|
2999
3073
|
(noPlugin)${content.trimStart()}
|
|
@@ -3001,8 +3075,9 @@ ${content}
|
|
|
3001
3075
|
~~~~~md
|
|
3002
3076
|
${content}
|
|
3003
3077
|
~~~~~`;
|
|
3004
|
-
|
|
3005
|
-
|
|
3078
|
+
abc_mditTabs.process(el, header, newContent);
|
|
3079
|
+
return el;
|
|
3080
|
+
}
|
|
3006
3081
|
}
|
|
3007
3082
|
});
|
|
3008
3083
|
ABConvert.factory({
|
|
@@ -42413,13 +42488,13 @@ function abSelector_squareInline(md, options) {
|
|
|
42413
42488
|
return;
|
|
42414
42489
|
}
|
|
42415
42490
|
if (text2.trim() == "") {
|
|
42416
|
-
if (ab_blankLine_counter
|
|
42491
|
+
if (ab_blockType == "list" && ab_blankLine_counter >= 1) {
|
|
42492
|
+
return;
|
|
42493
|
+
} else {
|
|
42417
42494
|
ab_blankLine_counter++;
|
|
42418
42495
|
ab_content += "\n";
|
|
42419
42496
|
state.line += 1;
|
|
42420
42497
|
return findAbEnd();
|
|
42421
|
-
} else {
|
|
42422
|
-
return;
|
|
42423
42498
|
}
|
|
42424
42499
|
} else {
|
|
42425
42500
|
ab_blankLine_counter = 0;
|
|
@@ -42461,7 +42536,7 @@ function abSelector_squareInline(md, options) {
|
|
|
42461
42536
|
}
|
|
42462
42537
|
} else if (ab_blockType == "heading") {
|
|
42463
42538
|
if (codeBlockFlag == "") {
|
|
42464
|
-
const match = text2.match(
|
|
42539
|
+
const match = text2.match(ABReg.reg_code);
|
|
42465
42540
|
if (match && match[3]) {
|
|
42466
42541
|
codeBlockFlag = match[1] + match[3];
|
|
42467
42542
|
ab_content += "\n" + text2;
|
|
@@ -42499,62 +42574,62 @@ function abSelector_squareInline(md, options) {
|
|
|
42499
42574
|
});
|
|
42500
42575
|
}
|
|
42501
42576
|
function abSelector_container(md, options) {
|
|
42502
|
-
md.block.ruler.before("fence", "AnyBlockMditContainer", (state, startLine, endLine
|
|
42503
|
-
const
|
|
42504
|
-
|
|
42505
|
-
|
|
42506
|
-
|
|
42507
|
-
|
|
42508
|
-
|
|
42509
|
-
|
|
42510
|
-
|
|
42511
|
-
|
|
42512
|
-
|
|
42513
|
-
|
|
42514
|
-
|
|
42515
|
-
|
|
42516
|
-
|
|
42517
|
-
|
|
42518
|
-
|
|
42519
|
-
|
|
42520
|
-
|
|
42521
|
-
|
|
42522
|
-
|
|
42523
|
-
|
|
42524
|
-
// also block seems to be auto closed by end of parent
|
|
42525
|
-
nextLine < endLine
|
|
42526
|
-
) {
|
|
42527
|
-
nextLine++;
|
|
42528
|
-
start = state.bMarks[nextLine];
|
|
42529
|
-
max = state.eMarks[nextLine];
|
|
42530
|
-
if (start < max && state.sCount[nextLine] < state.blkIndent)
|
|
42531
|
-
break;
|
|
42532
|
-
if (
|
|
42533
|
-
// match start
|
|
42534
|
-
state.src[start] === ":" && // closing fence should be indented less than 4 spaces
|
|
42535
|
-
state.sCount[nextLine] - state.blkIndent < 4
|
|
42536
|
-
) {
|
|
42537
|
-
for (pos = start + 1; pos <= max; pos++)
|
|
42538
|
-
if (state.src[pos] !== ":") break;
|
|
42539
|
-
if (pos - start >= markerCount) {
|
|
42540
|
-
pos = state.skipSpaces(pos);
|
|
42541
|
-
if (pos >= max) {
|
|
42542
|
-
autoClosed = true;
|
|
42543
|
-
break;
|
|
42544
|
-
}
|
|
42545
|
-
}
|
|
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;
|
|
42546
42599
|
}
|
|
42547
|
-
ab_content += "\n" + state.src.substring(start, max);
|
|
42548
42600
|
}
|
|
42549
|
-
|
|
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;
|
|
42550
42608
|
const token = state.push("fence", "code", 0);
|
|
42551
42609
|
token.info = "AnyBlock";
|
|
42552
|
-
token.content = `[${
|
|
42553
|
-
${
|
|
42554
|
-
token.map = [
|
|
42555
|
-
token.markup =
|
|
42610
|
+
token.content = `[${mdit_type}]
|
|
42611
|
+
${mdit_content}`;
|
|
42612
|
+
token.map = [mdit_startLine, mdit_endLine];
|
|
42613
|
+
token.markup = mdit_flag;
|
|
42556
42614
|
token.nesting = 0;
|
|
42557
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
|
+
}
|
|
42558
42633
|
});
|
|
42559
42634
|
}
|
|
42560
42635
|
function abRender_fence(md, options) {
|