markdown-it-any-block 3.3.1-beta1 → 3.3.2-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/README.md +6 -1
- package/dist/mdit-any-block.cjs +37 -46
- package/dist/mdit-any-block.js +37 -46
- package/index_mdit.ts +1 -1
- package/package.json +6 -2
- package/styles.css +1 -0
- package/dist/mdit-any-block.cjs.map +0 -1
- package/dist/mdit-any-block.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# AnyBlock MarkdownIt
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
- en
|
|
4
|
+
- Welcome to learn more about it in [the GitHub project](https://github.com/any-block/any-block)
|
|
5
|
+
- Here you will find more detailed function descriptions and multilingual documents.
|
|
6
|
+
- zh
|
|
7
|
+
- 欢迎到此 [github项目](https://github.com/any-block/any-block) 中了解更多
|
|
8
|
+
- 这里有更详细的功能介绍和多语言文档
|
|
4
9
|
|
|
5
10
|
## markdown-it-any-block 使用
|
|
6
11
|
|
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");
|
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");
|
package/index_mdit.ts
CHANGED
|
@@ -62,7 +62,7 @@ import "../ABConverter/converter/abc_deco"
|
|
|
62
62
|
import "../ABConverter/converter/abc_ex"
|
|
63
63
|
import "../ABConverter/converter/abc_mdit_container"
|
|
64
64
|
import "../ABConverter/converter/abc_plantuml" // 可选建议:
|
|
65
|
-
import "../ABConverter/converter/abc_mermaid
|
|
65
|
+
import "../ABConverter/converter/abc_mermaid" // 可选建议:新版无额外依赖,旧版非 min 环境下 7.1MB
|
|
66
66
|
import "../ABConverter/converter/abc_markmap" // 可选建议:1.3MB
|
|
67
67
|
|
|
68
68
|
interface Options {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdown-it-any-block",
|
|
3
|
-
"version": "3.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.3.2-beta1",
|
|
4
|
+
"description": "You can flexibility to create a 'Block' by many means. It also provides many useful features, like `list to table`. (obsidian/markdown-it/vuepress plugin/app)",
|
|
5
5
|
"types": "@types/index_mdit.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/mdit-any-block.cjs",
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"prepublishOnly": "pnpm build",
|
|
23
23
|
"copy_abc_style": "copyfiles --flat ../../src/ABConverter/style/styles.css ./"
|
|
24
24
|
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"anyblock", "any-block",
|
|
27
|
+
"markdown", "markdown-it"
|
|
28
|
+
],
|
|
25
29
|
"author": "LincZero",
|
|
26
30
|
"license": "GNU Affero General Public License v3.0",
|
|
27
31
|
"peerDependencies": {
|
package/styles.css
CHANGED