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.cjs
CHANGED
|
@@ -204,7 +204,10 @@ const ABReg = {
|
|
|
204
204
|
// 内联切分。`|`或全角符号+一空格,半角符号+两空格 (后者由于空格压缩,若经历了重渲染可能有问题)
|
|
205
205
|
};
|
|
206
206
|
const ABCSetting = {
|
|
207
|
-
env: "obsidian"
|
|
207
|
+
env: "obsidian",
|
|
208
|
+
// MarkdownPostProcessorContext类型, obsidian专用
|
|
209
|
+
mermaid: void 0
|
|
210
|
+
// obsidian专用,表示使用哪种方式渲染mermaid
|
|
208
211
|
};
|
|
209
212
|
function autoABAlias(header, selectorName, content) {
|
|
210
213
|
if (!header.trimEnd().endsWith("|")) header = header + "|";
|
|
@@ -255,7 +258,7 @@ const ABAlias_json_withSub = [
|
|
|
255
258
|
// quote, cite
|
|
256
259
|
// `其他` 避免错字, 我之前加过 warn, tips。后面又删了
|
|
257
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|" },
|
|
258
|
-
{ regex: /\|callout (
|
|
261
|
+
{ regex: /\|(callout|alert) ([^+-\s]+)([+-]?)\s?(.*)\|/, replacement: "|add([!$2]$3 $4)|addQuote|" }
|
|
259
262
|
// 注意避免和原上/上面的callout语法冲突,以及自身递归
|
|
260
263
|
];
|
|
261
264
|
const ABAlias_json_mdit = [
|
|
@@ -2332,23 +2335,22 @@ ABConvert.factory({
|
|
|
2332
2335
|
sub_button.onclick = fn_fold;
|
|
2333
2336
|
mid_el.appendChild(sub_button);
|
|
2334
2337
|
mid_el.appendChild(sub_el);
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
}
|
|
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;
|
|
2352
2354
|
}
|
|
2353
2355
|
}
|
|
2354
2356
|
return content;
|
|
@@ -2357,18 +2359,17 @@ ABConvert.factory({
|
|
|
2357
2359
|
ABConvert.factory({
|
|
2358
2360
|
id: "scroll",
|
|
2359
2361
|
name: "滚动",
|
|
2360
|
-
match: /^scroll(\((\d+)\))
|
|
2362
|
+
match: /^scroll(X)?(\((\d+)\))?$/,
|
|
2361
2363
|
default: "scroll(460)",
|
|
2364
|
+
detail: "默认是纵向滚动。可以指定溢出滚动的范围,可以使用scrollX进行横向滚动",
|
|
2362
2365
|
process_param: ABConvert_IOEnum.el,
|
|
2363
2366
|
process_return: ABConvert_IOEnum.el,
|
|
2364
2367
|
process: (el, header, content) => {
|
|
2365
|
-
const matchs = header.match(/^scroll(\((\d+)\))
|
|
2368
|
+
const matchs = header.match(/^scroll(X)?(\((\d+)\))?$/);
|
|
2366
2369
|
if (!matchs) return content;
|
|
2367
|
-
let arg1;
|
|
2368
|
-
if (
|
|
2369
|
-
|
|
2370
|
-
if (!matchs[2]) return content;
|
|
2371
|
-
arg1 = Number(matchs[2]);
|
|
2370
|
+
let arg1 = 0;
|
|
2371
|
+
if (matchs[2] && matchs[3]) {
|
|
2372
|
+
arg1 = Number(matchs[3]);
|
|
2372
2373
|
if (isNaN(arg1)) return content;
|
|
2373
2374
|
}
|
|
2374
2375
|
if (content.children.length != 1) return content;
|
|
@@ -2377,13 +2378,14 @@ ABConvert.factory({
|
|
|
2377
2378
|
const mid_el = document.createElement("div");
|
|
2378
2379
|
content.appendChild(mid_el);
|
|
2379
2380
|
mid_el.classList.add("ab-deco-scroll");
|
|
2380
|
-
|
|
2381
|
+
mid_el.appendChild(sub_el);
|
|
2382
|
+
if (!matchs[1]) {
|
|
2381
2383
|
mid_el.classList.add("ab-deco-scroll-y");
|
|
2382
|
-
mid_el.setAttribute("style", `max-height: ${arg1}
|
|
2384
|
+
mid_el.setAttribute("style", `max-height: ${arg1 !== 0 ? arg1 + "px" : "460px"}`);
|
|
2383
2385
|
} else {
|
|
2384
2386
|
mid_el.classList.add("ab-deco-scroll-x");
|
|
2387
|
+
mid_el.setAttribute("style", `max-height: ${arg1 !== 0 ? arg1 + "px" : "100%"}`);
|
|
2385
2388
|
}
|
|
2386
|
-
mid_el.appendChild(sub_el);
|
|
2387
2389
|
return content;
|
|
2388
2390
|
}
|
|
2389
2391
|
});
|
|
@@ -2904,9 +2906,8 @@ ABConvert.factory({
|
|
|
2904
2906
|
}
|
|
2905
2907
|
});
|
|
2906
2908
|
ABConvert.factory({
|
|
2907
|
-
id: "
|
|
2909
|
+
id: "info_converter",
|
|
2908
2910
|
name: "INFO",
|
|
2909
|
-
match: "info",
|
|
2910
2911
|
detail: "查看当前软件版本下的注册处理器表",
|
|
2911
2912
|
process_param: ABConvert_IOEnum.text,
|
|
2912
2913
|
process_return: ABConvert_IOEnum.el,
|
|
@@ -7903,11 +7904,6 @@ function list2ActivityDiagramText(listdata) {
|
|
|
7903
7904
|
let result = "@startuml\n";
|
|
7904
7905
|
const stats = listdata.map((item) => new Stat(item.content.trim(), item.level));
|
|
7905
7906
|
const { result: bodyResult } = processBlock(stats, 0, -1);
|
|
7906
|
-
const swimLanes = bodyResult.split("\n").filter((line) => line.startsWith("|") && line.endsWith("|"));
|
|
7907
|
-
if (swimLanes.length > 0) {
|
|
7908
|
-
result += swimLanes.join("\n");
|
|
7909
|
-
result += "\n";
|
|
7910
|
-
}
|
|
7911
7907
|
result += bodyResult;
|
|
7912
7908
|
result += "@enduml";
|
|
7913
7909
|
return result;
|
|
@@ -7986,7 +7982,6 @@ async function render_pumlText(text2, div) {
|
|
|
7986
7982
|
div.innerHTML = `<img src="${url}">`;
|
|
7987
7983
|
return div;
|
|
7988
7984
|
}
|
|
7989
|
-
let mermaid = null;
|
|
7990
7985
|
function getID(length = 16) {
|
|
7991
7986
|
return Number(Math.random().toString().substr(3, length) + Date.now()).toString(36);
|
|
7992
7987
|
}
|
|
@@ -8159,21 +8154,17 @@ async function data2mindmap(list_itemInfo, div) {
|
|
|
8159
8154
|
return render_mermaidText(mermaidText, div);
|
|
8160
8155
|
}
|
|
8161
8156
|
async function render_mermaidText(mermaidText, div) {
|
|
8162
|
-
if (ABCSetting.env == "obsidian") {
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
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
|
+
});
|
|
8168
8162
|
} else {
|
|
8169
8163
|
div.classList.add("ab-raw");
|
|
8170
8164
|
div.innerHTML = `<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`;
|
|
8171
8165
|
}
|
|
8172
8166
|
return div;
|
|
8173
8167
|
}
|
|
8174
|
-
async function init_mermaid() {
|
|
8175
|
-
if (ABCSetting.env !== "obsidian" || true) return;
|
|
8176
|
-
}
|
|
8177
8168
|
function abConvertEvent(d, isCycle = false) {
|
|
8178
8169
|
if (d.querySelector(".ab-super-width")) {
|
|
8179
8170
|
const els_note = d.querySelectorAll(".ab-note");
|