You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

myst-common

Package Overview
Dependencies
Maintainers
2
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

myst-common - npm Package Compare versions

Comparing version

to
1.1.14

2

dist/index.d.ts

@@ -5,5 +5,5 @@ export { admonitionKindToTitle, toText, fileError, fileWarn, fileInfo, createId, normalizeLabel, createHtmlId, liftChildren, setTextAsChild, copyNode, mergeTextNodes, writeTexLabelledComment, } from './utils.js';

export { TemplateKind, TemplateOptionType } from './templates.js';
export { AdmonitionKind, NotebookCell, ParseTypesEnum, TargetKind } from './types.js';
export { AdmonitionKind, NotebookCell, NotebookCellTags, ParseTypesEnum, TargetKind, } from './types.js';
export type { MessageInfo } from './utils.js';
export type { GenericNode, GenericParent, Citations, References, ArgDefinition, BodyDefinition, OptionDefinition, DirectiveData, RoleData, DirectiveSpec, RoleSpec, ParseTypes, MystPlugin, PluginOptions, PluginUtils, TransformSpec, } from './types.js';
//# sourceMappingURL=index.d.ts.map

@@ -5,2 +5,2 @@ export { admonitionKindToTitle, toText, fileError, fileWarn, fileInfo, createId, normalizeLabel, createHtmlId, liftChildren, setTextAsChild, copyNode, mergeTextNodes, writeTexLabelledComment, } from './utils.js';

export { TemplateKind, TemplateOptionType } from './templates.js';
export { AdmonitionKind, NotebookCell, ParseTypesEnum, TargetKind } from './types.js';
export { AdmonitionKind, NotebookCell, NotebookCellTags, ParseTypesEnum, TargetKind, } from './types.js';

@@ -28,2 +28,12 @@ import type { Plugin } from 'unified';

}
export declare enum NotebookCellTags {
'removeStderr' = "remove-stderr",
'removeStdout' = "remove-stdout",
'hideCell' = "hide-cell",
'hideInput' = "hide-input",
'hideOutput' = "hide-output",
'removeCell' = "remove-cell",
'removeInput' = "remove-input",
'removeOutput' = "remove-output"
}
export type References = {

@@ -30,0 +40,0 @@ cite?: Citations;

@@ -6,2 +6,13 @@ export var NotebookCell;

})(NotebookCell || (NotebookCell = {}));
export var NotebookCellTags;
(function (NotebookCellTags) {
NotebookCellTags["removeStderr"] = "remove-stderr";
NotebookCellTags["removeStdout"] = "remove-stdout";
NotebookCellTags["hideCell"] = "hide-cell";
NotebookCellTags["hideInput"] = "hide-input";
NotebookCellTags["hideOutput"] = "hide-output";
NotebookCellTags["removeCell"] = "remove-cell";
NotebookCellTags["removeInput"] = "remove-input";
NotebookCellTags["removeOutput"] = "remove-output";
})(NotebookCellTags || (NotebookCellTags = {}));
// Types for defining roles and directives

@@ -8,0 +19,0 @@ export var ParseTypesEnum;

@@ -32,3 +32,10 @@ import type { VFile } from 'vfile';

export declare function createHtmlId(identifier?: string): string | undefined;
export declare function liftChildren(tree: GenericParent, nodeType: string): void;
/**
* Eliminate all parent nodes in `tree` of type `removeType`; children of eliminated nodes are moved up to it's parent
*
* Nodes of `removeType` will remain if:
* - they are the root of `tree`
* - their children are undefined
*/
export declare function liftChildren(tree: GenericParent | GenericNode, removeType: string): void;
export declare function setTextAsChild(node: Partial<Parent>, text: string): void;

@@ -35,0 +42,0 @@ /**

@@ -1,2 +0,1 @@

import { map } from 'unist-util-map';
import { customAlphabet } from 'nanoid';

@@ -58,10 +57,10 @@ function addMessageInfo(message, info) {

}
export function liftChildren(tree, nodeType) {
map(tree, (node) => {
var _a, _b;
const children = (_b = (_a = node.children) === null || _a === void 0 ? void 0 : _a.map((child) => {
if (child.type === nodeType && child.children)
return child.children;
return child;
})) === null || _b === void 0 ? void 0 : _b.flat();
/**
* Helper function for recursively lifting children
*/
function getNodeOrLiftedChildren(node, removeType) {
if (!node.children)
return [node];
const children = node.children.map((child) => getNodeOrLiftedChildren(child, removeType)).flat();
if (node.type === removeType) {
// There are some checks in unist that look like `'children' in node`

@@ -71,7 +70,19 @@ // all children must be deleted, and not a key on the object

delete node.children;
if (children !== undefined)
node.children = children;
return node;
});
return children;
}
node.children = children;
return [node];
}
/**
* Eliminate all parent nodes in `tree` of type `removeType`; children of eliminated nodes are moved up to it's parent
*
* Nodes of `removeType` will remain if:
* - they are the root of `tree`
* - their children are undefined
*/
export function liftChildren(tree, removeType) {
if (!tree.children)
return;
tree.children = tree.children.map((child) => getNodeOrLiftedChildren(child, removeType)).flat();
}
export function setTextAsChild(node, text) {

@@ -78,0 +89,0 @@ node.children = [{ type: 'text', value: text }];

{
"name": "myst-common",
"sideEffects": false,
"version": "1.1.13",
"version": "1.1.14",
"type": "module",

@@ -23,7 +23,6 @@ "exports": "./dist/index.js",

"mdast": "^3.0.0",
"myst-frontmatter": "^1.1.13",
"myst-frontmatter": "^1.1.14",
"myst-spec": "^0.0.4",
"nanoid": "^4.0.0",
"unified": "^10.1.2",
"unist-util-map": "^3.0.0",
"unist-util-remove": "^3.1.0",

@@ -30,0 +29,0 @@ "unist-util-select": "^4.0.3",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet