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 1.6.3 to 2.0.0-dev.23

lib/create-token.d.ts

6

lib/const.d.ts
export declare const MASK_CHAR = "\uE000";
export declare const rePCEN: RegExp;
/**
* SVG Element list
*
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element
*/
export declare const svgElementList: string[];

97

lib/const.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.rePCEN = exports.MASK_CHAR = void 0;
exports.svgElementList = exports.rePCEN = exports.MASK_CHAR = void 0;
exports.MASK_CHAR = '\uE000';

@@ -41,1 +41,96 @@ /**

exports.rePCEN = new RegExp(`^[a-z](?:${rePCENChar})*\\-(?:${rePCENChar})*$`, 'i');
/**
* SVG Element list
*
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element
*/
exports.svgElementList = [
'a',
'animate',
'animateMotion',
'animateTransform',
'circle',
'clipPath',
'defs',
'desc',
'discard',
'ellipse',
'feBlend',
'feColorMatrix',
'feComponentTransfer',
'feComposite',
'feConvolveMatrix',
'feDiffuseLighting',
'feDisplacementMap',
'feDistantLight',
'feDropShadow',
'feFlood',
'feFuncA',
'feFuncB',
'feFuncG',
'feFuncR',
'feGaussianBlur',
'feImage',
'feMerge',
'feMergeNode',
'feMorphology',
'feOffset',
'fePointLight',
'feSpecularLighting',
'feSpotLight',
'feTile',
'feTurbulence',
'filter',
'foreignObject',
'g',
'hatch',
'hatchpath',
'image',
'line',
'linearGradient',
'marker',
'mask',
'mesh',
'meshgradient',
'meshpatch',
'meshrow',
'metadata',
'mpath',
'path',
'pattern',
'polygon',
'polyline',
'radialGradient',
'rect',
'script',
'set',
'stop',
'style',
'svg',
'switch',
'symbol',
'text',
'textPath',
'title',
'tspan',
'use',
'view',
// Below: Obsolete and deprecated elements
'altGlyph',
'altGlyphDef',
'altGlyphItem',
'animateColor',
'cursor',
'font',
'font-face',
'font-face-format',
'font-face-name',
'font-face-src',
'font-face-uri',
'glyph',
'glyphRef',
'hkern',
'missing-glyph',
'tref',
'vkern',
];

4

lib/ignore-block.d.ts

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

