New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@unified-latex/unified-latex-util-trim

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unified-latex/unified-latex-util-trim - npm Package Compare versions

Comparing version 1.0.1 to 1.0.5

192

dist/index.js

@@ -70,188 +70,12 @@ // libs/trim.ts

// libs/unified-latex-trim-environment-contents.ts
import { match as match3 } from "@unified-latex/unified-latex-util-match";
// ../unified-latex-util-visit/dist/index.js
import { match as match2 } from "@unified-latex/unified-latex-util-match";
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
function listMathChildren(node) {
const NULL_RETURN = { enter: [], leave: [] };
if (Array.isArray(node)) {
return NULL_RETURN;
}
if (match2.math(node)) {
return { enter: ["content"], leave: [] };
}
const renderInfo = node._renderInfo || {};
if (renderInfo.inMathMode == null) {
return NULL_RETURN;
}
if (match2.macro(node)) {
if (renderInfo.inMathMode === true) {
return { enter: ["args"], leave: [] };
} else if (renderInfo.inMathMode === false) {
return { enter: [], leave: ["args"] };
}
}
if (match2.environment(node)) {
if (renderInfo.inMathMode === true) {
return { enter: ["content"], leave: [] };
} else {
return { enter: [], leave: ["content"] };
}
}
return NULL_RETURN;
}
var CONTINUE = Symbol("continue");
var SKIP = Symbol("skip");
var EXIT = Symbol("exit");
var DEFAULT_CONTEXT = {
inMathMode: false,
hasMathModeAncestor: false
};
function visit(tree, visitor, options) {
const {
startingContext = DEFAULT_CONTEXT,
test = () => true,
includeArrays = false
} = options || {};
let enter;
let leave;
if (typeof visitor === "function") {
enter = visitor;
} else if (visitor && typeof visitor === "object") {
enter = visitor.enter;
leave = visitor.leave;
}
walk(tree, {
key: void 0,
index: void 0,
parents: [],
containingArray: void 0,
context: __spreadValues({}, startingContext)
});
function walk(node, { key, index, parents, context, containingArray }) {
const nodePassesTest = includeArrays ? test(node, { key, index, parents, context, containingArray }) : !Array.isArray(node) && test(node, { key, index, parents, context, containingArray });
const result = enter && nodePassesTest ? toResult(enter(node, {
key,
index,
parents,
context,
containingArray
})) : [CONTINUE];
if (result[0] === EXIT) {
return result;
}
if (result[0] === SKIP) {
return leave && nodePassesTest ? toResult(leave(node, {
key,
index,
parents,
context,
containingArray
})) : result;
}
if (Array.isArray(node)) {
for (let index2 = 0; index2 > -1 && index2 < node.length; index2++) {
const item = node[index2];
const result2 = walk(item, {
key,
index: index2,
parents,
context,
containingArray: node
});
if (result2[0] === EXIT) {
return result2;
}
if (typeof result2[1] === "number") {
index2 = result2[1] - 1;
}
}
} else {
let childProps = ["content", "args"];
switch (node.type) {
case "macro":
childProps = ["args"];
break;
case "comment":
case "string":
case "verb":
case "verbatim":
childProps = [];
break;
default:
break;
}
const mathModeProps = listMathChildren(node);
for (const key2 of childProps) {
const value = node[key2];
const grandparents = [node].concat(parents);
if (value == null) {
continue;
}
const newContext = __spreadValues({}, context);
if (mathModeProps.enter.includes(key2)) {
newContext.inMathMode = true;
newContext.hasMathModeAncestor = true;
} else if (mathModeProps.leave.includes(key2)) {
newContext.inMathMode = false;
}
const result2 = walk(value, {
key: key2,
index: void 0,
parents: grandparents,
context: newContext,
containingArray: void 0
});
if (result2[0] === EXIT) {
return result2;
}
}
}
return leave && nodePassesTest ? toResult(leave(node, {
key,
index,
parents,
context,
containingArray
})) : result;
}
}
function toResult(value) {
if (value == null) {
return [CONTINUE];
}
if (Array.isArray(value)) {
return value;
}
if (typeof value === "number") {
return [CONTINUE, value];
}
return [value];
}
// libs/unified-latex-trim-environment-contents.ts
import { visit } from "@unified-latex/unified-latex-util-visit";
var unifiedLatexTrimEnvironmentContents = function unifiedLatexTrimEnvironmentContents2() {
return (tree) => {
visit(tree, (node) => {
if (!(match3.math(node) || match3.anyEnvironment(node))) {
if (!(match2.math(node) || match2.anyEnvironment(node))) {
return;
}
let firstNode = node.content[0];
if (match3.comment(firstNode) && firstNode.sameline) {
if (match2.comment(firstNode) && firstNode.sameline) {
firstNode.suffixParbreak = false;

@@ -276,3 +100,3 @@ trimEnd(node.content);

// libs/has-whitespace-equivalent.ts
import { match as match4 } from "@unified-latex/unified-latex-util-match";
import { match as match3 } from "@unified-latex/unified-latex-util-match";
function hasWhitespaceEquivalent(nodes) {

@@ -283,3 +107,3 @@ let start = false;

const node = nodes[i];
if (match4.comment(node)) {
if (match3.comment(node)) {
if (node.leadingWhitespace) {

@@ -291,3 +115,3 @@ start = true;

}
if (match4.whitespace(node)) {
if (match3.whitespace(node)) {
start = true;

@@ -299,3 +123,3 @@ }

const node = nodes[j];
if (match4.comment(node)) {
if (match3.comment(node)) {
if (node.leadingWhitespace) {

@@ -307,3 +131,3 @@ end = true;

}
if (match4.whitespace(node)) {
if (match3.whitespace(node)) {
end = true;

@@ -310,0 +134,0 @@ }

10

package.json
{
"name": "@unified-latex/unified-latex-util-trim",
"version": "1.0.1",
"version": "1.0.5",
"description": "Functions for modifying a unified-latex AST",

@@ -8,4 +8,6 @@ "main": "dist/index.js",

"dependencies": {
"@unified-latex/unified-latex-types": "*",
"@unified-latex/unified-latex-util-match": "*"
"@unified-latex/unified-latex-types": "^1.0.5",
"@unified-latex/unified-latex-util-match": "^1.0.5",
"@unified-latex/unified-latex-util-visit": "^1.0.5",
"unified": "^10.1.2"
},

@@ -32,3 +34,3 @@ "files": [

"clean": "rm -rf ./dist && rm -rf tsconfig.tsbuildinfo",
"compile": "tsc -b tsconfig.json & node build.js",
"compile": "tsc -b tsconfig.json & node build.js & wait",
"test": "jest"

@@ -35,0 +37,0 @@ },

@@ -19,2 +19,11 @@ <!-- DO NOT MODIFY -->

## Install
```bash
npm install @unified-latex/unified-latex-util-trim
```
This package contains both esm and commonjs exports. To explicitly access the esm export,
import the `.js` file. To explicitly access the commonjs export, import the `.cjs` file.
# Plugins

@@ -21,0 +30,0 @@

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