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

@markuplint/parser-utils

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@markuplint/parser-utils - npm Package Compare versions

Comparing version 4.5.0 to 4.5.1

4

lib/attr-tokenizer.js

@@ -26,2 +26,3 @@ import { defaultSpaces } from './const.js';

let valueType = noQuoteValueType;
let parser;
let quoteEnd = '';

@@ -109,2 +110,3 @@ const isBeforeValueStarted = startState === AttrState.BeforeValue;

valueType = quote.type;
parser = quote.parser;
state = AttrState.Value;

@@ -130,3 +132,3 @@ break;

const raw = char + chars.join('');
const { validScript } = safeScriptParser(raw);
const { validScript } = safeScriptParser(raw, parser);
attrValue += validScript;

@@ -133,0 +135,0 @@ chars.splice(0, validScript.length - 1);

@@ -0,3 +1,4 @@

import type { CustomParser } from './types.js';
export declare function scriptParser(script: string): ScriptTokenType[];
export declare function safeScriptParser(script: string): {
export declare function safeScriptParser(script: string, parse?: CustomParser): {
validScript: string;

@@ -4,0 +5,0 @@ leftover: string;

@@ -13,8 +13,8 @@ // @ts-ignore

}
export function safeScriptParser(script) {
let { validScript, leftover } = safeParse(script);
export function safeScriptParser(script, parse = defaultParse) {
let { validScript, leftover } = safeParse(script, parse);
// Support for object literal
if (leftover.trim()) {
const assignment = '$=';
({ validScript } = safeParse(`${assignment}${script}`));
({ validScript } = safeParse(`${assignment}${script}`, parse));
validScript = validScript.length > assignment.length ? validScript.slice(assignment.length) : '';

@@ -26,3 +26,3 @@ }

const coverEnd = '}';
({ validScript } = safeParse(`${coverStart}${script}${coverEnd}`));
({ validScript } = safeParse(`${coverStart}${script}${coverEnd}`, parse));
const coverEndLastIndex = validScript.lastIndexOf(coverEnd);

@@ -40,12 +40,7 @@ validScript =

}
function safeParse(script) {
function safeParse(script, parse) {
let validScript;
let leftover;
try {
parse(script, {
ecmaVersion: 'latest',
ecmaFeatures: {
jsx: true,
},
});
parse(script);
validScript = script;

@@ -73,1 +68,9 @@ leftover = '';

}
function defaultParse(script) {
parse(script, {
ecmaVersion: 'latest',
ecmaFeatures: {
jsx: true,
},
});
}

@@ -57,3 +57,5 @@ import type { EndTagType, MLASTParentNode, ParserOptions as ConfigParserOptions } from '@markuplint/ml-ast';

readonly type: ValueType;
readonly parser?: CustomParser;
};
export type CustomParser = (code: string) => void;
export type ValueType = 'string' | 'script';
{
"name": "@markuplint/parser-utils",
"version": "4.5.0",
"version": "4.5.1",
"description": "Utility module for markuplint parser plugin",

@@ -31,3 +31,3 @@ "repository": "git@github.com:markuplint/markuplint.git",

"@markuplint/ml-ast": "4.2.0",
"@markuplint/ml-spec": "4.4.0",
"@markuplint/ml-spec": "4.4.1",
"@markuplint/types": "4.3.0",

@@ -40,3 +40,6 @@ "@types/uuid": "9.0.8",

},
"gitHead": "d5c8786b0dbbd82cdd89018dd57941d62bbe8d06"
"devDependencies": {
"@typescript-eslint/typescript-estree": "7.7.0"
},
"gitHead": "b029c86a6b3a9ea8189d2e5535e3023aaea753fd"
}
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