markdown-it-any-block 3.2.10 → 3.2.12

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/README.md CHANGED
@@ -10,6 +10,8 @@ markdown-it 版本的入口
10
10
 
11
11
  ```bash
12
12
  $ pnpm install -D markdown-it-any-block@latest
13
+
14
+ # 或beta/测试版 (供开发者测试使用,不建议) pnpm install -D markdown-it-any-block@beta
13
15
  ```
14
16
 
15
17
  使用 (vuepress为例,其他使用markdown-it插件的类似)
@@ -46,106 +46,6 @@ async function jsdom_init() {
46
46
  dom.window.scrollTo = () => {
47
47
  };
48
48
  }
49
- function container_plugin(md, name2, options) {
50
- function validateDefault(params) {
51
- return params.trim().split(" ", 2)[0] === name2;
52
- }
53
- function renderDefault(tokens, idx, _options, env, slf) {
54
- if (tokens[idx].nesting === 1) {
55
- tokens[idx].attrJoin("class", name2);
56
- }
57
- return slf.renderToken(tokens, idx, _options, env, slf);
58
- }
59
- options = options || {};
60
- const min_markers = 3;
61
- const marker_str = options.marker || ":";
62
- const marker_char = marker_str.charCodeAt(0);
63
- const marker_len = marker_str.length;
64
- const validate = options.validate || validateDefault;
65
- const render2 = options.render || renderDefault;
66
- function container(state, startLine, endLine, silent) {
67
- let pos;
68
- let auto_closed = false;
69
- let start = state.bMarks[startLine] + state.tShift[startLine];
70
- let max = state.eMarks[startLine];
71
- if (marker_char !== state.src.charCodeAt(start)) {
72
- return false;
73
- }
74
- for (pos = start + 1; pos <= max; pos++) {
75
- if (marker_str[(pos - start) % marker_len] !== state.src[pos]) {
76
- break;
77
- }
78
- }
79
- const marker_count = Math.floor((pos - start) / marker_len);
80
- if (marker_count < min_markers) {
81
- return false;
82
- }
83
- pos -= (pos - start) % marker_len;
84
- const markup = state.src.slice(start, pos);
85
- const params = state.src.slice(pos, max);
86
- if (!validate(params, markup)) {
87
- return false;
88
- }
89
- if (silent) {
90
- return true;
91
- }
92
- let nextLine = startLine;
93
- for (; ; ) {
94
- nextLine++;
95
- if (nextLine >= endLine) {
96
- break;
97
- }
98
- start = state.bMarks[nextLine] + state.tShift[nextLine];
99
- max = state.eMarks[nextLine];
100
- if (start < max && state.sCount[nextLine] < state.blkIndent) {
101
- break;
102
- }
103
- if (marker_char !== state.src.charCodeAt(start)) {
104
- continue;
105
- }
106
- if (state.sCount[nextLine] - state.blkIndent >= 4) {
107
- continue;
108
- }
109
- for (pos = start + 1; pos <= max; pos++) {
110
- if (marker_str[(pos - start) % marker_len] !== state.src[pos]) {
111
- break;
112
- }
113
- }
114
- if (Math.floor((pos - start) / marker_len) < marker_count) {
115
- continue;
116
- }
117
- pos -= (pos - start) % marker_len;
118
- pos = state.skipSpaces(pos);
119
- if (pos < max) {
120
- continue;
121
- }
122
- auto_closed = true;
123
- break;
124
- }
125
- const old_parent = state.parentType;
126
- const old_line_max = state.lineMax;
127
- state.parentType = "container";
128
- state.lineMax = nextLine;
129
- const token_o = state.push("container_" + name2 + "_open", "div", 1);
130
- token_o.markup = markup;
131
- token_o.block = true;
132
- token_o.info = params;
133
- token_o.map = [startLine, nextLine];
134
- state.md.block.tokenize(state, startLine + 1, nextLine);
135
- const token_c = state.push("container_" + name2 + "_close", "div", -1);
136
- token_c.markup = state.src.slice(start, pos);
137
- token_c.block = true;
138
- state.parentType = old_parent;
139
- state.lineMax = old_line_max;
140
- state.line = nextLine + (auto_closed ? 1 : 0);
141
- return true;
142
- }
143
- md.block.ruler.before("fence", "container_" + name2, container, {
144
- alt: ["paragraph", "reference", "blockquote", "list"]
145
- });
146
- md.renderer.rules["container_" + name2 + "_open"] = render2;
147
- md.renderer.rules["container_" + name2 + "_close"] = render2;
148
- }
149
49
  var ABConvert_IOEnum = /* @__PURE__ */ ((ABConvert_IOEnum2) => {
150
50
  ABConvert_IOEnum2["text"] = "string";
151
51
  ABConvert_IOEnum2["el"] = "HTMLElement";
@@ -334,8 +234,8 @@ function autoABAlias(header, selectorName, content) {
334
234
  return header;
335
235
  }
336
236
  const ABAlias_json_withSub = [
337
- { regex: /\|::: 140lne\|(info|note|warning|caution|attention|error|danger|tips|tip|hint|example|abstract|summary|tldr|quote|cite|todo|success|check|done)\s?(.*?)\|/, replacement: "|add([!$1] $2)|quote|" },
338
- { regex: /\|quote (\S+)\s?(.*)\|/, replacement: "|add([!$1] $2)|quote|" }
237
+ { regex: /\|(info|note|warning|caution|attention|error|danger|tips|tip|hint|example|abstract|summary|tldr|quote|cite|todo|success|check|done)\s?(.*?)\|/, replacement: "|add([!$1] $2)|addQuote|" },
238
+ { regex: /\|quote (\S+)\s?(.*)\|/, replacement: "|add([!$1] $2)|addQuote|" }
339
239
  // 注意避免和callout语法冲突,以及自身递归
340
240
  ];
341
241
  const ABAlias_json_mdit = [
@@ -637,9 +537,9 @@ class ABConvertManager {
637
537
  }
638
538
  }
639
539
  ABConvert.factory({
640
- id: "quote",
540
+ id: "addQuote",
641
541
  name: "增加引用块",
642
- match: /^(quote|addQuote)$/,
542
+ match: "addQuote",
643
543
  detail: "在文本的每行前面加上 `> `",
644
544
  process_param: ABConvert_IOEnum.text,
645
545
  process_return: ABConvert_IOEnum.text,
@@ -650,23 +550,24 @@ ABConvert.factory({
650
550
  }
651
551
  });
652
552
  ABConvert.factory({
653
- id: "code",
553
+ id: "addCode",
654
554
  name: "增加代码块",
655
- match: /^code(\((.*)\))?$/,
555
+ match: /^(addCode|code)(\((.*)\))?$/,
656
556
  default: "code()",
657
557
  detail: "在文本的前后均加上一行代码块围栏。不加`()`表示用原文本的第一行作为代码类型,括号类型为空表示代码类型为空",
658
558
  process_param: ABConvert_IOEnum.text,
659
559
  process_return: ABConvert_IOEnum.text,
660
560
  process: (el, header, content) => {
661
- let matchs = header.match(/^code(\((.*)\))?$/);
561
+ let matchs = header.match(/^(addCode|code)(\((.*)\))?$/);
662
562
  if (!matchs) return content;
663
- if (matchs[1]) content = matchs[2] + "\n" + content;
563
+ if (matchs[2]) content = matchs[3] + "\n" + content;
664
564
  return "``````" + content + "\n``````";
665
565
  }
666
566
  });
667
- const abc_Xquote = ABConvert.factory({
668
- id: "Xquote",
567
+ const abc_xQuote = ABConvert.factory({
568
+ id: "xQuote",
669
569
  name: "去除引用块",
570
+ match: "/^(xQuote|Xquote)$/",
670
571
  detail: "在文本的每行前面删除 `> `",
671
572
  process_param: ABConvert_IOEnum.text,
672
573
  process_return: ABConvert_IOEnum.text,
@@ -676,20 +577,20 @@ const abc_Xquote = ABConvert.factory({
676
577
  }).join("\n");
677
578
  }
678
579
  });
679
- const abc_Xcode = ABConvert.factory({
680
- id: "Xcode",
580
+ const abc_xCode = ABConvert.factory({
581
+ id: "xCode",
681
582
  name: "去除代码块",
682
- match: /^Xcode(\((true|false|)\))?$/,
683
- default: "Xcode(true)",
583
+ match: /^(xCode|Xcode)(\((true|false|)\))?$/,
584
+ default: "xCode(true)",
684
585
  detail: "参数为是否移除代码类型, Xcode默认为false, Xcode默认为true。记法: code|Xcode 或 code()|Xcode()内容不变",
685
586
  process_param: ABConvert_IOEnum.text,
686
587
  process_return: ABConvert_IOEnum.text,
687
588
  process: (el, header, content) => {
688
- let matchs = header.match(/^Xcode(\((true|false|)\))?$/);
589
+ let matchs = header.match(/^(xCode|Xcode)(\((true|false|)\))?$/);
689
590
  if (!matchs) return content;
690
591
  let remove_flag;
691
- if (matchs[1] == "") remove_flag = false;
692
- else remove_flag = matchs[2] != "false";
592
+ if (matchs[2] == "") remove_flag = false;
593
+ else remove_flag = matchs[3] != "false";
693
594
  let list_content = content.split("\n");
694
595
  let code_flag = "";
695
596
  let line_start = -1;
@@ -718,8 +619,9 @@ const abc_Xcode = ABConvert.factory({
718
619
  }
719
620
  });
720
621
  ABConvert.factory({
721
- id: "X",
622
+ id: "x",
722
623
  name: "去除代码或引用块",
624
+ match: /^(x|X)$/,
723
625
  process_param: ABConvert_IOEnum.text,
724
626
  process_return: ABConvert_IOEnum.text,
725
627
  process: (el, header, content) => {
@@ -733,8 +635,8 @@ ABConvert.factory({
733
635
  break;
734
636
  }
735
637
  }
736
- if (flag == "code") return abc_Xcode.process(el, header, content);
737
- else if (flag == "quote") return abc_Xquote.process(el, header, content);
638
+ if (flag == "code") return abc_xCode.process(el, header, content);
639
+ else if (flag == "quote") return abc_xQuote.process(el, header, content);
738
640
  return content;
739
641
  }
740
642
  });
@@ -2033,13 +1935,16 @@ class DirProcess {
2033
1935
  * 第一列等级为0、没有分叉
2034
1936
  */
2035
1937
  static dtdata2dt(list_tableInfo, div, modeT, is_folder = false) {
1938
+ const div2 = document.createElement("div");
1939
+ div.appendChild(div2);
1940
+ div2.classList.add("ab-list-table-parent");
1941
+ let table, thead, tbody;
2036
1942
  {
2037
- const table = document.createElement("table");
2038
- div.appendChild(table);
1943
+ table = document.createElement("table");
1944
+ div2.appendChild(table);
2039
1945
  table.classList.add("ab-table", "ab-list-table");
2040
1946
  if (is_folder) table.classList.add("ab-table-folder");
2041
1947
  if (modeT) table.setAttribute("modeT", "true");
2042
- let thead, tbody;
2043
1948
  {
2044
1949
  if (list_tableInfo[0].content.indexOf("< ") == 0) {
2045
1950
  thead = document.createElement("thead");
@@ -2095,10 +2000,12 @@ class DirProcess {
2095
2000
  td_cell.classList.add("ab-list-table-witharrow");
2096
2001
  ABConvertManager.getInstance().m_renderMarkdownFn(cell_item.content, td_cell);
2097
2002
  }
2003
+ }
2004
+ {
2098
2005
  const l_tr = tbody.querySelectorAll("tr");
2099
2006
  for (let i = 0; i < l_tr.length; i++) {
2100
- let targetEl = l_tr[i];
2101
- targetEl = targetEl.querySelector(":scope>td:first-child") ?? targetEl;
2007
+ const tr = l_tr[i];
2008
+ const targetEl = tr.querySelector(":scope>td:first-child") ?? tr;
2102
2009
  if (ABCSetting.env == "obsidian" || ABCSetting.env == "obsidian-min") {
2103
2010
  targetEl.onclick = () => {
2104
2011
  const tr_level = Number(tr.getAttribute("tr_level"));
@@ -2117,57 +2024,106 @@ class DirProcess {
2117
2024
  if (flag_do_fold) tr.setAttribute("is_fold", tr_isfold == "true" ? "false" : "true");
2118
2025
  };
2119
2026
  } else {
2120
- targetEl.setAttribute("onclick", `
2121
- const tr = (this.tagName == "TD") ? this.parentNode : this
2122
- const l_tr = tr.parentNode.querySelectorAll("tr")
2123
- const i = ${i}
2124
- const tr_level = Number(tr.getAttribute("tr_level"))
2125
- if (isNaN(tr_level)) return
2126
- const tr_isfold = tr.getAttribute("is_fold")
2127
- if (!tr_isfold) return
2128
- let flag_do_fold = false // 防止折叠最小层
2129
- for (let j=i+1; j<l_tr.length; j++){
2130
- const tr2 = l_tr[j]
2131
- const tr_level2 = Number(tr2.getAttribute("tr_level"))
2132
- if (isNaN(tr_level2)) break
2133
- if (tr_level2<=tr_level) break
2134
- (tr_isfold == "true") ? tr2.style.display = "" : tr2.style.display = "none"
2135
- flag_do_fold = true
2136
- }
2137
- if (flag_do_fold) tr.setAttribute("is_fold", tr_isfold=="true"?"false":"true")
2027
+ targetEl.setAttribute("onclick", ` const tr = (this.tagName == "TD") ? this.parentNode : this
2028
+ const l_tr = tr.parentNode.querySelectorAll("tr")
2029
+ const i = ${i}
2030
+
2031
+ const tr_level = Number(tr.getAttribute("tr_level"))
2032
+ if (isNaN(tr_level)) return
2033
+ const tr_isfold = tr.getAttribute("is_fold")
2034
+ if (!tr_isfold) return
2035
+ let flag_do_fold = false // 防止折叠最小层
2036
+ for (let j=i+1; j<l_tr.length; j++){
2037
+ const tr2 = l_tr[j]
2038
+ const tr_level2 = Number(tr2.getAttribute("tr_level"))
2039
+ if (isNaN(tr_level2)) break
2040
+ if (tr_level2<=tr_level) break
2041
+ (tr_isfold == "true") ? tr2.style.display = "" : tr2.style.display = "none"
2042
+ flag_do_fold = true
2043
+ }
2044
+ if (flag_do_fold) tr.setAttribute("is_fold", tr_isfold=="true"?"false":"true")
2138
2045
  `);
2139
2046
  }
2140
2047
  }
2048
+ }
2049
+ {
2141
2050
  const btn = document.createElement("button");
2142
- table.appendChild(btn);
2051
+ div2.appendChild(btn);
2143
2052
  btn.classList.add("ab-table-fold");
2144
- btn.textContent = "全部折叠/展开";
2053
+ const svgStr_fold = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-fold-vertical-icon lucide-fold-vertical"><path d="M12 22v-6"/><path d="M12 8V2"/><path d="M4 12H2"/><path d="M10 12H8"/><path d="M16 12h-2"/><path d="M22 12h-2"/><path d="m15 19-3-3-3 3"/><path d="m15 5-3 3-3-3"/></svg>`;
2054
+ const svgStr_unfold = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-unfold-vertical-icon lucide-unfold-vertical"><path d="M12 22v-6"/><path d="M12 8V2"/><path d="M4 12H2"/><path d="M10 12H8"/><path d="M16 12h-2"/><path d="M22 12h-2"/><path d="m15 19-3 3-3-3"/><path d="m15 5-3-3-3 3"/></svg>`;
2145
2055
  btn.setAttribute("is_fold", "false");
2146
- btn.onclick = () => {
2147
- const l_tr2 = table.querySelectorAll("tr");
2148
- for (let i = 0; i < l_tr2.length; i++) {
2149
- const tr2 = l_tr2[i];
2150
- (() => {
2151
- const tr_level = Number(tr2.getAttribute("tr_level"));
2152
- if (isNaN(tr_level)) return;
2153
- const tr_isfold = btn.getAttribute("is_fold");
2154
- if (!tr_isfold) return;
2155
- let flag_do_fold = false;
2156
- for (let j = i + 1; j < l_tr2.length; j++) {
2157
- const tr22 = l_tr2[j];
2158
- const tr_level2 = Number(tr22.getAttribute("tr_level"));
2159
- if (isNaN(tr_level2)) break;
2160
- if (tr_level2 <= tr_level) break;
2161
- tr_isfold == "true" ? tr22.style.display = "" : tr22.style.display = "none";
2162
- flag_do_fold = true;
2163
- }
2164
- if (flag_do_fold) tr2.setAttribute("is_fold", tr_isfold == "true" ? "false" : "true");
2165
- })();
2166
- }
2167
- if (btn.getAttribute("is_fold")) {
2168
- btn.setAttribute("is_fold", btn.getAttribute("is_fold") == "true" ? "false" : "true");
2169
- }
2170
- };
2056
+ btn.innerHTML = svgStr_fold;
2057
+ if (ABCSetting.env == "obsidian" || ABCSetting.env == "obsidian-min") {
2058
+ btn.onclick = () => {
2059
+ const l_tr = table.querySelectorAll("tr");
2060
+ for (let i = 0; i < l_tr.length; i++) {
2061
+ const tr = l_tr[i];
2062
+ (() => {
2063
+ const tr_level = Number(tr.getAttribute("tr_level"));
2064
+ if (isNaN(tr_level)) return;
2065
+ const tr_isfold = btn.getAttribute("is_fold");
2066
+ if (!tr_isfold) return;
2067
+ let flag_do_fold = false;
2068
+ for (let j = i + 1; j < l_tr.length; j++) {
2069
+ const tr2 = l_tr[j];
2070
+ const tr_level2 = Number(tr2.getAttribute("tr_level"));
2071
+ if (isNaN(tr_level2)) break;
2072
+ if (tr_level2 <= tr_level) break;
2073
+ tr_isfold == "true" ? tr2.style.display = "" : tr2.style.display = "none";
2074
+ flag_do_fold = true;
2075
+ }
2076
+ if (flag_do_fold) tr.setAttribute("is_fold", tr_isfold == "true" ? "false" : "true");
2077
+ })();
2078
+ }
2079
+ const is_all_fold = btn.getAttribute("is_fold");
2080
+ if (is_all_fold == "true") {
2081
+ btn.setAttribute("is_fold", "false");
2082
+ btn.innerHTML = svgStr_fold;
2083
+ } else {
2084
+ btn.setAttribute("is_fold", "true");
2085
+ btn.innerHTML = svgStr_unfold;
2086
+ }
2087
+ };
2088
+ } else {
2089
+ btn.setAttribute(
2090
+ "onclick",
2091
+ ` const btn = this;
2092
+ const svgStr_fold = \`${svgStr_fold}\`;
2093
+ const svgStr_unfold = \`${svgStr_unfold}\`;
2094
+ const table = btn.parentNode?.querySelector("table");
2095
+ if (!table) return;
2096
+
2097
+ const l_tr = table.querySelectorAll("tr");
2098
+ for (let i=0; i<l_tr.length; i++) {
2099
+ const tr = l_tr[i]
2100
+ ;(()=>{
2101
+ const tr_level = Number(tr.getAttribute("tr_level"))
2102
+ if (isNaN(tr_level)) return
2103
+ const tr_isfold = btn.getAttribute("is_fold"); // [!code] tr->btn
2104
+ if (!tr_isfold) return
2105
+ let flag_do_fold = false // 防止折叠最小层
2106
+ for (let j=i+1; j<l_tr.length; j++){
2107
+ const tr2 = l_tr[j]
2108
+ const tr_level2 = Number(tr2.getAttribute("tr_level"))
2109
+ if (isNaN(tr_level2)) break
2110
+ if (tr_level2<=tr_level) break
2111
+ (tr_isfold == "true") ? tr2.style.display = "" : tr2.style.display = "none"
2112
+ flag_do_fold = true
2113
+ }
2114
+ if (flag_do_fold) tr.setAttribute("is_fold", tr_isfold=="true"?"false":"true")
2115
+ })()
2116
+ }
2117
+ const is_all_fold = btn.getAttribute("is_fold")
2118
+ if (is_all_fold=="true") {
2119
+ btn.setAttribute("is_fold", "false"); btn.innerHTML = svgStr_fold;
2120
+ }
2121
+ else {
2122
+ btn.setAttribute("is_fold", "true"); btn.innerHTML = svgStr_unfold;
2123
+ }
2124
+ `
2125
+ );
2126
+ }
2171
2127
  }
2172
2128
  return div;
2173
2129
  }
@@ -2438,36 +2394,32 @@ ABConvert.factory({
2438
2394
  const args = matchs[1].split(",").map(
2439
2395
  (arg) => /^\d*\.?\d+$/.test(arg.trim()) ? `${arg.trim()}%` : arg.trim()
2440
2396
  );
2441
- switch (true) {
2442
- case content.children[0].classList.contains("ab-col"): {
2443
- const sub_els = content.children[0].children;
2444
- if (sub_els.length == 0) return content;
2445
- for (let i = 0; i < Math.min(sub_els.length, args.length); i++) {
2446
- const sub_el = sub_els[i];
2447
- if (args[i].endsWith("%")) sub_el.style.flex = `0 1 ${args[i]}`;
2448
- else {
2449
- sub_el.style.width = args[i];
2450
- sub_el.style.flex = `0 0 auto`;
2451
- }
2397
+ if (content.children[0].classList.contains("ab-col")) {
2398
+ const sub_els = content.children[0].children;
2399
+ if (sub_els.length == 0) return content;
2400
+ for (let i = 0; i < Math.min(sub_els.length, args.length); i++) {
2401
+ const sub_el = sub_els[i];
2402
+ if (args[i].endsWith("%")) sub_el.style.flex = `0 1 ${args[i]}`;
2403
+ else {
2404
+ sub_el.style.width = args[i];
2405
+ sub_el.style.flex = `0 0 auto`;
2452
2406
  }
2453
- return content;
2454
- }
2455
- case content.children[0].querySelector("table") !== null: {
2456
- const table = content.children[0].querySelector("table");
2457
- if (!table) return content;
2458
- table.style.tableLayout = "fixed";
2459
- table.style.width = args.some((arg) => arg.endsWith("%")) ? "100%" : "fit-content";
2460
- table.querySelectorAll("tr").forEach((row) => {
2461
- for (let i = 0; i < Math.min(row.children.length, args.length); i++) {
2462
- const cell = row.children[i];
2463
- cell.style.width = cell.style.minWidth = cell.style.maxWidth = args[i];
2464
- }
2465
- });
2466
- return content;
2467
2407
  }
2468
- default:
2469
- return content;
2408
+ return content;
2470
2409
  }
2410
+ const table = content.children[0].querySelector("table");
2411
+ if (table !== null) {
2412
+ table.style.tableLayout = "fixed";
2413
+ table.style.width = args.some((arg) => arg.endsWith("%")) ? "100%" : "fit-content";
2414
+ table.querySelectorAll("tr").forEach((row) => {
2415
+ for (let i = 0; i < Math.min(row.children.length, args.length); i++) {
2416
+ const cell = row.children[i];
2417
+ cell.style.width = cell.style.minWidth = cell.style.maxWidth = args[i];
2418
+ }
2419
+ });
2420
+ return content;
2421
+ }
2422
+ return content;
2471
2423
  }
2472
2424
  });
2473
2425
  ABConvert.factory({
@@ -2599,9 +2551,7 @@ ABConvert.factory({
2599
2551
  const origi_rowCount = origi_rows.length;
2600
2552
  const origi_colCount = origi_rows[0].cells.length;
2601
2553
  const trans_table = document.createElement("table");
2602
- content.appendChild(trans_table);
2603
- origi_table.classList.add("ab-transposition");
2604
- origi_table.classList.add("ab-table");
2554
+ origi_table.classList.add("ab-transposition", "ab-table");
2605
2555
  origi_table.classList.forEach((className) => {
2606
2556
  trans_table.classList.add(className);
2607
2557
  });
@@ -2616,7 +2566,7 @@ ABConvert.factory({
2616
2566
  newCell.innerHTML = oldCell.innerHTML;
2617
2567
  }
2618
2568
  }
2619
- origi_table.remove();
2569
+ origi_table.innerHTML = trans_table.innerHTML;
2620
2570
  return content;
2621
2571
  }
2622
2572
  });
@@ -2706,9 +2656,7 @@ ABConvert.factory({
2706
2656
  }
2707
2657
  }
2708
2658
  const trans_table = document.createElement("table");
2709
- content.appendChild(trans_table);
2710
- origi_table.classList.add("ab-transposition");
2711
- origi_table.classList.add("ab-table");
2659
+ origi_table.classList.add("ab-transposition", "ab-table");
2712
2660
  origi_table.classList.forEach((className) => {
2713
2661
  trans_table.classList.add(className);
2714
2662
  });
@@ -2728,7 +2676,7 @@ ABConvert.factory({
2728
2676
  newCell.setAttribute("colIndex", String(cell.colIndex));
2729
2677
  }
2730
2678
  }
2731
- origi_table.remove();
2679
+ origi_table.innerHTML = trans_table.innerHTML;
2732
2680
  return content;
2733
2681
  }
2734
2682
  });
@@ -2824,9 +2772,7 @@ ABConvert.factory({
2824
2772
  }
2825
2773
  const map_table2 = map_table;
2826
2774
  const trans_table = document.createElement("table");
2827
- content.appendChild(trans_table);
2828
- origi_table.classList.add("ab-transposition");
2829
- origi_table.classList.add("ab-table");
2775
+ origi_table.classList.add("ab-transposition", "ab-table");
2830
2776
  origi_table.classList.forEach((className) => {
2831
2777
  trans_table.classList.add(className);
2832
2778
  });
@@ -2846,7 +2792,7 @@ ABConvert.factory({
2846
2792
  newCell.setAttribute("colIndex", String(cell.colIndex));
2847
2793
  }
2848
2794
  }
2849
- origi_table.remove();
2795
+ origi_table.innerHTML = trans_table.innerHTML;
2850
2796
  return content;
2851
2797
  }
2852
2798
  });
@@ -42576,19 +42522,63 @@ function abSelector_squareInline(md, options) {
42576
42522
  }
42577
42523
  });
42578
42524
  }
42579
- function abSelector_container_vuepress(md, options) {
42580
- md.use(container_plugin, "AnyBlockContainer", {
42581
- validate: function(params) {
42582
- return params.trim().toLowerCase().match(/^anyblock(.*)$/);
42583
- },
42584
- render: function(tokens, idx) {
42585
- var m = tokens[idx].info.trim().toLowerCase().match(/^anyblock(.*)$/);
42586
- if (tokens[idx].nesting === 1) {
42587
- return '<details class="any-block-debug"><summary>' + md.utils.escapeHtml(m[1]).trimStart() + "</summary>\n";
42588
- } else {
42589
- return "</details>\n";
42525
+ function abSelector_container(md, options) {
42526
+ md.block.ruler.before("fence", "AnyBlockMditContainer", (state, startLine, endLine, silent) => {
42527
+ const typeNames = ["mditABDemo"];
42528
+ let start = state.bMarks[startLine];
42529
+ let max = state.eMarks[startLine];
42530
+ if (state.src[start] !== ":") return false;
42531
+ let pos = start + 1;
42532
+ while (pos <= max) {
42533
+ if (state.src[pos] !== ":") break;
42534
+ pos++;
42535
+ }
42536
+ const markerCount = pos - start;
42537
+ if (markerCount < 3) return false;
42538
+ const markup = state.src.slice(start, pos);
42539
+ const ab_mdit_header = state.src.slice(pos, max);
42540
+ if (!typeNames.includes(ab_mdit_header.split("|")[0].trim())) return false;
42541
+ if (silent) return true;
42542
+ const ab_startLine = startLine;
42543
+ let nextLine = startLine;
42544
+ let autoClosed = false;
42545
+ let ab_content = "";
42546
+ while (
42547
+ // unclosed block should be auto closed by end of document.
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
+ }
42590
42570
  }
42571
+ ab_content += "\n" + state.src.substring(start, max);
42591
42572
  }
42573
+ state.line = nextLine + (autoClosed ? 1 : 0);
42574
+ const token = state.push("fence", "code", 0);
42575
+ token.info = "AnyBlock";
42576
+ token.content = `[${ab_mdit_header}]
42577
+ ${ab_content}`;
42578
+ token.map = [ab_startLine, nextLine];
42579
+ token.markup = markup;
42580
+ token.nesting = 0;
42581
+ return true;
42592
42582
  });
42593
42583
  }
42594
42584
  function abRender_fence(md, options) {
@@ -42652,7 +42642,7 @@ function ab_mdit(md, options) {
42652
42642
  });
42653
42643
  ABCSetting.env = "vuepress";
42654
42644
  md.use(abSelector_squareInline);
42655
- md.use(abSelector_container_vuepress);
42645
+ md.use(abSelector_container);
42656
42646
  md.use(abRender_fence);
42657
42647
  }
42658
42648
  exports.abConvertEvent = abConvertEvent;