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

myst-transforms

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

myst-transforms - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

4

dist/cjs/blocks.js

@@ -14,3 +14,3 @@ "use strict";

var unist_util_select_1 = require("unist-util-select");
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
function blockNestingTransform(mdast) {

@@ -48,3 +48,3 @@ if (!(0, unist_util_select_1.select)('block', mdast)) {

catch (error) {
(0, myst_utils_1.fileError)(file, 'Problem parsing JSON for block', { node: block, source: TRANSFORM_SOURCE });
(0, myst_common_1.fileError)(file, 'Problem parsing JSON for block', { node: block, source: TRANSFORM_SOURCE });
}

@@ -51,0 +51,0 @@ });

@@ -5,3 +5,3 @@ "use strict";

var unist_util_select_1 = require("unist-util-select");
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
function codeTransform(mdast, file, opts) {

@@ -12,3 +12,3 @@ var code = (0, unist_util_select_1.selectAll)('code', mdast);

if (!(opts === null || opts === void 0 ? void 0 : opts.lang)) {
(0, myst_utils_1.fileWarn)(file, 'Language is not defined for code block', { node: node });
(0, myst_common_1.fileWarn)(file, 'Language is not defined for code block', { node: node });
return;

@@ -15,0 +15,0 @@ }

@@ -27,3 +27,3 @@ "use strict";

var mdast_util_find_and_replace_1 = require("mdast-util-find-and-replace");
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
var TRANSFORM_NAME = 'myst-transforms:enumerate';

@@ -68,3 +68,3 @@ var TargetKind;

if (noNodeChildren) {
(0, myst_utils_1.setTextAsChild)(node, template);
(0, myst_common_1.setTextAsChild)(node, template);
}

@@ -96,3 +96,3 @@ var num = enumerator != null ? String(enumerator) : UNKNOWN_REFERENCE_ENUMERATOR;

var numberType = used.number && used.s ? '"{number}" and "%s"' : "".concat(used.number ? '"number"' : '"%s"');
(0, myst_utils_1.fileWarn)(file, "Reference for \"".concat(node.identifier, "\" uses ").concat(numberType, " in the template, but node is not numbered."), {
(0, myst_common_1.fileWarn)(file, "Reference for \"".concat(node.identifier, "\" uses ").concat(numberType, " in the template, but node is not numbered."), {
node: node,

@@ -189,3 +189,3 @@ note: 'The node was filled in with "??" as the number.',

if (!node.html_id) {
node.html_id = (0, myst_utils_1.createHtmlId)(node.identifier);
node.html_id = (0, myst_common_1.createHtmlId)(node.identifier);
}

@@ -197,3 +197,3 @@ if (node.identifier && this.targets[node.identifier]) {

return; // Do not warn on implicit headings
(0, myst_utils_1.fileWarn)(this.file, "Duplicate identifier \"".concat(node.identifier, "\" for node of type ").concat(node.type), {
(0, myst_common_1.fileWarn)(this.file, "Duplicate identifier \"".concat(node.identifier, "\" for node of type ").concat(node.type), {
node: node,

@@ -206,3 +206,3 @@ source: TRANSFORM_NAME

this.targets[node.identifier] = {
node: (0, myst_utils_1.copyNode)(node),
node: (0, myst_common_1.copyNode)(node),
kind: kind

@@ -256,3 +256,3 @@ };

var headingTemplate = numberHeading ? 'Section %s' : '{name}';
fillReferenceEnumerators(this.file, node, headingTemplate, target.node.enumerator, (0, myst_utils_1.copyNode)(target.node).children);
fillReferenceEnumerators(this.file, node, headingTemplate, target.node.enumerator, (0, myst_common_1.copyNode)(target.node).children);
}

@@ -265,3 +265,3 @@ else if (target.kind === TargetKind.equation) {

var caption = (0, unist_util_select_1.select)('caption > paragraph', target.node);
var title = caption ? (_b = (0, myst_utils_1.copyNode)(caption)) === null || _b === void 0 ? void 0 : _b.children : undefined;
var title = caption ? (_b = (0, myst_common_1.copyNode)(caption)) === null || _b === void 0 ? void 0 : _b.children : undefined;
if (title && node.kind === ReferenceKind.ref && noNodeChildren) {

@@ -282,3 +282,3 @@ node.children = title;

return;
(0, myst_utils_1.fileWarn)(this.file, "Cross reference target was not found: ".concat(node.identifier), {
(0, myst_common_1.fileWarn)(this.file, "Cross reference target was not found: ".concat(node.identifier), {
node: node,

@@ -392,3 +392,3 @@ source: TRANSFORM_NAME

var identifier = link.url.replace(/^#/, '');
var reference = (0, myst_utils_1.normalizeLabel)(identifier);
var reference = (0, myst_common_1.normalizeLabel)(identifier);
var target = (_a = opts.state.getTarget(identifier)) !== null && _a !== void 0 ? _a : opts.state.getTarget(reference === null || reference === void 0 ? void 0 : reference.identifier);

@@ -399,3 +399,3 @@ if (!target || !reference) {

// Only warn on explicit internal URLs
(0, myst_utils_1.fileWarn)(opts.state.file, "No target for internal reference \"".concat(link.url, "\" was found."), {
(0, myst_common_1.fileWarn)(opts.state.file, "No target for internal reference \"".concat(link.url, "\" was found."), {
node: node,

@@ -407,3 +407,3 @@ source: TRANSFORM_NAME

if (!link.url.startsWith('#') && opts.state.file) {
(0, myst_utils_1.fileWarn)(opts.state.file, "Legacy syntax used for link target, please prepend a '#' to your link url: \"".concat(link.url, "\""), {
(0, myst_common_1.fileWarn)(opts.state.file, "Legacy syntax used for link target, please prepend a '#' to your link url: \"".concat(link.url, "\""), {
node: node,

@@ -423,3 +423,3 @@ note: 'The link target should be of the form `[](#target)`, including the `#` sign.\nThis may be deprecated in the future.',

if (target.node.implicit && opts.state.file) {
(0, myst_utils_1.fileWarn)(opts.state.file, "Linking \"".concat(target.node.identifier, "\" to an implicit ").concat(target.kind, " reference, best practice is to create an explicit reference."), {
(0, myst_common_1.fileWarn)(opts.state.file, "Linking \"".concat(target.node.identifier, "\" to an implicit ").concat(target.kind, " reference, best practice is to create an explicit reference."), {
node: node,

@@ -426,0 +426,0 @@ note: 'Explicit references do not break when you update the title to a section, they are preferred over using the implicit HTML ID created for headers.',

@@ -10,3 +10,3 @@ "use strict";

var unist_util_remove_1 = require("unist-util-remove");
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
function getFrontmatter(tree, opts) {

@@ -27,3 +27,3 @@ if (opts === void 0) { opts = { removeYaml: true, removeHeading: true }; }

if (nextNodeIsHeading) {
var title = (0, myst_utils_1.toText)(nextNode.children);
var title = (0, myst_common_1.toText)(nextNode.children);
// Add the title if it doesn't already exist

@@ -41,3 +41,3 @@ if (!frontmatter.title)

if (heading) {
frontmatter.title = (0, myst_utils_1.toText)(heading.children);
frontmatter.title = (0, myst_common_1.toText)(heading.children);
if (opts.removeHeading)

@@ -44,0 +44,0 @@ heading.type = '__delete__';

@@ -24,3 +24,3 @@ "use strict";

var rehype_remark_1 = __importDefault(require("rehype-remark"));
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
var defaultHtmlToMdastOptions = {

@@ -65,3 +65,3 @@ keepBreaks: true,

});
(0, myst_utils_1.liftChildren)(tree, 'htmlParsed');
(0, myst_common_1.liftChildren)(tree, 'htmlParsed');
(0, unist_util_select_1.selectAll)('_break', tree).forEach(function (node) {

@@ -68,0 +68,0 @@ node.type = 'break';

@@ -5,3 +5,3 @@ "use strict";

var unist_util_select_1 = require("unist-util-select");
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
function imageAltTextTransform(tree) {

@@ -21,3 +21,3 @@ var containers = (0, unist_util_select_1.selectAll)('container', tree);

return;
image.alt = (0, myst_utils_1.toText)(content);
image.alt = (0, myst_common_1.toText)(content);
});

@@ -24,0 +24,0 @@ }

@@ -5,7 +5,7 @@ "use strict";

var unist_util_map_1 = require("unist-util-map");
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
function addKeys(node) {
if (node.key)
return;
node.key = (0, myst_utils_1.createId)();
node.key = (0, myst_common_1.createId)();
return node;

@@ -12,0 +12,0 @@ }

"use strict";
exports.__esModule = true;
exports.DOITransformer = void 0;
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
var doi_utils_1 = require("doi-utils");

@@ -26,3 +26,3 @@ var utils_1 = require("./utils");

if (!doi || !(0, doi_utils_1.validate)(doi)) {
(0, myst_utils_1.fileError)(file, "DOI is not valid: ".concat(urlSource), {
(0, myst_common_1.fileError)(file, "DOI is not valid: ".concat(urlSource), {
node: link,

@@ -29,0 +29,0 @@ source: TRANSFORM_SOURCE

"use strict";
exports.__esModule = true;
exports.MystTransformer = void 0;
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
var utils_1 = require("./utils");

@@ -22,3 +22,3 @@ var TRANSFORM_SOURCE = 'LinkTransform:MystTransformer';

catch (err) {
(0, myst_utils_1.fileError)(file, "Could not parse url for \"".concat(urlSource, "\""), {
(0, myst_common_1.fileError)(file, "Could not parse url for \"".concat(urlSource, "\""), {
node: link,

@@ -30,3 +30,3 @@ source: TRANSFORM_SOURCE

if (!url.hash) {
(0, myst_utils_1.fileError)(file, "Must provide a target for \"".concat(urlSource, "\""), {
(0, myst_common_1.fileError)(file, "Must provide a target for \"".concat(urlSource, "\""), {
node: link,

@@ -46,3 +46,3 @@ note: 'Use the `#` symbol to create a target, for example, <myst:project#my-target>',

if (!lookup) {
(0, myst_utils_1.fileWarn)(file, "Unknown project \"".concat(url.pathname, "\" for link: ").concat(urlSource), {
(0, myst_common_1.fileWarn)(file, "Unknown project \"".concat(url.pathname, "\" for link: ").concat(urlSource), {
node: link,

@@ -56,3 +56,3 @@ source: TRANSFORM_SOURCE

if (!entry) {
(0, myst_utils_1.fileWarn)(file, "\"".concat(urlSource, "\" not found interspinx ").concat(lookup.id, " (").concat(lookup.path, ")"), {
(0, myst_common_1.fileWarn)(file, "\"".concat(urlSource, "\" not found interspinx ").concat(lookup.id, " (").concat(lookup.path, ")"), {
node: link,

@@ -59,0 +59,0 @@ source: TRANSFORM_SOURCE

"use strict";
exports.__esModule = true;
exports.RRIDTransformer = void 0;
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
var utils_1 = require("./utils");

@@ -36,3 +36,3 @@ var RESOLVER = 'https://scicrunch.org/resolver/';

if (!isValid(rrid)) {
(0, myst_utils_1.fileWarn)(file, "RRID is not valid: ".concat(urlSource), {
(0, myst_common_1.fileWarn)(file, "RRID is not valid: ".concat(urlSource), {
node: link,

@@ -39,0 +39,0 @@ source: TRANSFORM_SOURCE

"use strict";
exports.__esModule = true;
exports.WikiTransformer = void 0;
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
var utils_1 = require("./utils");

@@ -50,3 +50,3 @@ var DEFAULT_LANGUAGE = 'en';

if (!result) {
(0, myst_utils_1.fileWarn)(file, "Wikipedia pagenames should not contain spaces in link: ".concat(urlSource), {
(0, myst_common_1.fileWarn)(file, "Wikipedia pagenames should not contain spaces in link: ".concat(urlSource), {
node: link,

@@ -60,3 +60,3 @@ note: 'Replace spaces with underscores',

if (page.match(/\s/)) {
(0, myst_utils_1.fileWarn)(file, "Wikipedia pagenames should not contain spaces in link: ".concat(urlSource), {
(0, myst_common_1.fileWarn)(file, "Wikipedia pagenames should not contain spaces in link: ".concat(urlSource), {
node: link,

@@ -68,3 +68,3 @@ note: 'Replace spaces with underscores',

if (page.match(/\//)) {
(0, myst_utils_1.fileError)(file, "Wikipedia pagenames should not contain \"/\" in link: ".concat(urlSource), {
(0, myst_common_1.fileError)(file, "Wikipedia pagenames should not contain \"/\" in link: ".concat(urlSource), {
node: link,

@@ -71,0 +71,0 @@ note: 'Only point to the final page name, do not include any other parts of the Wikipedia URL.',

@@ -31,3 +31,3 @@ "use strict";

var unist_util_select_1 = require("unist-util-select");
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
var TRANSFORM_NAME = 'myst-transforms:math';

@@ -60,6 +60,6 @@ var replacements = {

var label = match[1];
var normalized = (0, myst_utils_1.normalizeLabel)(label);
var normalized = (0, myst_common_1.normalizeLabel)(label);
if (node.type === 'math' && normalized) {
if (node.enumerated === false) {
(0, myst_utils_1.fileWarn)(file, "Labelling an unnumbered math node with \"\\label{".concat(label, "}\""), {
(0, myst_common_1.fileWarn)(file, "Labelling an unnumbered math node with \"\\label{".concat(label, "}\""), {
node: node,

@@ -74,3 +74,3 @@ source: TRANSFORM_NAME

else if (node.type === 'inlineMath') {
(0, myst_utils_1.fileWarn)(file, "Cannot use \"\\label{".concat(label, "}\" in inline math"), {
(0, myst_common_1.fileWarn)(file, "Cannot use \"\\label{".concat(label, "}\" in inline math"), {
node: node,

@@ -93,3 +93,3 @@ source: TRANSFORM_NAME

if (node.type === 'inlineMath') {
(0, myst_utils_1.fileWarn)(file, "Unexpected AMS environment in inline math node.", {
(0, myst_common_1.fileWarn)(file, "Unexpected AMS environment in inline math node.", {
node: node,

@@ -105,3 +105,3 @@ note: value,

// Should never get to here as the parser should not accept mismatched ends
(0, myst_utils_1.fileWarn)(file, "Mismatching begin/end environment numbering", {
(0, myst_common_1.fileWarn)(file, "Mismatching begin/end environment numbering", {
node: node,

@@ -119,3 +119,3 @@ note: value,

return value;
(0, myst_utils_1.fileWarn)(file, 'Replacing \\begin{eqnarray} with \\begin{align*}', {
(0, myst_common_1.fileWarn)(file, 'Replacing \\begin{eqnarray} with \\begin{align*}', {
node: node,

@@ -157,3 +157,3 @@ note: 'Although the standard eqnarray environment is available in LaTeX, it is better to use align or equation+split instead. Within eqnarray, spacing around signs of relation is not the preferred mathematical spacing, and is inconsistent with that spacing as it appears in other environments.',

if (message.includes("Expected 'EOF', got '&' at position")) {
(0, myst_utils_1.fileWarn)(file, 'Wrapping with \\begin{align*}', {
(0, myst_common_1.fileWarn)(file, 'Wrapping with \\begin{align*}', {
node: node,

@@ -169,3 +169,3 @@ note: message,

if (message.includes('Unknown column alignment: *')) {
(0, myst_utils_1.fileWarn)(file, 'Alignment of "*" not supported, using "c"', {
(0, myst_common_1.fileWarn)(file, 'Alignment of "*" not supported, using "c"', {
node: node,

@@ -193,3 +193,3 @@ note: message,

var message = 'No input for math node';
(0, myst_utils_1.fileWarn)(file, message, {
(0, myst_common_1.fileWarn)(file, message, {
node: node,

@@ -212,7 +212,7 @@ note: node.value,

result.warnings.forEach(function (message) {
(0, myst_utils_1.fileWarn)(file, message, { node: node, note: node.value, source: 'KaTeX' });
(0, myst_common_1.fileWarn)(file, message, { node: node, note: node.value, source: 'KaTeX' });
});
}
if (result.error) {
(0, myst_utils_1.fileWarn)(file, result.error, { node: node, note: node.value, source: 'KaTeX', fatal: true });
(0, myst_common_1.fileWarn)(file, result.error, { node: node, note: node.value, source: 'KaTeX', fatal: true });
node.error = true;

@@ -219,0 +219,0 @@ node.message = result.error;

"use strict";
exports.__esModule = true;
exports.mystCleanupPlugin = exports.mystCleanupTransform = void 0;
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
function mystCleanupTransform(tree) {
(0, myst_utils_1.liftChildren)(tree, 'mystDirective');
(0, myst_utils_1.liftChildren)(tree, 'mystRole');
(0, myst_common_1.liftChildren)(tree, 'mystDirective');
(0, myst_common_1.liftChildren)(tree, 'mystRole');
}

@@ -9,0 +9,0 @@ exports.mystCleanupTransform = mystCleanupTransform;

@@ -8,3 +8,3 @@ "use strict";

var unist_util_select_1 = require("unist-util-select");
var myst_utils_1 = require("myst-utils");
var myst_common_1 = require("myst-common");
/**

@@ -27,3 +27,3 @@ * Propagate target identifier/value to subsequent node

var nextNode = (0, unist_util_find_after_1.findAfter)(parent, index);
var normalized = (0, myst_utils_1.normalizeLabel)(node.label);
var normalized = (0, myst_common_1.normalizeLabel)(node.label);
if (nextNode && normalized) {

@@ -47,3 +47,3 @@ nextNode.identifier = normalized.identifier;

return;
var normalized = (0, myst_utils_1.normalizeLabel)((0, myst_utils_1.toText)(node.children));
var normalized = (0, myst_common_1.normalizeLabel)((0, myst_common_1.toText)(node.children));
if (normalized) {

@@ -50,0 +50,0 @@ // For implicit header identifiers, use the html_id rather than the normalized label

@@ -11,3 +11,3 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {

import { select, selectAll } from 'unist-util-select';
import { fileError } from 'myst-utils';
import { fileError } from 'myst-common';
export function blockNestingTransform(mdast) {

@@ -14,0 +14,0 @@ if (!select('block', mdast)) {

import { selectAll } from 'unist-util-select';
import { fileWarn } from 'myst-utils';
import { fileWarn } from 'myst-common';
export function codeTransform(mdast, file, opts) {

@@ -4,0 +4,0 @@ var code = selectAll('code', mdast);

@@ -24,3 +24,3 @@ var __assign = (this && this.__assign) || function () {

import { findAndReplace } from 'mdast-util-find-and-replace';
import { createHtmlId, fileWarn, normalizeLabel, setTextAsChild, copyNode } from 'myst-utils';
import { createHtmlId, fileWarn, normalizeLabel, setTextAsChild, copyNode } from 'myst-common';
var TRANSFORM_NAME = 'myst-transforms:enumerate';

@@ -27,0 +27,0 @@ export var TargetKind;

import yaml from 'js-yaml';
import { select } from 'unist-util-select';
import { remove } from 'unist-util-remove';
import { toText } from 'myst-utils';
import { toText } from 'myst-common';
export function getFrontmatter(tree, opts) {

@@ -6,0 +6,0 @@ if (opts === void 0) { opts = { removeYaml: true, removeHeading: true }; }

@@ -18,3 +18,3 @@ var __assign = (this && this.__assign) || function () {

import rehypeRemark from 'rehype-remark';
import { liftChildren } from 'myst-utils';
import { liftChildren } from 'myst-common';
var defaultHtmlToMdastOptions = {

@@ -21,0 +21,0 @@ keepBreaks: true,

import { select, selectAll } from 'unist-util-select';
import { toText } from 'myst-utils';
import { toText } from 'myst-common';
export function imageAltTextTransform(tree) {

@@ -4,0 +4,0 @@ var containers = selectAll('container', tree);

import { map } from 'unist-util-map';
import { createId } from 'myst-utils';
import { createId } from 'myst-common';
function addKeys(node) {

@@ -4,0 +4,0 @@ if (node.key)

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

import { fileError } from 'myst-utils';
import { fileError } from 'myst-common';
import { validate, normalize } from 'doi-utils';

@@ -3,0 +3,0 @@ import { updateLinkTextIfEmpty } from './utils';

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

import { fileWarn, fileError } from 'myst-utils';
import { fileWarn, fileError } from 'myst-common';
import { updateLinkTextIfEmpty } from './utils';

@@ -3,0 +3,0 @@ var TRANSFORM_SOURCE = 'LinkTransform:MystTransformer';

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

import { fileWarn } from 'myst-utils';
import { fileWarn } from 'myst-common';
import { updateLinkTextIfEmpty, withoutHttp } from './utils';

@@ -3,0 +3,0 @@ var RESOLVER = 'https://scicrunch.org/resolver/';

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

import { fileError, fileWarn } from 'myst-utils';
import { fileError, fileWarn } from 'myst-common';
import { updateLinkTextIfEmpty, withoutHttp } from './utils';

@@ -3,0 +3,0 @@ var DEFAULT_LANGUAGE = 'en';

@@ -25,3 +25,3 @@ var __assign = (this && this.__assign) || function () {

import { selectAll } from 'unist-util-select';
import { fileWarn, normalizeLabel } from 'myst-utils';
import { fileWarn, normalizeLabel } from 'myst-common';
var TRANSFORM_NAME = 'myst-transforms:math';

@@ -28,0 +28,0 @@ var replacements = {

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

import { liftChildren } from 'myst-utils';
import { liftChildren } from 'myst-common';
export function mystCleanupTransform(tree) {

@@ -3,0 +3,0 @@ liftChildren(tree, 'mystDirective');

@@ -5,3 +5,3 @@ import { findAfter } from 'unist-util-find-after';

import { selectAll } from 'unist-util-select';
import { normalizeLabel, toText } from 'myst-utils';
import { normalizeLabel, toText } from 'myst-common';
/**

@@ -8,0 +8,0 @@ * Propagate target identifier/value to subsequent node

{
"name": "myst-transforms",
"version": "0.0.4",
"version": "0.0.5",
"main": "./dist/cjs/index.js",

@@ -34,3 +34,3 @@ "module": "./dist/esm/index.js",

"myst-spec": "^0.0.4",
"myst-utils": "*",
"myst-common": "*",
"unified": "^10.0.0",

@@ -37,0 +37,0 @@ "unist-util-select": "^4.0.1",

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