Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@milkdown/preset-commonmark

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@milkdown/preset-commonmark - npm Package Compare versions

Comparing version 4.13.2 to 4.13.3

lib/plugin/filter-html.d.ts

32

lib/plugin/index.js
/* Copyright 2021, Milkdown by Mirone. */
import { remarkPluginFactory } from '@milkdown/core';
import links from 'remark-inline-links';
const isParent = (node) => !!node.children;
const isHTML = (node) => node.type === 'html';
function flatMapWithDepth(ast, fn) {
return transform(ast, 0, null)[0];
function transform(node, index, parent) {
if (isParent(node)) {
const out = [];
for (let i = 0, n = node.children.length; i < n; i++) {
const xs = transform(node.children[i], i, node);
if (xs) {
for (let j = 0, m = xs.length; j < m; j++) {
out.push(xs[j]);
}
}
}
node.children = out;
}
return fn(node, index, parent);
}
}
const filterHTMLPlugin = () => {
function transformer(tree) {
flatMapWithDepth(tree, (node) => {
if (!isHTML(node)) {
return [node];
}
return [];
});
}
return transformer;
};
import { filterHTMLPlugin } from './filter-html';
export const commonmarkPlugins = [remarkPluginFactory([links, filterHTMLPlugin])];
//# sourceMappingURL=index.js.map
{
"name": "@milkdown/preset-commonmark",
"version": "4.13.2",
"version": "4.13.3",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "module": "lib/index.js",

/* Copyright 2021, Milkdown by Mirone. */
import { remarkPluginFactory } from '@milkdown/core';
import links from 'remark-inline-links';
import { Literal, Node, Parent } from 'unist';
const isParent = (node: Node): node is Parent => !!(node as Parent).children;
const isHTML = (node: Node): node is Literal<string> => node.type === 'html';
import { filterHTMLPlugin } from './filter-html';
function flatMapWithDepth(ast: Node, fn: (node: Node, index: number, parent: Node | null) => Node[]) {
return transform(ast, 0, null)[0];
function transform(node: Node, index: number, parent: Node | null) {
if (isParent(node)) {
const out = [];
for (let i = 0, n = node.children.length; i < n; i++) {
const xs = transform(node.children[i], i, node);
if (xs) {
for (let j = 0, m = xs.length; j < m; j++) {
out.push(xs[j]);
}
}
}
node.children = out;
}
return fn(node, index, parent);
}
}
const filterHTMLPlugin = () => {
function transformer(tree: Node) {
flatMapWithDepth(tree, (node) => {
if (!isHTML(node)) {
return [node];
}
return [];
});
}
return transformer;
};
export const commonmarkPlugins = [remarkPluginFactory([links, filterHTMLPlugin])];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc