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

@markuplint/html-parser

Package Overview
Dependencies
Maintainers
1
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@markuplint/html-parser - npm Package Compare versions

Comparing version 3.4.0 to 3.5.0

8

lib/create-tree.d.ts
import type { MLASTNode } from '@markuplint/ml-ast';
export declare function createTree(
rawCode: string,
isFragment: boolean,
offsetOffset: number,
offsetLine: number,
offsetColumn: number,
): MLASTNode[];
export declare function createTree(rawCode: string, isFragment: boolean, offsetOffset: number, offsetLine: number, offsetColumn: number): MLASTNode[];

14

lib/create-tree.js

@@ -13,9 +13,9 @@ "use strict";

function createTree(rawCode, isFragment, offsetOffset, offsetLine, offsetColumn) {
const doc = isFragment
? (0, parse5_1.parseFragment)(rawCode, P5_OPTIONS)
: (0, parse5_1.parse)(rawCode, P5_OPTIONS);
const doc = isFragment ? (0, parse5_1.parseFragment)(rawCode, P5_OPTIONS) : (0, parse5_1.parse)(rawCode, P5_OPTIONS);
return createTreeRecursive(doc, null, rawCode, offsetOffset, offsetLine, offsetColumn);
}
exports.createTree = createTree;
function createTreeRecursive(rootNode, parentNode, rawHtml, offsetOffset, offsetLine, offsetColumn) {
function createTreeRecursive(rootNode,
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
parentNode, rawHtml, offsetOffset, offsetLine, offsetColumn) {
const nodeList = [];

@@ -40,3 +40,7 @@ const childNodes = getChildNodes(rootNode);

}
function nodeize(originNode, prevNode, parentNode, rawHtml, offsetOffset, offsetLine, offsetColumn) {
function nodeize(originNode,
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
prevNode,
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
parentNode, rawHtml, offsetOffset, offsetLine, offsetColumn) {
const nextNode = null;

@@ -43,0 +47,0 @@ const location = getLocation(originNode);

@@ -0,7 +1,6 @@

export { default as attrTokenizer } from './attr-tokenizer';
export { default as isDocumentFragment } from './is-document-fragment';
export { default as parseRawTag } from './parse-raw-tag';
export { getNamespace } from './get-namespace';
export { parse } from './parse';
export { flattenNodes } from './flatten-nodes';
export { removeDeprecatedNode } from './remove-deprecated-node';
export { getNamespace } from './get-namespace';
export { default as parseRawTag } from './parse-raw-tag';
export { default as attrTokenizer } from './attr-tokenizer';
export { createTree } from './create-tree';

@@ -6,16 +6,14 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.attrTokenizer = exports.parseRawTag = exports.getNamespace = exports.removeDeprecatedNode = exports.flattenNodes = exports.parse = exports.isDocumentFragment = void 0;
exports.createTree = exports.parse = exports.getNamespace = exports.parseRawTag = exports.isDocumentFragment = exports.attrTokenizer = void 0;
var attr_tokenizer_1 = require("./attr-tokenizer");
Object.defineProperty(exports, "attrTokenizer", { enumerable: true, get: function () { return __importDefault(attr_tokenizer_1).default; } });
var is_document_fragment_1 = require("./is-document-fragment");
Object.defineProperty(exports, "isDocumentFragment", { enumerable: true, get: function () { return __importDefault(is_document_fragment_1).default; } });
var parse_raw_tag_1 = require("./parse-raw-tag");
Object.defineProperty(exports, "parseRawTag", { enumerable: true, get: function () { return __importDefault(parse_raw_tag_1).default; } });
var get_namespace_1 = require("./get-namespace");
Object.defineProperty(exports, "getNamespace", { enumerable: true, get: function () { return get_namespace_1.getNamespace; } });
var parse_1 = require("./parse");
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_1.parse; } });
var flatten_nodes_1 = require("./flatten-nodes");
Object.defineProperty(exports, "flattenNodes", { enumerable: true, get: function () { return flatten_nodes_1.flattenNodes; } });
var remove_deprecated_node_1 = require("./remove-deprecated-node");
Object.defineProperty(exports, "removeDeprecatedNode", { enumerable: true, get: function () { return remove_deprecated_node_1.removeDeprecatedNode; } });
var get_namespace_1 = require("./get-namespace");
Object.defineProperty(exports, "getNamespace", { enumerable: true, get: function () { return get_namespace_1.getNamespace; } });
var parse_raw_tag_1 = require("./parse-raw-tag");
Object.defineProperty(exports, "parseRawTag", { enumerable: true, get: function () { return __importDefault(parse_raw_tag_1).default; } });
var attr_tokenizer_1 = require("./attr-tokenizer");
Object.defineProperty(exports, "attrTokenizer", { enumerable: true, get: function () { return __importDefault(attr_tokenizer_1).default; } });
var create_tree_1 = require("./create-tree");
Object.defineProperty(exports, "createTree", { enumerable: true, get: function () { return create_tree_1.createTree; } });
import type { MLASTNode } from '@markuplint/ml-ast';
export declare function isStartsHeadTagOrBodyTag(rawCode: string): boolean;
export declare function optimizeStartsHeadTagOrBodyTagSetup(rawCode: string): {
code: string;
heads: string[];
bodies: string[];
code: string;
heads: string[];
bodies: string[];
};
export declare function optimizeStartsHeadTagOrBodyTagResume(
nodeList: MLASTNode[],
replacements: ReturnType<typeof optimizeStartsHeadTagOrBodyTagSetup>,
): void;
export declare function optimizeStartsHeadTagOrBodyTagResume(nodeList: MLASTNode[], replacements: ReturnType<typeof optimizeStartsHeadTagOrBodyTagSetup>): void;

