@anyblock/remark-any-block 1.0.1-beta2 → 1.0.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/README.md +2 -14
- package/anyblock.ts +3 -6
- package/dist/remark-any-block.cjs +33 -37
- package/dist/remark-any-block.js +33 -37
- package/index.ts +1 -1
- package/jsdom_init.ts +2 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,21 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## remark-any-block 使用
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
详见 github *any-block* 组织下的 *Remark Demo* 仓库
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Quartz4: 包含 OFM (Obsidian风格Markdown) 相关的插件
|
|
9
|
-
- Docusaurus: 包含 MDX 相关插件
|
|
10
|
-
|
|
11
|
-
> [!WARNING]
|
|
12
|
-
> 暂时不属于完全通用的 Remark 插件 (doing, 或者你自己改改), 当前该插件测试于 Quartz V4 版本
|
|
13
|
-
> 详见 [any-block/QuartzDemo](https://github.com/any-block/QuartzDemo)
|
|
14
|
-
>
|
|
15
|
-
> Quartz V4 在 remark 的基础上又封装了一层
|
|
16
|
-
|
|
17
|
-
## 使用案例/示例
|
|
18
|
-
|
|
19
|
-
见 [any-block/QuartzDemo](https://github.com/any-block/QuartzDemo)
|
|
7
|
+
暂时不属于完全通用的 Remark 插件 (doing, 或者你自己改改), 当前该插件测试于 Quartz V4 版本
|
|
20
8
|
|
|
21
9
|
## 构建
|
|
22
10
|
|
package/anyblock.ts
CHANGED
|
@@ -179,7 +179,7 @@ export const remark_anyblock_render_codeblock = () => {
|
|
|
179
179
|
if (typeof document == "undefined") return
|
|
180
180
|
return (tree: Root, _file: VFile) => {
|
|
181
181
|
visit(tree, "code", (node: Code, index: number|undefined, parent: any|undefined) => { // 遍历所有的 code 类型节点
|
|
182
|
-
if (
|
|
182
|
+
if (node.lang.toLowerCase() != "anyblock") return
|
|
183
183
|
if (!parent || !index) return
|
|
184
184
|
|
|
185
185
|
const lines = node.value.split("\n")
|
|
@@ -230,11 +230,8 @@ export const remark_anyblock_render_codeblock = () => {
|
|
|
230
230
|
})
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
* 仅 Quartz 项目可用,其他 Remark 项目 (如 Astro、Docusaurus) 不需要用到这个
|
|
236
|
-
*/
|
|
237
|
-
export const quartz_transformer_anyblock: QuartzTransformerPlugin = (/*options: any*/) => {
|
|
233
|
+
// 这是 Quartz 的 Transformer 插件定义
|
|
234
|
+
export const transformer_anyblock: QuartzTransformerPlugin = (/*options: any*/) => {
|
|
238
235
|
return {
|
|
239
236
|
name: "AnyBlock",
|
|
240
237
|
markdownPlugins(_ctx: BuildCtx) {
|
|
@@ -23,17 +23,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
25
|
const MarkdownIt = require("markdown-it");
|
|
26
|
-
let dom = null;
|
|
27
26
|
async function jsdom_init() {
|
|
28
27
|
const { default: jsdom } = await import("jsdom");
|
|
29
28
|
const { JSDOM } = jsdom;
|
|
30
|
-
dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
|
|
29
|
+
const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
|
|
31
30
|
url: "http://localhost/"
|
|
32
31
|
// @warn 若缺少该行,则在mdit+build环境下,编译报错
|
|
33
32
|
});
|
|
34
|
-
jsdom_able();
|
|
35
|
-
}
|
|
36
|
-
async function jsdom_able() {
|
|
37
33
|
global.Storage = dom.window.Storage;
|
|
38
34
|
global.window = dom.window;
|
|
39
35
|
global.history = dom.window.history;
|
|
@@ -17507,16 +17503,16 @@ const DomUtils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
|
|
|
17507
17503
|
textContent,
|
|
17508
17504
|
uniqueSort
|
|
17509
17505
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
17510
|
-
function render(that,
|
|
17506
|
+
function render(that, dom, options) {
|
|
17511
17507
|
if (!that)
|
|
17512
17508
|
return "";
|
|
17513
|
-
return that(
|
|
17509
|
+
return that(dom !== null && dom !== void 0 ? dom : that._root.children, null, void 0, options).toString();
|
|
17514
17510
|
}
|
|
17515
|
-
function isOptions(
|
|
17516
|
-
return typeof
|
|
17511
|
+
function isOptions(dom, options) {
|
|
17512
|
+
return typeof dom === "object" && dom != null && !("length" in dom) && !("type" in dom);
|
|
17517
17513
|
}
|
|
17518
|
-
function html$1(
|
|
17519
|
-
const toRender = isOptions(
|
|
17514
|
+
function html$1(dom, options) {
|
|
17515
|
+
const toRender = isOptions(dom) ? (options = dom, void 0) : dom;
|
|
17520
17516
|
const opts = {
|
|
17521
17517
|
...defaultOpts$2,
|
|
17522
17518
|
...this === null || this === void 0 ? void 0 : this._options,
|
|
@@ -17524,9 +17520,9 @@ function html$1(dom2, options) {
|
|
|
17524
17520
|
};
|
|
17525
17521
|
return render(this, toRender, opts);
|
|
17526
17522
|
}
|
|
17527
|
-
function xml(
|
|
17523
|
+
function xml(dom) {
|
|
17528
17524
|
const options = { ...this._options, xmlMode: true };
|
|
17529
|
-
return render(this,
|
|
17525
|
+
return render(this, dom, options);
|
|
17530
17526
|
}
|
|
17531
17527
|
function text$1(elements) {
|
|
17532
17528
|
const elems = elements ? elements : this ? this.root() : [];
|
|
@@ -17616,8 +17612,8 @@ function domEach(array, fn) {
|
|
|
17616
17612
|
fn(array[i], i);
|
|
17617
17613
|
return array;
|
|
17618
17614
|
}
|
|
17619
|
-
function cloneDom(
|
|
17620
|
-
const clone2 = "length" in
|
|
17615
|
+
function cloneDom(dom) {
|
|
17616
|
+
const clone2 = "length" in dom ? Array.prototype.map.call(dom, (el) => cloneNode(el, true)) : [cloneNode(dom, true)];
|
|
17621
17617
|
const root2 = new Document$1(clone2);
|
|
17622
17618
|
clone2.forEach((node) => {
|
|
17623
17619
|
node.parent = root2;
|
|
@@ -19848,8 +19844,8 @@ function _insert(concatenator) {
|
|
|
19848
19844
|
if (!hasChildren(el))
|
|
19849
19845
|
return;
|
|
19850
19846
|
const domSrc = typeof elems[0] === "function" ? elems[0].call(el, i, this._render(el.children)) : elems;
|
|
19851
|
-
const
|
|
19852
|
-
concatenator(
|
|
19847
|
+
const dom = this._makeDomArray(domSrc, i < lastIdx);
|
|
19848
|
+
concatenator(dom, el.children, el);
|
|
19853
19849
|
});
|
|
19854
19850
|
};
|
|
19855
19851
|
}
|
|
@@ -19903,11 +19899,11 @@ function prependTo(target) {
|
|
|
19903
19899
|
prependTarget.prepend(this);
|
|
19904
19900
|
return this;
|
|
19905
19901
|
}
|
|
19906
|
-
const append = _insert((
|
|
19907
|
-
uniqueSplice(children2, children2.length, 0,
|
|
19902
|
+
const append = _insert((dom, children2, parent2) => {
|
|
19903
|
+
uniqueSplice(children2, children2.length, 0, dom, parent2);
|
|
19908
19904
|
});
|
|
19909
|
-
const prepend = _insert((
|
|
19910
|
-
uniqueSplice(children2, 0, 0,
|
|
19905
|
+
const prepend = _insert((dom, children2, parent2) => {
|
|
19906
|
+
uniqueSplice(children2, 0, 0, dom, parent2);
|
|
19911
19907
|
});
|
|
19912
19908
|
function _wrap(insert) {
|
|
19913
19909
|
return function(wrapper) {
|
|
@@ -19992,8 +19988,8 @@ function after(...elems) {
|
|
|
19992
19988
|
if (index2 < 0)
|
|
19993
19989
|
return;
|
|
19994
19990
|
const domSrc = typeof elems[0] === "function" ? elems[0].call(el, i, this._render(el.children)) : elems;
|
|
19995
|
-
const
|
|
19996
|
-
uniqueSplice(siblings2, index2 + 1, 0,
|
|
19991
|
+
const dom = this._makeDomArray(domSrc, i < lastIdx);
|
|
19992
|
+
uniqueSplice(siblings2, index2 + 1, 0, dom, parent2);
|
|
19997
19993
|
});
|
|
19998
19994
|
}
|
|
19999
19995
|
function insertAfter(target) {
|
|
@@ -20029,8 +20025,8 @@ function before(...elems) {
|
|
|
20029
20025
|
if (index2 < 0)
|
|
20030
20026
|
return;
|
|
20031
20027
|
const domSrc = typeof elems[0] === "function" ? elems[0].call(el, i, this._render(el.children)) : elems;
|
|
20032
|
-
const
|
|
20033
|
-
uniqueSplice(siblings2, index2, 0,
|
|
20028
|
+
const dom = this._makeDomArray(domSrc, i < lastIdx);
|
|
20029
|
+
uniqueSplice(siblings2, index2, 0, dom, parent2);
|
|
20034
20030
|
});
|
|
20035
20031
|
}
|
|
20036
20032
|
function insertBefore(target) {
|
|
@@ -20068,11 +20064,11 @@ function replaceWith(content) {
|
|
|
20068
20064
|
}
|
|
20069
20065
|
const siblings2 = parent2.children;
|
|
20070
20066
|
const cont = typeof content === "function" ? content.call(el, i, el) : content;
|
|
20071
|
-
const
|
|
20072
|
-
update(
|
|
20067
|
+
const dom = this._makeDomArray(cont);
|
|
20068
|
+
update(dom, null);
|
|
20073
20069
|
const index2 = siblings2.indexOf(el);
|
|
20074
|
-
uniqueSplice(siblings2, index2, 1,
|
|
20075
|
-
if (!
|
|
20070
|
+
uniqueSplice(siblings2, index2, 1, dom, parent2);
|
|
20071
|
+
if (!dom.includes(el)) {
|
|
20076
20072
|
el.parent = el.prev = el.next = null;
|
|
20077
20073
|
}
|
|
20078
20074
|
});
|
|
@@ -20308,8 +20304,8 @@ function getLoad(parse2, render2) {
|
|
|
20308
20304
|
_parse(content2, options2, isDocument3, context) {
|
|
20309
20305
|
return parse2(content2, options2, isDocument3, context);
|
|
20310
20306
|
}
|
|
20311
|
-
_render(
|
|
20312
|
-
return render2(
|
|
20307
|
+
_render(dom) {
|
|
20308
|
+
return render2(dom, this.options);
|
|
20313
20309
|
}
|
|
20314
20310
|
}
|
|
20315
20311
|
function initialize(selector, context, root2 = initialRoot, opts) {
|
|
@@ -28496,8 +28492,8 @@ function parseWithParse5(content, options, isDocument2, context) {
|
|
|
28496
28492
|
return isDocument2 ? parse$2(content, opts) : parseFragment(context, content, opts);
|
|
28497
28493
|
}
|
|
28498
28494
|
const renderOpts = { treeAdapter: adapter };
|
|
28499
|
-
function renderWithParse5(
|
|
28500
|
-
const nodes = "length" in
|
|
28495
|
+
function renderWithParse5(dom) {
|
|
28496
|
+
const nodes = "length" in dom ? dom : [dom];
|
|
28501
28497
|
for (let index2 = 0; index2 < nodes.length; index2 += 1) {
|
|
28502
28498
|
const node = nodes[index2];
|
|
28503
28499
|
if (isDocument$1(node)) {
|
|
@@ -29749,7 +29745,7 @@ function parseDocument$1(data2, options) {
|
|
|
29749
29745
|
return handler.root;
|
|
29750
29746
|
}
|
|
29751
29747
|
const parse$1 = getParse((content, options, isDocument2, context) => options.xmlMode || options._useHtmlParser2 ? parseDocument$1(content, options) : parseWithParse5(content, options, isDocument2, context));
|
|
29752
|
-
const load = getLoad(parse$1, (
|
|
29748
|
+
const load = getLoad(parse$1, (dom, options) => options.xmlMode || options._useHtmlParser2 ? render$1(dom, options) : renderWithParse5(dom));
|
|
29753
29749
|
load([]);
|
|
29754
29750
|
const defaultSelectorRules = {
|
|
29755
29751
|
"div,p": ({ $node }) => ({
|
|
@@ -49625,7 +49621,7 @@ const remark_anyblock_render_codeblock = () => {
|
|
|
49625
49621
|
if (typeof document == "undefined") return;
|
|
49626
49622
|
return (tree, _file) => {
|
|
49627
49623
|
visit$1(tree, "code", (node, index2, parent2) => {
|
|
49628
|
-
if (
|
|
49624
|
+
if (node.lang.toLowerCase() != "anyblock") return;
|
|
49629
49625
|
if (!parent2 || !index2) return;
|
|
49630
49626
|
const lines = node.value.split("\n");
|
|
49631
49627
|
const head = lines.shift();
|
|
@@ -49655,7 +49651,7 @@ const remark_anyblock_render_codeblock = () => {
|
|
|
49655
49651
|
el_child.innerHTML = result;
|
|
49656
49652
|
});
|
|
49657
49653
|
}
|
|
49658
|
-
const
|
|
49654
|
+
const transformer_anyblock = () => {
|
|
49659
49655
|
return {
|
|
49660
49656
|
name: "AnyBlock",
|
|
49661
49657
|
markdownPlugins(_ctx) {
|
|
@@ -49674,5 +49670,5 @@ exports.ABConvertManager = ABConvertManager;
|
|
|
49674
49670
|
exports.abConvertEvent = abConvertEvent;
|
|
49675
49671
|
exports.jsdom_init = jsdom_init;
|
|
49676
49672
|
exports.remark_anyblock_render_codeblock = remark_anyblock_render_codeblock;
|
|
49677
|
-
exports.transformer_anyblock =
|
|
49673
|
+
exports.transformer_anyblock = transformer_anyblock;
|
|
49678
49674
|
//# sourceMappingURL=remark-any-block.cjs.map
|
package/dist/remark-any-block.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import MarkdownIt from "markdown-it";
|
|
2
|
-
let dom = null;
|
|
3
2
|
async function jsdom_init() {
|
|
4
3
|
const { default: jsdom } = await import("jsdom");
|
|
5
4
|
const { JSDOM } = jsdom;
|
|
6
|
-
dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
|
|
5
|
+
const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
|
|
7
6
|
url: "http://localhost/"
|
|
8
7
|
// @warn 若缺少该行,则在mdit+build环境下,编译报错
|
|
9
8
|
});
|
|
10
|
-
jsdom_able();
|
|
11
|
-
}
|
|
12
|
-
async function jsdom_able() {
|
|
13
9
|
global.Storage = dom.window.Storage;
|
|
14
10
|
global.window = dom.window;
|
|
15
11
|
global.history = dom.window.history;
|
|
@@ -17483,16 +17479,16 @@ const DomUtils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
|
|
|
17483
17479
|
textContent,
|
|
17484
17480
|
uniqueSort
|
|
17485
17481
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
17486
|
-
function render(that,
|
|
17482
|
+
function render(that, dom, options) {
|
|
17487
17483
|
if (!that)
|
|
17488
17484
|
return "";
|
|
17489
|
-
return that(
|
|
17485
|
+
return that(dom !== null && dom !== void 0 ? dom : that._root.children, null, void 0, options).toString();
|
|
17490
17486
|
}
|
|
17491
|
-
function isOptions(
|
|
17492
|
-
return typeof
|
|
17487
|
+
function isOptions(dom, options) {
|
|
17488
|
+
return typeof dom === "object" && dom != null && !("length" in dom) && !("type" in dom);
|
|
17493
17489
|
}
|
|
17494
|
-
function html$1(
|
|
17495
|
-
const toRender = isOptions(
|
|
17490
|
+
function html$1(dom, options) {
|
|
17491
|
+
const toRender = isOptions(dom) ? (options = dom, void 0) : dom;
|
|
17496
17492
|
const opts = {
|
|
17497
17493
|
...defaultOpts$2,
|
|
17498
17494
|
...this === null || this === void 0 ? void 0 : this._options,
|
|
@@ -17500,9 +17496,9 @@ function html$1(dom2, options) {
|
|
|
17500
17496
|
};
|
|
17501
17497
|
return render(this, toRender, opts);
|
|
17502
17498
|
}
|
|
17503
|
-
function xml(
|
|
17499
|
+
function xml(dom) {
|
|
17504
17500
|
const options = { ...this._options, xmlMode: true };
|
|
17505
|
-
return render(this,
|
|
17501
|
+
return render(this, dom, options);
|
|
17506
17502
|
}
|
|
17507
17503
|
function text$1(elements) {
|
|
17508
17504
|
const elems = elements ? elements : this ? this.root() : [];
|
|
@@ -17592,8 +17588,8 @@ function domEach(array, fn) {
|
|
|
17592
17588
|
fn(array[i], i);
|
|
17593
17589
|
return array;
|
|
17594
17590
|
}
|
|
17595
|
-
function cloneDom(
|
|
17596
|
-
const clone2 = "length" in
|
|
17591
|
+
function cloneDom(dom) {
|
|
17592
|
+
const clone2 = "length" in dom ? Array.prototype.map.call(dom, (el) => cloneNode(el, true)) : [cloneNode(dom, true)];
|
|
17597
17593
|
const root2 = new Document$1(clone2);
|
|
17598
17594
|
clone2.forEach((node) => {
|
|
17599
17595
|
node.parent = root2;
|
|
@@ -19824,8 +19820,8 @@ function _insert(concatenator) {
|
|
|
19824
19820
|
if (!hasChildren(el))
|
|
19825
19821
|
return;
|
|
19826
19822
|
const domSrc = typeof elems[0] === "function" ? elems[0].call(el, i, this._render(el.children)) : elems;
|
|
19827
|
-
const
|
|
19828
|
-
concatenator(
|
|
19823
|
+
const dom = this._makeDomArray(domSrc, i < lastIdx);
|
|
19824
|
+
concatenator(dom, el.children, el);
|
|
19829
19825
|
});
|
|
19830
19826
|
};
|
|
19831
19827
|
}
|
|
@@ -19879,11 +19875,11 @@ function prependTo(target) {
|
|
|
19879
19875
|
prependTarget.prepend(this);
|
|
19880
19876
|
return this;
|
|
19881
19877
|
}
|
|
19882
|
-
const append = _insert((
|
|
19883
|
-
uniqueSplice(children2, children2.length, 0,
|
|
19878
|
+
const append = _insert((dom, children2, parent2) => {
|
|
19879
|
+
uniqueSplice(children2, children2.length, 0, dom, parent2);
|
|
19884
19880
|
});
|
|
19885
|
-
const prepend = _insert((
|
|
19886
|
-
uniqueSplice(children2, 0, 0,
|
|
19881
|
+
const prepend = _insert((dom, children2, parent2) => {
|
|
19882
|
+
uniqueSplice(children2, 0, 0, dom, parent2);
|
|
19887
19883
|
});
|
|
19888
19884
|
function _wrap(insert) {
|
|
19889
19885
|
return function(wrapper) {
|
|
@@ -19968,8 +19964,8 @@ function after(...elems) {
|
|
|
19968
19964
|
if (index2 < 0)
|
|
19969
19965
|
return;
|
|
19970
19966
|
const domSrc = typeof elems[0] === "function" ? elems[0].call(el, i, this._render(el.children)) : elems;
|
|
19971
|
-
const
|
|
19972
|
-
uniqueSplice(siblings2, index2 + 1, 0,
|
|
19967
|
+
const dom = this._makeDomArray(domSrc, i < lastIdx);
|
|
19968
|
+
uniqueSplice(siblings2, index2 + 1, 0, dom, parent2);
|
|
19973
19969
|
});
|
|
19974
19970
|
}
|
|
19975
19971
|
function insertAfter(target) {
|
|
@@ -20005,8 +20001,8 @@ function before(...elems) {
|
|
|
20005
20001
|
if (index2 < 0)
|
|
20006
20002
|
return;
|
|
20007
20003
|
const domSrc = typeof elems[0] === "function" ? elems[0].call(el, i, this._render(el.children)) : elems;
|
|
20008
|
-
const
|
|
20009
|
-
uniqueSplice(siblings2, index2, 0,
|
|
20004
|
+
const dom = this._makeDomArray(domSrc, i < lastIdx);
|
|
20005
|
+
uniqueSplice(siblings2, index2, 0, dom, parent2);
|
|
20010
20006
|
});
|
|
20011
20007
|
}
|
|
20012
20008
|
function insertBefore(target) {
|
|
@@ -20044,11 +20040,11 @@ function replaceWith(content) {
|
|
|
20044
20040
|
}
|
|
20045
20041
|
const siblings2 = parent2.children;
|
|
20046
20042
|
const cont = typeof content === "function" ? content.call(el, i, el) : content;
|
|
20047
|
-
const
|
|
20048
|
-
update(
|
|
20043
|
+
const dom = this._makeDomArray(cont);
|
|
20044
|
+
update(dom, null);
|
|
20049
20045
|
const index2 = siblings2.indexOf(el);
|
|
20050
|
-
uniqueSplice(siblings2, index2, 1,
|
|
20051
|
-
if (!
|
|
20046
|
+
uniqueSplice(siblings2, index2, 1, dom, parent2);
|
|
20047
|
+
if (!dom.includes(el)) {
|
|
20052
20048
|
el.parent = el.prev = el.next = null;
|
|
20053
20049
|
}
|
|
20054
20050
|
});
|
|
@@ -20284,8 +20280,8 @@ function getLoad(parse2, render2) {
|
|
|
20284
20280
|
_parse(content2, options2, isDocument3, context) {
|
|
20285
20281
|
return parse2(content2, options2, isDocument3, context);
|
|
20286
20282
|
}
|
|
20287
|
-
_render(
|
|
20288
|
-
return render2(
|
|
20283
|
+
_render(dom) {
|
|
20284
|
+
return render2(dom, this.options);
|
|
20289
20285
|
}
|
|
20290
20286
|
}
|
|
20291
20287
|
function initialize(selector, context, root2 = initialRoot, opts) {
|
|
@@ -28472,8 +28468,8 @@ function parseWithParse5(content, options, isDocument2, context) {
|
|
|
28472
28468
|
return isDocument2 ? parse$2(content, opts) : parseFragment(context, content, opts);
|
|
28473
28469
|
}
|
|
28474
28470
|
const renderOpts = { treeAdapter: adapter };
|
|
28475
|
-
function renderWithParse5(
|
|
28476
|
-
const nodes = "length" in
|
|
28471
|
+
function renderWithParse5(dom) {
|
|
28472
|
+
const nodes = "length" in dom ? dom : [dom];
|
|
28477
28473
|
for (let index2 = 0; index2 < nodes.length; index2 += 1) {
|
|
28478
28474
|
const node = nodes[index2];
|
|
28479
28475
|
if (isDocument$1(node)) {
|
|
@@ -29725,7 +29721,7 @@ function parseDocument$1(data2, options) {
|
|
|
29725
29721
|
return handler.root;
|
|
29726
29722
|
}
|
|
29727
29723
|
const parse$1 = getParse((content, options, isDocument2, context) => options.xmlMode || options._useHtmlParser2 ? parseDocument$1(content, options) : parseWithParse5(content, options, isDocument2, context));
|
|
29728
|
-
const load = getLoad(parse$1, (
|
|
29724
|
+
const load = getLoad(parse$1, (dom, options) => options.xmlMode || options._useHtmlParser2 ? render$1(dom, options) : renderWithParse5(dom));
|
|
29729
29725
|
load([]);
|
|
29730
29726
|
const defaultSelectorRules = {
|
|
29731
29727
|
"div,p": ({ $node }) => ({
|
|
@@ -49601,7 +49597,7 @@ const remark_anyblock_render_codeblock = () => {
|
|
|
49601
49597
|
if (typeof document == "undefined") return;
|
|
49602
49598
|
return (tree, _file) => {
|
|
49603
49599
|
visit$1(tree, "code", (node, index2, parent2) => {
|
|
49604
|
-
if (
|
|
49600
|
+
if (node.lang.toLowerCase() != "anyblock") return;
|
|
49605
49601
|
if (!parent2 || !index2) return;
|
|
49606
49602
|
const lines = node.value.split("\n");
|
|
49607
49603
|
const head = lines.shift();
|
|
@@ -49631,7 +49627,7 @@ const remark_anyblock_render_codeblock = () => {
|
|
|
49631
49627
|
el_child.innerHTML = result;
|
|
49632
49628
|
});
|
|
49633
49629
|
}
|
|
49634
|
-
const
|
|
49630
|
+
const transformer_anyblock = () => {
|
|
49635
49631
|
return {
|
|
49636
49632
|
name: "AnyBlock",
|
|
49637
49633
|
markdownPlugins(_ctx) {
|
|
@@ -49651,6 +49647,6 @@ export {
|
|
|
49651
49647
|
abConvertEvent,
|
|
49652
49648
|
jsdom_init,
|
|
49653
49649
|
remark_anyblock_render_codeblock,
|
|
49654
|
-
|
|
49650
|
+
transformer_anyblock
|
|
49655
49651
|
};
|
|
49656
49652
|
//# sourceMappingURL=remark-any-block.js.map
|
package/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// JsDom。仅用于提供document对象支持 (如果Ob环境中则不需要,用ob自带document对象的)
|
|
2
2
|
export { jsdom_init } from './jsdom_init'
|
|
3
3
|
export {
|
|
4
|
-
|
|
4
|
+
transformer_anyblock,
|
|
5
5
|
// remark_anyblock_to_codeblock, // 取消注释则用库的地方会报错找不到 document
|
|
6
6
|
remark_anyblock_render_codeblock,
|
|
7
7
|
} from './anyblock'
|
package/jsdom_init.ts
CHANGED
|
@@ -6,19 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
// import jsdom from "jsdom"
|
|
8
8
|
|
|
9
|
-
let dom: any = null;
|
|
10
|
-
|
|
11
9
|
export async function jsdom_init() {
|
|
12
10
|
const { default: jsdom } = await import('jsdom') // 废弃,要同步,避免docuemnt初始化不及时
|
|
13
11
|
const { JSDOM } = jsdom
|
|
14
|
-
dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
|
|
12
|
+
const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
|
|
15
13
|
url: 'http://localhost/', // @warn 若缺少该行,则在mdit+build环境下,编译报错
|
|
16
|
-
})
|
|
17
|
-
jsdom_able()
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/// 启用 jsdom 环境
|
|
21
|
-
export async function jsdom_able() {
|
|
14
|
+
});
|
|
22
15
|
global.Storage = dom.window.Storage;
|
|
23
16
|
global.window = dom.window as any
|
|
24
17
|
global.history = dom.window.history // @warn 若缺少该行,则在mdit+build环境下,编译报错:ReferenceError: history is not defined
|
|
@@ -35,10 +28,3 @@ export async function jsdom_able() {
|
|
|
35
28
|
dom.window.scrollTo = ()=>{} // @warn 若缺少该行,编译警告:Error: Not implemented: window.scrollTo
|
|
36
29
|
global.MutationObserver = dom.window.MutationObserver
|
|
37
30
|
}
|
|
38
|
-
|
|
39
|
-
/// 禁用 jsdom 环境
|
|
40
|
-
export async function jsdom_disable() {
|
|
41
|
-
global.window = undefined
|
|
42
|
-
global.history = undefined
|
|
43
|
-
global.document = undefined
|
|
44
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anyblock/remark-any-block",
|
|
3
|
-
"version": "1.0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "You can flexibility to create a 'Block' by many means. It also provides many useful features, like `list to table`.",
|
|
5
5
|
"types": "@types/index_remark.d.ts",
|
|
6
6
|
"type": "module",
|