@milkdown/preset-commonmark 4.13.2 → 4.13.3

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.
@@ -0,0 +1,3 @@
1
+ import { Node } from 'unist';
2
+ export declare const filterHTMLPlugin: () => (tree: Node) => void;
3
+ //# sourceMappingURL=filter-html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-html.d.ts","sourceRoot":"","sources":["../../src/plugin/filter-html.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,IAAI,EAAU,MAAM,OAAO,CAAC;AA0B9C,eAAO,MAAM,gBAAgB,eACE,IAAI,SAUlC,CAAC"}
@@ -0,0 +1,32 @@
1
+ const isParent = (node) => !!node.children;
2
+ const isHTML = (node) => node.type === 'html';
3
+ function flatMapWithDepth(ast, fn) {
4
+ return transform(ast, 0, null)[0];
5
+ function transform(node, index, parent) {
6
+ if (isParent(node)) {
7
+ const out = [];
8
+ for (let i = 0, n = node.children.length; i < n; i++) {
9
+ const xs = transform(node.children[i], i, node);
10
+ if (xs) {
11
+ for (let j = 0, m = xs.length; j < m; j++) {
12
+ out.push(xs[j]);
13
+ }
14
+ }
15
+ }
16
+ node.children = out;
17
+ }
18
+ return fn(node, index, parent);
19
+ }
20
+ }
21
+ export const filterHTMLPlugin = () => {
22
+ function transformer(tree) {
23
+ flatMapWithDepth(tree, (node) => {
24
+ if (!isHTML(node)) {
25
+ return [node];
26
+ }
27
+ return [];
28
+ });
29
+ }
30
+ return transformer;
31
+ };
32
+ //# sourceMappingURL=filter-html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-html.js","sourceRoot":"","sources":["../../src/plugin/filter-html.ts"],"names":[],"mappings":"AAGA,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAkB,EAAE,CAAC,CAAC,CAAE,IAAe,CAAC,QAAQ,CAAC;AAC7E,MAAM,MAAM,GAAG,CAAC,IAAU,EAA2B,EAAE,CAAC,IAAI,CAAC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"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AA0CA,eAAO,MAAM,iBAAiB,2CAAmD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB,2CAAmD,CAAC"}
@@ -1,36 +1,6 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
  import { remarkPluginFactory } from '@milkdown/core';
3
3
  import links from 'remark-inline-links';
4
- const isParent = (node) => !!node.children;
5
- const isHTML = (node) => node.type === 'html';
6
- function flatMapWithDepth(ast, fn) {
7
- return transform(ast, 0, null)[0];
8
- function transform(node, index, parent) {
9
- if (isParent(node)) {
10
- const out = [];
11
- for (let i = 0, n = node.children.length; i < n; i++) {
12
- const xs = transform(node.children[i], i, node);
13
- if (xs) {
14
- for (let j = 0, m = xs.length; j < m; j++) {
15
- out.push(xs[j]);
16
- }
17
- }
18
- }
19
- node.children = out;
20
- }
21
- return fn(node, index, parent);
22
- }
23
- }
24
- const filterHTMLPlugin = () => {
25
- function transformer(tree) {
26
- flatMapWithDepth(tree, (node) => {
27
- if (!isHTML(node)) {
28
- return [node];
29
- }
30
- return [];
31
- });
32
- }
33
- return transformer;
34
- };
4
+ import { filterHTMLPlugin } from './filter-html';
35
5
  export const commonmarkPlugins = [remarkPluginFactory([links, filterHTMLPlugin])];
36
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,MAAM,qBAAqB,CAAC;AAGxC,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAkB,EAAE,CAAC,CAAC,CAAE,IAAe,CAAC,QAAQ,CAAC;AAC7E,MAAM,MAA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IACD,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,mBAAmB,CAAC,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,MAAM,qBAAqB,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,mBAAmB,CAAC,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milkdown/preset-commonmark",
3
- "version": "4.13.2",
3
+ "version": "4.13.3",
4
4
  "main": "lib/index.js",
5
5
  "module": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -0,0 +1,39 @@
1
+ /* Copyright 2021, Milkdown by Mirone. */
2
+ import { Literal, Node, Parent } from 'unist';
3
+
4
+ const isParent = (node: Node): node is Parent => !!(node as Parent).children;
5
+ const isHTML = (node: Node): node is Literal<string> => node.type === 'html';
6
+
7
+ function flatMapWithDepth(ast: Node, fn: (node: Node, index: number, parent: Node | null) => Node[]) {
8
+ return transform(ast, 0, null)[0];
9
+
10
+ function transform(node: Node, index: number, parent: Node | null) {
11
+ if (isParent(node)) {
12
+ const out = [];
13
+ for (let i = 0, n = node.children.length; i < n; i++) {
14
+ const xs = transform(node.children[i], i, node);
15
+ if (xs) {
16
+ for (let j = 0, m = xs.length; j < m; j++) {
17
+ out.push(xs[j]);
18
+ }
19
+ }
20
+ }
21
+ node.children = out;
22
+ }
23
+
24
+ return fn(node, index, parent);
25
+ }
26
+ }
27
+
28
+ export const filterHTMLPlugin = () => {
29
+ function transformer(tree: Node) {
30
+ flatMapWithDepth(tree, (node) => {
31
+ if (!isHTML(node)) {
32
+ return [node];
33
+ }
34
+
35
+ return [];
36
+ });
37
+ }
38
+ return transformer;
39
+ };
@@ -1,43 +1,7 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
  import { remarkPluginFactory } from '@milkdown/core';
3
3
  import links from 'remark-inline-links';
4
- import { Literal, Node, Parent } from 'unist';
5
4
 
6
- const isParent = (node: Node): node is Parent => !!(node as Parent).children;
7
- const isHTML = (node: Node): node is Literal<string> => node.type === 'html';
8
-
9
- function flatMapWithDepth(ast: Node, fn: (node: Node, index: number, parent: Node | null) => Node[]) {
10
- return transform(ast, 0, null)[0];
11
-
12
- function transform(node: Node, index: number, parent: Node | null) {
13
- if (isParent(node)) {
14
- const out = [];
15
- for (let i = 0, n = node.children.length; i < n; i++) {
16
- const xs = transform(node.children[i], i, node);
17
- if (xs) {
18
- for (let j = 0, m = xs.length; j < m; j++) {
19
- out.push(xs[j]);
20
- }
21
- }
22
- }
23
- node.children = out;
24
- }
25
-
26
- return fn(node, index, parent);
27
- }
28
- }
29
-
30
- const filterHTMLPlugin = () => {
31
- function transformer(tree: Node) {
32
- flatMapWithDepth(tree, (node) => {
33
- if (!isHTML(node)) {
34
- return [node];
35
- }
36
-
37
- return [];
38
- });
39
- }
40
- return transformer;
41
- };
5
+ import { filterHTMLPlugin } from './filter-html';
42
6
 
43
7
  export const commonmarkPlugins = [remarkPluginFactory([links, filterHTMLPlugin])];