@@ -37,3 +37,7 @@ "use strict";

exports.optimizeStartsHeadTagOrBodyTagSetup = optimizeStartsHeadTagOrBodyTagSetup;
function optimizeStartsHeadTagOrBodyTagResume(nodeList, replacements) {
function optimizeStartsHeadTagOrBodyTagResume(
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
nodeList,
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
replacements) {
nodeList.forEach(node => {

@@ -40,0 +44,0 @@ if (!node.nodeName.startsWith(`x-${UNDUPLICATED_CHAR}`)) {

import type { MLASTAttr, MLToken } from '@markuplint/ml-ast';
type TagTokens = {
tagName: string;
attrs: MLASTAttr[];
selfClosingSolidus: MLToken;
endSpace: MLToken;
tagName: string;
attrs: MLASTAttr[];
selfClosingSolidus: MLToken;
endSpace: MLToken;
};
export default function parseRawTag(
raw: string,
startLine: number,
startCol: number,
startOffset: number,
offsetOffset?: number,
offsetLine?: number,
offsetColumn?: number,
): TagTokens;
export default function parseRawTag(raw: string, startLine: number, startCol: number, startOffset: number, offsetOffset?: number, offsetLine?: number, offsetColumn?: number): TagTokens;
export {};

@@ -6,3 +6,2 @@ "use strict";

const attr_tokenizer_1 = tslib_1.__importDefault(require("./attr-tokenizer"));
const const_1 = require("./const");
// eslint-disable-next-line no-control-regex

@@ -16,3 +15,3 @@ const reAttrsInStartTag = /\s*[^\x00-\x1f\x7f-\x9f "'>/=]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^\s]*))?/;

let col = startCol + (startLine === 1 ? offsetColumn : 0);
const matches = raw.match(const_1.reTag);
const matches = raw.match(parser_utils_1.reTag);
const tagWithAttrs = matches === null || matches === void 0 ? void 0 : matches[1];

@@ -25,3 +24,3 @@ if (!tagWithAttrs) {

const tagName = tagNameSplitted[0] || tagNameSplitted[1];
if (!tagName || (!const_1.reTagName.test(tagName) && !(0, parser_utils_1.isPotentialCustomElementName)(tagName))) {
if (!tagName || (!parser_utils_1.reTagName.test(tagName) && !(0, parser_utils_1.isPotentialCustomElementName)(tagName))) {
throw new SyntaxError(`Invalid tag name: "${tagName}" in <${tagWithAttrs}>`);

@@ -28,0 +27,0 @@ }

@@ -7,3 +7,2 @@ "use strict";

const create_tree_1 = require("./create-tree");
const flatten_nodes_1 = require("./flatten-nodes");
const is_document_fragment_1 = tslib_1.__importDefault(require("./is-document-fragment"));

@@ -22,3 +21,3 @@ const optimize_starts_head_or_body_1 = require("./optimize-starts-head-or-body");

const nodeTree = (0, create_tree_1.createTree)(rawCode, isFragment, (_a = options === null || options === void 0 ? void 0 : options.offsetOffset) !== null && _a !== void 0 ? _a : 0, (_b = options === null || options === void 0 ? void 0 : options.offsetLine) !== null && _b !== void 0 ? _b : 0, (_c = options === null || options === void 0 ? void 0 : options.offsetColumn) !== null && _c !== void 0 ? _c : 0);
const nodeList = (0, flatten_nodes_1.flattenNodes)(nodeTree, rawCode);
const nodeList = (0, parser_utils_1.flattenNodes)(nodeTree, rawCode);
if (data) {

@@ -25,0 +24,0 @@ (0, optimize_starts_head_or_body_1.optimizeStartsHeadTagOrBodyTagResume)(nodeList, data);

{
"name": "@markuplint/html-parser",
"version": "3.4.0",
"version": "3.5.0",
"description": "HTML parser for markuplint",

@@ -23,8 +23,11 @@ "repository": "git@github.com:markuplint/markuplint.git",

"dependencies": {
"@markuplint/ml-ast": "3.0.0",
"@markuplint/parser-utils": "3.4.0",
"@markuplint/ml-ast": "3.1.0",
"@markuplint/parser-utils": "3.5.0",
"parse5": "7.1.2",
"tslib": "^2.4.1"
},
"gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
"devDependencies": {
"type-fest": "^3.7.0"
},
"gitHead": "0c47b2c2722f6823a17f36edbab98486275f8ab4"
}
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