import { IgnoreBlock, IgnoreTag } from './types';
import { MLASTNode } from '@markuplint/ml-ast';
import type { IgnoreBlock, IgnoreTag } from './types';
import type { MLASTNode } from '@markuplint/ml-ast';
export declare function ignoreBlock(source: string, tags: IgnoreTag[]): IgnoreBlock;
export declare function restoreNode(nodeList: MLASTNode[], ignoreBlock: IgnoreBlock): MLASTNode[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.restoreNode = exports.ignoreBlock = void 0;
const ml_ast_1 = require("@markuplint/ml-ast");
const utils_1 = require("./utils");
const const_1 = require("./const");
const create_token_1 = require("./create-token");
const get_location_1 = require("./get-location");
const siblings_correction_1 = require("./siblings-correction");
function ignoreBlock(source, tags) {

@@ -19,3 +20,3 @@ let replaced = source;

replaced = attr.replaced;
stack.push(...attr.stack.map(res => (Object.assign(Object.assign({}, res), { type: tag.type }))));
stack.push(...attr.stack.map(res => ({ ...res, type: tag.type })));
// Replace tags in other nodes

@@ -30,3 +31,3 @@ const text = maskText(tag.start, tag.end, replaced, (startTag, taggedCode, endTag) => {

replaced = text.replaced;
stack.push(...text.stack.map(res => (Object.assign(Object.assign({}, res), { type: tag.type }))));
stack.push(...text.stack.map(res => ({ ...res, type: tag.type })));
}

@@ -71,3 +72,3 @@ stack.sort((a, b) => a.index - b.index);

for (const node of nodeList) {
if (node.type === ml_ast_1.MLASTNodeType.Comment || node.type === ml_ast_1.MLASTNodeType.Text) {
if (node.type === 'comment' || node.type === 'text') {
if (!hasIgnoreBlock(node.raw)) {

@@ -89,4 +90,8 @@ continue;

const offset = node.startOffset + pointer;
const { raw, startOffset, endOffset, startLine, endLine, startCol, endCol } = utils_1.sliceFragment(source, offset, offset + above.length);
const textNode = Object.assign(Object.assign({}, node), { uuid: utils_1.uuid(), type: ml_ast_1.MLASTNodeType.Text, raw,
const { raw, startOffset, endOffset, startLine, endLine, startCol, endCol } = (0, get_location_1.sliceFragment)(source, offset, offset + above.length);
const textNode = {
...node,
uuid: (0, create_token_1.uuid)(),
type: 'text',
raw,
startOffset,

@@ -97,3 +102,4 @@ endOffset,

startCol,
endCol });
endCol,
};
insertList.push(textNode);

@@ -103,6 +109,6 @@ }

const offset = node.startOffset + pointer + above.length;
const { raw, startOffset, endOffset, startLine, endLine, startCol, endCol } = utils_1.sliceFragment(source, offset, offset + body.length);
const { raw, startOffset, endOffset, startLine, endLine, startCol, endCol } = (0, get_location_1.sliceFragment)(source, offset, offset + body.length);
const bodyNode = {
uuid: utils_1.uuid(),
type: ml_ast_1.MLASTNodeType.PreprocessorSpecificBlock,
uuid: (0, create_token_1.uuid)(),
type: 'psblock',
nodeName: `#ps:${tag.type}`,

@@ -130,4 +136,8 @@ raw,

const offset = node.endOffset - text.length;
const { raw, startOffset, endOffset, startLine, endLine, startCol, endCol } = utils_1.sliceFragment(source, offset, offset + text.length);
const textNode = Object.assign(Object.assign({}, node), { uuid: utils_1.uuid(), type: ml_ast_1.MLASTNodeType.Text, raw,
const { raw, startOffset, endOffset, startLine, endLine, startCol, endCol } = (0, get_location_1.sliceFragment)(source, offset, offset + text.length);
const textNode = {
...node,
uuid: (0, create_token_1.uuid)(),
type: 'text',
raw,
startOffset,

@@ -138,6 +148,7 @@ endOffset,

startCol,
endCol });
endCol,
};
insertList.push(textNode);
}
utils_1.siblingsCorrection(insertList);
(0, siblings_correction_1.siblingsCorrection)(insertList);
if (parentNode) {

@@ -148,3 +159,3 @@ parentNode.childNodes = insertList;

}
if (node.type === ml_ast_1.MLASTNodeType.StartTag) {
if (node.type === 'starttag') {
for (const attr of node.attributes) {

@@ -151,0 +162,0 @@ if (attr.type === 'ps-attr' || attr.value.raw === '' || !hasIgnoreBlock(attr.value.raw)) {

@@ -0,3 +1,8 @@

export * from './decision';
export * from './get-location';
export * from './create-token';
export * from './idl-attributes';
export * from './walker';
export * from './ignore-block';
export * from './utils';
export declare function ignoreFrontMatter(code: string): string;
export * from './ignore-front-matter';
export * from './debugger';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ignoreFrontMatter = void 0;
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./ignore-block"), exports);
tslib_1.__exportStar(require("./utils"), exports);
function ignoreFrontMatter(code) {
const reStart = /^(?:\s*\r?\n)?---\r?\n/.exec(code);
if (!reStart) {
return code;
}
const startPoint = reStart[0].length;
const afterStart = code.slice(startPoint);
const reEnd = /\r?\n---\r?\n/.exec(afterStart);
if (!reEnd) {
return code;
}
const endPoint = startPoint + reEnd.index + reEnd[0].length;
const frontMatter = code.slice(0, endPoint);
const afterCode = code.slice(endPoint);
const masked = frontMatter.replace(/[^\r\n]/g, ' ');
return masked + afterCode;
}
exports.ignoreFrontMatter = ignoreFrontMatter;
(0, tslib_1.__exportStar)(require("./decision"), exports);
(0, tslib_1.__exportStar)(require("./get-location"), exports);
(0, tslib_1.__exportStar)(require("./create-token"), exports);
(0, tslib_1.__exportStar)(require("./idl-attributes"), exports);
(0, tslib_1.__exportStar)(require("./walker"), exports);
(0, tslib_1.__exportStar)(require("./ignore-block"), exports);
(0, tslib_1.__exportStar)(require("./ignore-front-matter"), exports);
(0, tslib_1.__exportStar)(require("./debugger"), exports);
{
"name": "@markuplint/parser-utils",
"version": "1.6.3",
"version": "2.0.0-dev.23+6a10aede",
"description": "Utility module for markuplint parser plugin",

@@ -22,7 +22,7 @@ "repository": "git@github.com:markuplint/markuplint.git",

"dependencies": {
"@markuplint/ml-ast": "^1.6.0",
"tslib": "^2.3.0",
"@markuplint/ml-ast": "^2.0.0-dev.36+6a10aede",
"tslib": "^2.3.1",
"uuid": "^8.3.2"
},
"gitHead": "4c08a8374af02f4edc8846c48fc48066248ce1f3"
"gitHead": "6a10aede7385e2e97d0ba2c272a2e8c08e5429fd"
}
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"composite": true
},
"references": [
{
"path": "../html-parser"
},
{
"path": "../ml-ast"
}
],
"include": ["./src/**/*"],
"exclude": ["node_modules"]
"extends": "../../../tsconfig.json"
}

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