🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

myst-frontmatter

Package Overview
Dependencies
Maintainers
0
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

myst-frontmatter - npm Package Compare versions

Comparing version

to
1.7.7

4

dist/numbering/types.d.ts
export type NumberingItem = {
enabled?: boolean;
start?: number;
enumerator?: string;
template?: string;
continue?: boolean;
offset?: number;
};

@@ -9,2 +12,3 @@ export type Numbering = {

all?: NumberingItem;
title?: NumberingItem;
figure?: NumberingItem;

@@ -11,0 +15,0 @@ subfigure?: NumberingItem;

@@ -19,2 +19,8 @@ import type { ValidationOptions } from 'simple-validators';

heading6: string;
figures: string;
subfigures: string;
equations: string;
subequations: string;
tables: string;
titles: string;
};

@@ -33,2 +39,3 @@ /**

export declare function validateNumberingItem(input: any, opts: ValidationOptions): NumberingItem | undefined;
export declare function validateTitleItem(input: any, opts: ValidationOptions): NumberingItem | undefined;
/**

@@ -35,0 +42,0 @@ * Validate Numbering object

import { defined, fillMissingKeys, incrementOptions, validateBoolean, validateNumber, validateObjectKeys, validateString, validationWarning, } from 'simple-validators';
export const NUMBERING_OPTIONS = ['enumerator', 'all', 'headings'];
export const NUMBERING_OPTIONS = ['enumerator', 'all', 'headings', 'title'];
const HEADING_KEYS = ['heading_1', 'heading_2', 'heading_3', 'heading_4', 'heading_5', 'heading_6'];

@@ -13,3 +13,4 @@ export const NUMBERING_KEYS = [

];
const NUMBERING_ITEM_KEYS = ['enabled', 'start', 'template'];
const NUMBERING_ITEM_KEYS = ['enabled', 'start', 'enumerator', 'template', 'continue'];
const CONTINUE_STRINGS = ['continue', 'next'];
export const NUMBERING_ALIAS = {

@@ -29,2 +30,8 @@ sections: 'headings',

heading6: 'heading_6',
figures: 'figure',
subfigures: 'subfigure',
equations: 'equation',
subequations: 'subequation',
tables: 'table',
titles: 'title',
};

@@ -49,3 +56,3 @@ function isBoolean(input) {

export function validateNumberingItem(input, opts) {
var _a, _b;
var _a, _b, _c, _d, _e;
if (isBoolean(input)) {

@@ -57,2 +64,5 @@ input = { enabled: input };

}
else if (CONTINUE_STRINGS.includes(input)) {
input = { continue: true };
}
else if (typeof input === 'string') {

@@ -71,11 +81,17 @@ input = { template: input };

if (defined(value.start)) {
const start = validateNumber(value.start, {
...incrementOptions('start', opts),
integer: true,
min: 1,
});
if (start) {
output.start = start;
if (CONTINUE_STRINGS.includes(value.start) && !defined(value.continue)) {
output.continue = true;
output.enabled = (_a = output.enabled) !== null && _a !== void 0 ? _a : true;
}
else {
const start = validateNumber(value.start, {
...incrementOptions('start', opts),
integer: true,
min: 1,
});
if (start) {
output.start = start;
output.enabled = (_b = output.enabled) !== null && _b !== void 0 ? _b : true;
}
}
}

@@ -86,2 +102,56 @@ if (defined(value.template)) {

output.template = template;
output.enabled = (_c = output.enabled) !== null && _c !== void 0 ? _c : true;
}
}
if (defined(value.enumerator)) {
const enumerator = validateString(value.enumerator, incrementOptions('enumerator', opts));
if (defined(enumerator)) {
output.enumerator = enumerator;
output.enabled = (_d = output.enabled) !== null && _d !== void 0 ? _d : true;
}
}
if (defined(value.continue)) {
const cont = validateBoolean(value.continue, incrementOptions('continue', opts));
if (defined(cont)) {
output.continue = cont;
output.enabled = (_e = output.enabled) !== null && _e !== void 0 ? _e : true;
}
}
if (Object.keys(output).length === 0)
return undefined;
return output;
}
export function validateTitleItem(input, opts) {
var _a, _b;
if (isBoolean(input)) {
input = { enabled: input };
}
else if (typeof input === 'number') {
input = { offset: input };
}
const value = validateObjectKeys(input, { optional: ['enabled', 'offset', 'enumerator'] }, opts);
if (value === undefined)
return undefined;
const output = {};
if (defined(value.enabled)) {
const enabled = validateBoolean(value.enabled, incrementOptions('enabled', opts));
if (defined(enabled))
output.enabled = enabled;
}
if (defined(value.offset)) {
const offset = validateNumber(value.offset, {
integer: true,
min: 0,
max: 5,
...incrementOptions('offset', opts),
});
if (defined(offset)) {
output.offset = offset;
output.enabled = (_a = output.enabled) !== null && _a !== void 0 ? _a : true;
}
}
if (defined(value.enumerator)) {
const enumerator = validateString(value.enumerator, incrementOptions('enumerator', opts));
if (defined(enumerator)) {
output.enumerator = enumerator;
output.enabled = (_b = output.enabled) !== null && _b !== void 0 ? _b : true;

@@ -98,3 +168,3 @@ }

export function validateNumbering(input, opts) {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e;
if (isBoolean(input)) {

@@ -110,2 +180,5 @@ input = { all: input };

const enumeratorOpts = incrementOptions('enumerator', opts);
if (typeof value.enumerator === 'string') {
value.enumerator = { enumerator: value.enumerator };
}
output.enumerator = validateNumberingItem(value.enumerator, enumeratorOpts);

@@ -122,2 +195,9 @@ if (((_a = output.enumerator) === null || _a === void 0 ? void 0 : _a.enabled) != null) {

}
if (((_c = output.enumerator) === null || _c === void 0 ? void 0 : _c.continue) != null) {
validationWarning("value for 'continue' is ignored", enumeratorOpts);
delete output.enumerator.continue;
}
if (!output.enumerator || Object.keys(output.enumerator).length === 0) {
delete output.enumerator;
}
}

@@ -127,11 +207,17 @@ if (defined(value.all)) {

output.all = validateNumberingItem(value.all, allOpts);
if (((_c = output.all) === null || _c === void 0 ? void 0 : _c.template) != null) {
if (((_d = output.all) === null || _d === void 0 ? void 0 : _d.template) != null) {
validationWarning("value for 'template' is ignored", allOpts);
delete output.all.template;
}
if (((_d = output.all) === null || _d === void 0 ? void 0 : _d.start) != null) {
if (((_e = output.all) === null || _e === void 0 ? void 0 : _e.start) != null) {
validationWarning("value for 'start' is ignored", allOpts);
delete output.all.start;
}
if (!output.all || Object.keys(output.all).length === 0) {
delete output.all;
}
}
if (defined(value.title)) {
output.title = validateTitleItem(value.title, incrementOptions('title', opts));
}
if (defined(value.headings)) {

@@ -169,8 +255,12 @@ headings = validateNumberingItem(value.headings, incrementOptions('headings', opts));

.forEach(([key, val]) => {
var _a, _b, _c;
var _a, _b, _c, _d, _e;
output[key] = fillMissingKeys((_a = base === null || base === void 0 ? void 0 : base[key]) !== null && _a !== void 0 ? _a : {},
// Enabling/disabling all in base overrides filler
{ ...val, enabled: (_c = (_b = base === null || base === void 0 ? void 0 : base.all) === null || _b === void 0 ? void 0 : _b.enabled) !== null && _c !== void 0 ? _c : val.enabled }, NUMBERING_ITEM_KEYS);
{
...val,
enabled: (_c = (_b = base === null || base === void 0 ? void 0 : base.all) === null || _b === void 0 ? void 0 : _b.enabled) !== null && _c !== void 0 ? _c : val.enabled,
continue: (_e = (_d = base === null || base === void 0 ? void 0 : base.all) === null || _d === void 0 ? void 0 : _d.continue) !== null && _e !== void 0 ? _e : val.continue,
}, NUMBERING_ITEM_KEYS);
});
return output;
}

@@ -10,2 +10,3 @@ import type { Jupytext } from '../jupytext/types.js';

tags?: string[];
enumerator?: string;
/** Flag if frontmatter title is duplicated in content

@@ -12,0 +13,0 @@ *

3

dist/page/types.js

@@ -9,4 +9,5 @@ import { PROJECT_AND_PAGE_FRONTMATTER_KEYS } from '../project/types.js';

'tags',
'site',
'enumerator',
'content_includes_title',
'site',
];

@@ -44,2 +44,5 @@ import { defined, incrementOptions, validateObjectKeys, validateString, validateBoolean, validateObject, } from 'simple-validators';

}
if (defined(value.enumerator)) {
output.enumerator = validateString(value.enumerator, incrementOptions('enumerator', opts));
}
if (defined(value.content_includes_title)) {

@@ -46,0 +49,0 @@ output.content_includes_title = validateBoolean(value.content_includes_title, incrementOptions('content_includes_title', opts));

@@ -38,2 +38,3 @@ import type { PublicationMeta } from '../biblio/types.js';

settings?: ProjectSettings;
edit_url?: string | null;
};

@@ -40,0 +41,0 @@ export type ProjectFrontmatter = ProjectAndPageFrontmatter & {

@@ -24,2 +24,3 @@ import { SITE_FRONTMATTER_KEYS } from '../site/types.js';

'settings', // We maybe want to move this into site frontmatter in the future
'edit_url',
...KNOWN_EXTERNAL_IDENTIFIERS,

@@ -26,0 +27,0 @@ // Do not add any project specific keys here!

@@ -207,2 +207,8 @@ import { defined, incrementOptions, validateBoolean, validateDate, validateList, validateNumber, validateObject, validateObjectKeys, validateString, validateUrl, validationError, validationWarning, } from 'simple-validators';

}
if (value.edit_url === null) {
output.edit_url = null;
}
else if (defined(value.edit_url)) {
output.edit_url = validateUrl(value.edit_url, incrementOptions('edit_url', opts));
}
return output;

@@ -209,0 +215,0 @@ }

{
"name": "myst-frontmatter",
"version": "1.7.6",
"version": "1.7.7",
"sideEffects": false,

@@ -36,3 +36,3 @@ "license": "MIT",

"credit-roles": "^2.1.0",
"doi-utils": "^2.0.0",
"doi-utils": "^2.0.4",
"orcid": "^1.0.0",

@@ -39,0 +39,0 @@ "simple-validators": "^1.1.0",

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

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