markdown-it-any-block 3.3.1-beta1 → 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 +37 -46
- package/dist/mdit-any-block.cjs.map +1 -1
- package/dist/mdit-any-block.js +37 -46
- package/dist/mdit-any-block.js.map +1 -1
- package/index_mdit.ts +1 -1
- package/package.json +1 -1
- package/styles.css +1 -0
package/dist/mdit-any-block.js
CHANGED
|
@@ -180,7 +180,10 @@ const ABReg = {
|
|
|
180
180
|
// 内联切分。`|`或全角符号+一空格,半角符号+两空格 (后者由于空格压缩,若经历了重渲染可能有问题)
|
|
181
181
|
};
|
|
182
182
|
const ABCSetting = {
|
|
183
|
-
env: "obsidian"
|
|
183
|
+
env: "obsidian",
|
|
184
|
+
// MarkdownPostProcessorContext类型, obsidian专用
|
|
185
|
+
mermaid: void 0
|
|
186
|
+
// obsidian专用,表示使用哪种方式渲染mermaid
|
|
184
187
|
};
|
|
185
188
|
function autoABAlias(header, selectorName, content) {
|
|
186
189
|
if (!header.trimEnd().endsWith("|")) header = header + "|";
|
|
@@ -231,7 +234,7 @@ const ABAlias_json_withSub = [
|
|
|
231
234
|
// quote, cite
|
|
232
235
|
// `其他` 避免错字, 我之前加过 warn, tips。后面又删了
|
|
233
236
|
{ 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 (
|
|
237
|
+
{ regex: /\|(callout|alert) ([^+-\s]+)([+-]?)\s?(.*)\|/, replacement: "|add([!$2]$3 $4)|addQuote|" }
|
|
235
238
|
// 注意避免和原上/上面的callout语法冲突,以及自身递归
|
|
236
239
|
];
|
|
237
240
|
const ABAlias_json_mdit = [
|
|
@@ -2308,23 +2311,22 @@ ABConvert.factory({
|
|
|
2308
2311
|
sub_button.onclick = fn_fold;
|
|
2309
2312
|
mid_el.appendChild(sub_button);
|
|
2310
2313
|
mid_el.appendChild(sub_el);
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
}
|
|
2314
|
+
const isListTable = sub_el.classList.contains("ab-list-table-parent");
|
|
2315
|
+
const listTable_btn = sub_el.querySelector(".ab-table-fold");
|
|
2316
|
+
if (isListTable && listTable_btn) {
|
|
2317
|
+
if (ABCSetting.env == "obsidian" || ABCSetting.env == "obsidian-min") {
|
|
2318
|
+
fn_fold();
|
|
2319
|
+
sub_button.textContent = "折叠/展开";
|
|
2320
|
+
const fn_fold2 = () => {
|
|
2321
|
+
const clickEvent = new MouseEvent("click", {
|
|
2322
|
+
view: window,
|
|
2323
|
+
bubbles: true,
|
|
2324
|
+
cancelable: true
|
|
2325
|
+
});
|
|
2326
|
+
listTable_btn.dispatchEvent(clickEvent);
|
|
2327
|
+
};
|
|
2328
|
+
fn_fold2();
|
|
2329
|
+
sub_button.onclick = fn_fold2;
|
|
2328
2330
|
}
|
|
2329
2331
|
}
|
|
2330
2332
|
return content;
|
|
@@ -2333,18 +2335,17 @@ ABConvert.factory({
|
|
|
2333
2335
|
ABConvert.factory({
|
|
2334
2336
|
id: "scroll",
|
|
2335
2337
|
name: "滚动",
|
|
2336
|
-
match: /^scroll(\((\d+)\))
|
|
2338
|
+
match: /^scroll(X)?(\((\d+)\))?$/,
|
|
2337
2339
|
default: "scroll(460)",
|
|
2340
|
+
detail: "默认是纵向滚动。可以指定溢出滚动的范围,可以使用scrollX进行横向滚动",
|
|
2338
2341
|
process_param: ABConvert_IOEnum.el,
|
|
2339
2342
|
process_return: ABConvert_IOEnum.el,
|
|
2340
2343
|
process: (el, header, content) => {
|
|
2341
|
-
const matchs = header.match(/^scroll(\((\d+)\))
|
|
2344
|
+
const matchs = header.match(/^scroll(X)?(\((\d+)\))?$/);
|
|
2342
2345
|
if (!matchs) return content;
|
|
2343
|
-
let arg1;
|
|
2344
|
-
if (
|
|
2345
|
-
|
|
2346
|
-
if (!matchs[2]) return content;
|
|
2347
|
-
arg1 = Number(matchs[2]);
|
|
2346
|
+
let arg1 = 0;
|
|
2347
|
+
if (matchs[2] && matchs[3]) {
|
|
2348
|
+
arg1 = Number(matchs[3]);
|
|
2348
2349
|
if (isNaN(arg1)) return content;
|
|
2349
2350
|
}
|
|
2350
2351
|
if (content.children.length != 1) return content;
|
|
@@ -2353,13 +2354,14 @@ ABConvert.factory({
|
|
|
2353
2354
|
const mid_el = document.createElement("div");
|
|
2354
2355
|
content.appendChild(mid_el);
|
|
2355
2356
|
mid_el.classList.add("ab-deco-scroll");
|
|
2356
|
-
|
|
2357
|
+
mid_el.appendChild(sub_el);
|
|
2358
|
+
if (!matchs[1]) {
|
|
2357
2359
|
mid_el.classList.add("ab-deco-scroll-y");
|
|
2358
|
-
mid_el.setAttribute("style", `max-height: ${arg1}
|
|
2360
|
+
mid_el.setAttribute("style", `max-height: ${arg1 !== 0 ? arg1 + "px" : "460px"}`);
|
|
2359
2361
|
} else {
|
|
2360
2362
|
mid_el.classList.add("ab-deco-scroll-x");
|
|
2363
|
+
mid_el.setAttribute("style", `max-height: ${arg1 !== 0 ? arg1 + "px" : "100%"}`);
|
|
2361
2364
|
}
|
|
2362
|
-
mid_el.appendChild(sub_el);
|
|
2363
2365
|
return content;
|
|
2364
2366
|
}
|
|
2365
2367
|
});
|
|
@@ -2880,9 +2882,8 @@ ABConvert.factory({
|
|
|
2880
2882
|
}
|
|
2881
2883
|
});
|
|
2882
2884
|
ABConvert.factory({
|
|
2883
|
-
id: "
|
|
2885
|
+
id: "info_converter",
|
|
2884
2886
|
name: "INFO",
|
|
2885
|
-
match: "info",
|
|
2886
2887
|
detail: "查看当前软件版本下的注册处理器表",
|
|
2887
2888
|
process_param: ABConvert_IOEnum.text,
|
|
2888
2889
|
process_return: ABConvert_IOEnum.el,
|
|
@@ -7879,11 +7880,6 @@ function list2ActivityDiagramText(listdata) {
|
|
|
7879
7880
|
let result = "@startuml\n";
|
|
7880
7881
|
const stats = listdata.map((item) => new Stat(item.content.trim(), item.level));
|
|
7881
7882
|
const { result: bodyResult } = processBlock(stats, 0, -1);
|
|
7882
|
-
const swimLanes = bodyResult.split("\n").filter((line) => line.startsWith("|") && line.endsWith("|"));
|
|
7883
|
-
if (swimLanes.length > 0) {
|
|
7884
|
-
result += swimLanes.join("\n");
|
|
7885
|
-
result += "\n";
|
|
7886
|
-
}
|
|
7887
7883
|
result += bodyResult;
|
|
7888
7884
|
result += "@enduml";
|
|
7889
7885
|
return result;
|
|
@@ -7962,7 +7958,6 @@ async function render_pumlText(text2, div) {
|
|
|
7962
7958
|
div.innerHTML = `<img src="${url}">`;
|
|
7963
7959
|
return div;
|
|
7964
7960
|
}
|
|
7965
|
-
let mermaid = null;
|
|
7966
7961
|
function getID(length = 16) {
|
|
7967
7962
|
return Number(Math.random().toString().substr(3, length) + Date.now()).toString(36);
|
|
7968
7963
|
}
|
|
@@ -8135,21 +8130,17 @@ async function data2mindmap(list_itemInfo, div) {
|
|
|
8135
8130
|
return render_mermaidText(mermaidText, div);
|
|
8136
8131
|
}
|
|
8137
8132
|
async function render_mermaidText(mermaidText, div) {
|
|
8138
|
-
if (ABCSetting.env == "obsidian") {
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
ABConvertManager.getInstance().m_renderMarkdownFn("```mermaid\n" + mermaidText + "\n```", div);
|
|
8133
|
+
if ((ABCSetting.env == "obsidian" || ABCSetting.env == "obsidian-min") && ABCSetting.mermaid) {
|
|
8134
|
+
ABCSetting.mermaid.then(async (mermaid) => {
|
|
8135
|
+
const { svg } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
|
|
8136
|
+
div.innerHTML = svg;
|
|
8137
|
+
});
|
|
8144
8138
|
} else {
|
|
8145
8139
|
div.classList.add("ab-raw");
|
|
8146
8140
|
div.innerHTML = `<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`;
|
|
8147
8141
|
}
|
|
8148
8142
|
return div;
|
|
8149
8143
|
}
|
|
8150
|
-
async function init_mermaid() {
|
|
8151
|
-
if (ABCSetting.env !== "obsidian" || true) return;
|
|
8152
|
-
}
|
|
8153
8144
|
function abConvertEvent(d, isCycle = false) {
|
|
8154
8145
|
if (d.querySelector(".ab-super-width")) {
|
|
8155
8146
|
const els_note = d.querySelectorAll(".ab-note");
|