@markuplint/html-parser
Advanced tools
Comparing version 3.5.0 to 3.6.0
@@ -8,3 +8,3 @@ "use strict"; | ||
function attrTokenizer(raw, line, col, startOffset) { | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
const attrMatchedMap = raw.match(reAttrsInStartTag); | ||
@@ -17,6 +17,6 @@ if (!attrMatchedMap) { | ||
const spacesBeforeEqualChars = (_c = attrMatchedMap[3]) !== null && _c !== void 0 ? _c : ''; | ||
const equalChars = attrMatchedMap[4] || null; | ||
const spacesAfterEqualChars = (_d = attrMatchedMap[5]) !== null && _d !== void 0 ? _d : ''; | ||
const equalChars = (_d = attrMatchedMap[4]) !== null && _d !== void 0 ? _d : null; | ||
const spacesAfterEqualChars = (_e = attrMatchedMap[5]) !== null && _e !== void 0 ? _e : ''; | ||
const quoteChars = attrMatchedMap[6] != null ? '"' : attrMatchedMap[7] != null ? "'" : null; | ||
const valueChars = (_g = (_f = (_e = attrMatchedMap[6]) !== null && _e !== void 0 ? _e : attrMatchedMap[7]) !== null && _f !== void 0 ? _f : attrMatchedMap[8]) !== null && _g !== void 0 ? _g : (quoteChars ? '' : null); | ||
const valueChars = (_h = (_g = (_f = attrMatchedMap[6]) !== null && _f !== void 0 ? _f : attrMatchedMap[7]) !== null && _g !== void 0 ? _g : attrMatchedMap[8]) !== null && _h !== void 0 ? _h : (quoteChars ? '' : null); | ||
let offset = startOffset; | ||
@@ -54,7 +54,7 @@ const spacesBeforeName = (0, parser_utils_1.tokenizer)(spacesBeforeAttrString, line, col, offset); | ||
spacesBeforeEqualChars + | ||
(equalChars || '') + | ||
(equalChars !== null && equalChars !== void 0 ? equalChars : '') + | ||
spacesAfterEqualChars + | ||
(quoteChars || '') + | ||
(valueChars || '') + | ||
(quoteChars || ''), name.startLine, name.startCol, name.startOffset); | ||
(quoteChars !== null && quoteChars !== void 0 ? quoteChars : '') + | ||
(valueChars !== null && valueChars !== void 0 ? valueChars : '') + | ||
(quoteChars !== null && quoteChars !== void 0 ? quoteChars : ''), name.startLine, name.startCol, name.startOffset); | ||
return { | ||
@@ -61,0 +61,0 @@ type: 'html-attr', |
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[]; |
@@ -44,6 +44,7 @@ "use strict"; | ||
parentNode, rawHtml, offsetOffset, offsetLine, offsetColumn) { | ||
var _a, _b, _c; | ||
const nextNode = null; | ||
const location = getLocation(originNode); | ||
if (!location) { | ||
const prevToken = prevNode || parentNode; | ||
const prevToken = prevNode !== null && prevNode !== void 0 ? prevNode : parentNode; | ||
const startOffset = prevToken ? prevToken.endOffset : 0; | ||
@@ -83,3 +84,3 @@ const endOffset = prevToken ? prevToken.endOffset : 0; | ||
const { startOffset, endOffset, startLine, endLine, startCol, endCol } = location; | ||
const raw = rawHtml.slice(startOffset, endOffset || startOffset); | ||
const raw = rawHtml.slice(startOffset, endOffset !== null && endOffset !== void 0 ? endOffset : startOffset); | ||
switch (originNode.nodeName) { | ||
@@ -91,7 +92,7 @@ case '#documentType': { | ||
// @ts-ignore | ||
name: originNode.name || '', | ||
name: (_a = originNode.name) !== null && _a !== void 0 ? _a : '', | ||
// @ts-ignore | ||
publicId: originNode.publicId || '', | ||
publicId: (_b = originNode.publicId) !== null && _b !== void 0 ? _b : '', | ||
// @ts-ignore | ||
systemId: originNode.systemId || '', | ||
systemId: (_c = originNode.systemId) !== null && _c !== void 0 ? _c : '', | ||
startOffset: startOffset + offsetOffset, | ||
@@ -156,3 +157,3 @@ endOffset: endOffset + offsetOffset, | ||
? rawHtml.slice(tagLoc.startOffset, tagLoc.endOffset) | ||
: rawHtml.slice(startOffset, endOffset || startOffset); | ||
: rawHtml.slice(startOffset, endOffset !== null && endOffset !== void 0 ? endOffset : startOffset); | ||
const tagTokens = (0, parse_raw_tag_1.default)(startTagRaw, startLine, startCol, startOffset, offsetOffset, offsetLine, offsetColumn); | ||
@@ -247,3 +248,4 @@ const tagName = tagTokens.tagName; | ||
function getChildNodes(rootNode) { | ||
return rootNode.content ? rootNode.content.childNodes : rootNode.childNodes || []; | ||
var _a; | ||
return rootNode.content ? rootNode.content.childNodes : (_a = rootNode.childNodes) !== null && _a !== void 0 ? _a : []; | ||
} | ||
@@ -250,0 +252,0 @@ function hasLocation(node) { |
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; |
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 {}; |
{ | ||
"name": "@markuplint/html-parser", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"description": "HTML parser for markuplint", | ||
@@ -24,3 +24,3 @@ "repository": "git@github.com:markuplint/markuplint.git", | ||
"@markuplint/ml-ast": "3.1.0", | ||
"@markuplint/parser-utils": "3.5.0", | ||
"@markuplint/parser-utils": "3.6.0", | ||
"parse5": "7.1.2", | ||
@@ -32,3 +32,3 @@ "tslib": "^2.4.1" | ||
}, | ||
"gitHead": "0c47b2c2722f6823a17f36edbab98486275f8ab4" | ||
"gitHead": "715dd53d3b1064a9bcf616c1533921cad9e3b187" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28626
596
+ Added@markuplint/parser-utils@3.6.0(transitive)
+ Added@markuplint/types@3.5.0(transitive)
- Removed@markuplint/parser-utils@3.5.0(transitive)
- Removed@markuplint/types@3.4.0(transitive)