@markuplint/parser-utils
Advanced tools
Comparing version 3.0.0-dev.96 to 3.0.0-dev.176
@@ -1,2 +0,2 @@ | ||
export declare const MASK_CHAR = "\uE000"; | ||
export declare const MASK_CHAR = '\uE000'; | ||
/** | ||
@@ -8,1 +8,4 @@ * SVG Element list | ||
export declare const svgElementList: string[]; | ||
export declare const reTag: RegExp; | ||
export declare const reTagName: RegExp; | ||
export declare const reSplitterTag: RegExp; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.svgElementList = exports.MASK_CHAR = void 0; | ||
exports.reSplitterTag = exports.reTagName = exports.reTag = exports.svgElementList = exports.MASK_CHAR = void 0; | ||
exports.MASK_CHAR = '\uE000'; | ||
@@ -100,1 +100,5 @@ /** | ||
]; | ||
exports.reTag = /^<((?:.|\s|\n)+)>\s*$/; | ||
// eslint-disable-next-line no-control-regex | ||
exports.reTagName = /^(?:[a-z][^\u0000\u0009\u000A\u000C\u0020/>]*)/i; | ||
exports.reSplitterTag = /<[^>]+>/g; |
import type { MLToken } from '@markuplint/ml-ast'; | ||
export declare function tokenizer(raw: string | null, startLine: number, startCol: number, startOffset: number): MLToken; | ||
export declare function tokenizer( | ||
raw: string | null, | ||
startLine: number, | ||
startCol: number, | ||
startOffset: number, | ||
): MLToken; | ||
export declare function createTokenFromRawCode(raw: string | null, startOffset: number, rawCode: string): MLToken; | ||
export declare function uuid(): string; |
@@ -7,3 +7,3 @@ "use strict"; | ||
function tokenizer(raw, startLine, startCol, startOffset) { | ||
raw = raw || ''; | ||
raw = raw !== null && raw !== void 0 ? raw : ''; | ||
const endLine = (0, get_location_1.getEndLine)(raw, startLine); | ||
@@ -25,3 +25,3 @@ const endCol = (0, get_location_1.getEndCol)(raw, startCol); | ||
function createTokenFromRawCode(raw, startOffset, rawCode) { | ||
raw = raw || ''; | ||
raw = raw !== null && raw !== void 0 ? raw : ''; | ||
const loc = (0, get_location_1.sliceFragment)(rawCode, startOffset, startOffset + raw.length); | ||
@@ -28,0 +28,0 @@ return { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.attributesToDebugMaps = exports.nodeListToDebugMaps = void 0; | ||
function nodeListToDebugMaps(nodeList, withAttr = false) { | ||
function nodeListToDebugMaps( | ||
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types | ||
nodeList, withAttr = false) { | ||
return nodeList | ||
@@ -22,3 +24,5 @@ .map(n => { | ||
exports.nodeListToDebugMaps = nodeListToDebugMaps; | ||
function attributesToDebugMaps(attributes) { | ||
function attributesToDebugMaps( | ||
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types | ||
attributes) { | ||
return attributes.map(n => { | ||
@@ -54,5 +58,6 @@ const r = [ | ||
function tokenDebug(n, type = '') { | ||
var _a, _b, _c, _d; | ||
return `[${n.startLine}:${n.startCol}]>[${n.endLine}:${n.endCol}](${n.startOffset},${n.endOffset})${ | ||
// @ts-ignore | ||
n.potentialName || n.nodeName || n.name || n.type || type}: ${visibleWhiteSpace(n.raw)}`; | ||
(_d = (_c = (_b = (_a = n.potentialName) !== null && _a !== void 0 ? _a : n.nodeName) !== null && _b !== void 0 ? _b : n.name) !== null && _c !== void 0 ? _c : n.type) !== null && _d !== void 0 ? _d : type}: ${visibleWhiteSpace(n.raw)}`; | ||
} | ||
@@ -59,0 +64,0 @@ function visibleWhiteSpace(chars) { |
import type { ElementType, ParserAuthoredElementNameDistinguishing } from '@markuplint/ml-ast'; | ||
export declare function detectElementType(name: string, option?: ParserAuthoredElementNameDistinguishing, defaultPattern?: ParserAuthoredElementNameDistinguishing): ElementType; | ||
export declare function detectElementType( | ||
name: string, | ||
option?: ParserAuthoredElementNameDistinguishing, | ||
defaultPattern?: ParserAuthoredElementNameDistinguishing, | ||
): ElementType; |
@@ -13,6 +13,6 @@ "use strict"; | ||
function distinguishAuthoredName(name, pattern, defaultPattern) { | ||
if (pattern) { | ||
if (pattern != null) { | ||
return _distinguishAuthoredName(name, pattern); | ||
} | ||
if (defaultPattern) { | ||
if (defaultPattern != null) { | ||
return _distinguishAuthoredName(name, defaultPattern); | ||
@@ -34,3 +34,3 @@ } | ||
const matched = pattern.match(/^\/(.+)\/([ig]*)$/i); | ||
if (matched) { | ||
if (matched && matched[1]) { | ||
return new RegExp(matched[1], matched[2]); | ||
@@ -37,0 +37,0 @@ } |
@@ -5,10 +5,14 @@ export declare function getLine(html: string, startOffset: number): number; | ||
export declare function getEndCol(html: string, col: number): number; | ||
export declare function sliceFragment(rawHtml: string, start: number, end: number): { | ||
startOffset: number; | ||
endOffset: number; | ||
startLine: number; | ||
endLine: number; | ||
startCol: number; | ||
endCol: number; | ||
raw: string; | ||
export declare function sliceFragment( | ||
rawHtml: string, | ||
start: number, | ||
end: number, | ||
): { | ||
startOffset: number; | ||
endOffset: number; | ||
startLine: number; | ||
endLine: number; | ||
startCol: number; | ||
endCol: number; | ||
raw: string; | ||
}; |
@@ -9,4 +9,5 @@ "use strict"; | ||
function getCol(html, startOffset) { | ||
var _a; | ||
const lines = html.slice(0, startOffset).split(/\n/g); | ||
return lines[lines.length - 1].length + 1; | ||
return ((_a = lines[lines.length - 1]) !== null && _a !== void 0 ? _a : '').length + 1; | ||
} | ||
@@ -13,0 +14,0 @@ exports.getCol = getCol; |
export declare function searchIDLAttribute(name: string): { | ||
idlPropName: string | undefined; | ||
contentAttrName: string | undefined; | ||
idlPropName: string | undefined; | ||
contentAttrName: string | undefined; | ||
}; |
@@ -111,2 +111,5 @@ "use strict"; | ||
playsInline: 'playsinline', | ||
popover: 'popover', | ||
popoverTarget: 'popovertarget', | ||
popoverTargetAction: 'popovertargetaction', | ||
poster: 'poster', | ||
@@ -420,8 +423,9 @@ preload: 'preload', | ||
function searchIDLAttribute(name) { | ||
var _a; | ||
const camelizedName = camelize(name); | ||
const [idlPropName, contentAttrName] = (/^on[a-z]/.test(name) && [name.toLowerCase(), name.toLowerCase()]) || | ||
list.find(([idlPropName, contentAttrName]) => idlPropName.toLowerCase() === camelizedName.toLowerCase() || | ||
const [idlPropName, contentAttrName] = /^on[a-z]/.test(name) | ||
? [name.toLowerCase(), name.toLowerCase()] | ||
: (_a = list.find(([idlPropName, contentAttrName]) => idlPropName.toLowerCase() === camelizedName.toLowerCase() || | ||
contentAttrName.toLowerCase() === name.toLowerCase() || | ||
hyphenize(idlPropName) === name.toLowerCase()) || | ||
[]; | ||
hyphenize(idlPropName) === name.toLowerCase())) !== null && _a !== void 0 ? _a : []; | ||
return { | ||
@@ -434,3 +438,3 @@ idlPropName, | ||
function camelize(str) { | ||
return str.replace(/[:-][a-z]/g, $0 => $0[1].toUpperCase()); | ||
return str.replace(/[:-][a-z]/g, $0 => { var _a, _b; return (_b = (_a = $0[1]) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : ''; }); | ||
} | ||
@@ -437,0 +441,0 @@ function hyphenize(str) { |
import type { IgnoreBlock, IgnoreTag } from './types'; | ||
import type { MLASTNode } from '@markuplint/ml-ast'; | ||
export declare function ignoreBlock(source: string, tags: IgnoreTag[], maskChar?: string): IgnoreBlock; | ||
export declare function ignoreBlock(source: string, tags: readonly IgnoreTag[], maskChar?: string): IgnoreBlock; | ||
export declare function restoreNode(nodeList: MLASTNode[], ignoreBlock: IgnoreBlock): MLASTNode[]; |
@@ -16,3 +16,3 @@ "use strict"; | ||
taggedCode.replace(/[^\n]/g, maskChar) + | ||
maskChar.repeat((endTag || '').length); | ||
maskChar.repeat((endTag !== null && endTag !== void 0 ? endTag : '').length); | ||
return mask; | ||
@@ -26,3 +26,3 @@ }); | ||
taggedCode.replace(/[^\n]/g, maskChar) + | ||
maskChar.repeat((endTag || '').length); | ||
maskChar.repeat((endTag !== null && endTag !== void 0 ? endTag : '').length); | ||
const taggedMask = `<!${mask.slice(2).slice(0, -1)}>`; | ||
@@ -57,3 +57,3 @@ return taggedMask; | ||
taggedCode, | ||
endTag: endTag || null, | ||
endTag: endTag !== null && endTag !== void 0 ? endTag : null, | ||
}); | ||
@@ -63,3 +63,3 @@ /** | ||
*/ | ||
replaced = above + masking(startTag, taggedCode, endTag) + (below || ''); | ||
replaced = above + masking(startTag, taggedCode, endTag) + (below !== null && below !== void 0 ? below : ''); | ||
} | ||
@@ -71,4 +71,6 @@ return { | ||
} | ||
function restoreNode(nodeList, ignoreBlock) { | ||
var _a, _b, _c, _d; | ||
function restoreNode( | ||
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types | ||
nodeList, ignoreBlock) { | ||
var _a, _b, _c, _d, _e; | ||
nodeList = nodeList.slice(); | ||
@@ -89,3 +91,3 @@ const { source, stack, maskChar } = ignoreBlock; | ||
const start = tag.index - node.startOffset; | ||
const body = tag.startTag + tag.taggedCode + (tag.endTag || ''); | ||
const body = tag.startTag + tag.taggedCode + ((_a = tag.endTag) !== null && _a !== void 0 ? _a : ''); | ||
const above = node.raw.slice(pointer, start); | ||
@@ -108,6 +110,6 @@ const below = text.slice(above.length + body.length); | ||
}; | ||
if ((_a = node.prevNode) === null || _a === void 0 ? void 0 : _a.nextNode) { | ||
if ((_b = node.prevNode) === null || _b === void 0 ? void 0 : _b.nextNode) { | ||
node.prevNode.nextNode = textNode; | ||
} | ||
if ((_b = node.nextNode) === null || _b === void 0 ? void 0 : _b.prevNode) { | ||
if ((_c = node.nextNode) === null || _c === void 0 ? void 0 : _c.prevNode) { | ||
node.nextNode.prevNode = textNode; | ||
@@ -137,6 +139,6 @@ } | ||
}; | ||
if ((_c = node.prevNode) === null || _c === void 0 ? void 0 : _c.nextNode) { | ||
if ((_d = node.prevNode) === null || _d === void 0 ? void 0 : _d.nextNode) { | ||
node.prevNode.nextNode = bodyNode; | ||
} | ||
if ((_d = node.nextNode) === null || _d === void 0 ? void 0 : _d.prevNode) { | ||
if ((_e = node.nextNode) === null || _e === void 0 ? void 0 : _e.prevNode) { | ||
node.nextNode.prevNode = bodyNode; | ||
@@ -143,0 +145,0 @@ } |
@@ -0,10 +1,16 @@ | ||
export * from './const'; | ||
export * from './create-token'; | ||
export * from './debugger'; | ||
export * from './decision'; | ||
export * from './detect-element-type'; | ||
export * from './flatten-nodes'; | ||
export * from './get-location'; | ||
export * from './create-token'; | ||
export * from './get-space-before'; | ||
export * from './idl-attributes'; | ||
export * from './walker'; | ||
export * from './ignore-block'; | ||
export * from './ignore-front-matter'; | ||
export * from './debugger'; | ||
export * from './parse-attr'; | ||
export * from './parser-error'; | ||
export * from './detect-element-type'; | ||
export * from './remove-deprecated-node'; | ||
export * from './tag-splitter'; | ||
export * from './walker'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./const"), exports); | ||
tslib_1.__exportStar(require("./create-token"), exports); | ||
tslib_1.__exportStar(require("./debugger"), exports); | ||
tslib_1.__exportStar(require("./decision"), exports); | ||
tslib_1.__exportStar(require("./detect-element-type"), exports); | ||
tslib_1.__exportStar(require("./flatten-nodes"), exports); | ||
tslib_1.__exportStar(require("./get-location"), exports); | ||
tslib_1.__exportStar(require("./create-token"), exports); | ||
tslib_1.__exportStar(require("./get-space-before"), exports); | ||
tslib_1.__exportStar(require("./idl-attributes"), exports); | ||
tslib_1.__exportStar(require("./walker"), exports); | ||
tslib_1.__exportStar(require("./ignore-block"), exports); | ||
tslib_1.__exportStar(require("./ignore-front-matter"), exports); | ||
tslib_1.__exportStar(require("./debugger"), exports); | ||
tslib_1.__exportStar(require("./parse-attr"), exports); | ||
tslib_1.__exportStar(require("./parser-error"), exports); | ||
tslib_1.__exportStar(require("./detect-element-type"), exports); | ||
tslib_1.__exportStar(require("./remove-deprecated-node"), exports); | ||
tslib_1.__exportStar(require("./tag-splitter"), exports); | ||
tslib_1.__exportStar(require("./walker"), exports); |
export declare class ParserError extends Error { | ||
readonly col: number; | ||
readonly line: number; | ||
name: string; | ||
readonly nodeName: string | null; | ||
readonly raw: string; | ||
constructor(message: string, { line, col, raw, nodeName, }: { | ||
line?: number; | ||
col?: number; | ||
raw?: string; | ||
nodeName?: string | null; | ||
}); | ||
readonly col: number; | ||
readonly line: number; | ||
name: string; | ||
readonly nodeName: string | null; | ||
readonly raw: string; | ||
constructor( | ||
message: string, | ||
{ | ||
line, | ||
col, | ||
raw, | ||
nodeName, | ||
}: { | ||
readonly line?: number; | ||
readonly col?: number; | ||
readonly raw?: string; | ||
readonly nodeName?: string | null; | ||
}, | ||
); | ||
} |
@@ -11,7 +11,13 @@ "use strict"; | ||
*/ | ||
function siblingsCorrection(nodeList) { | ||
function siblingsCorrection( | ||
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types | ||
nodeList) { | ||
var _a, _b; | ||
for (let i = 0; i < nodeList.length; i++) { | ||
const prevNode = nodeList[i - 1] || null; | ||
const prevNode = (_a = nodeList[i - 1]) !== null && _a !== void 0 ? _a : null; | ||
const node = nodeList[i]; | ||
const nextNode = nodeList[i + 1] || null; | ||
if (!node) { | ||
continue; | ||
} | ||
const nextNode = (_b = nodeList[i + 1]) !== null && _b !== void 0 ? _b : null; | ||
node.prevNode = prevNode; | ||
@@ -18,0 +24,0 @@ node.nextNode = nextNode; |
export type Code = { | ||
type: string; | ||
index: number; | ||
startTag: string; | ||
taggedCode: string; | ||
endTag: string | null; | ||
readonly type: string; | ||
readonly index: number; | ||
readonly startTag: string; | ||
readonly taggedCode: string; | ||
readonly endTag: string | null; | ||
}; | ||
export type IgnoreTag = { | ||
type: string; | ||
start: RegExp; | ||
end: RegExp; | ||
readonly type: string; | ||
readonly start: Readonly<RegExp>; | ||
readonly end: Readonly<RegExp>; | ||
}; | ||
export type IgnoreBlock = { | ||
source: string; | ||
replaced: string; | ||
stack: Code[]; | ||
maskChar: string; | ||
readonly source: string; | ||
readonly replaced: string; | ||
readonly stack: readonly Code[]; | ||
readonly maskChar: string; | ||
}; |
import type { MLASTNode, Walker } from '@markuplint/ml-ast'; | ||
export declare function walk(nodeList: MLASTNode[], walker: Walker, depth?: number): void; | ||
export declare function walk(nodeList: readonly MLASTNode[], walker: Walker, depth?: number): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.walk = void 0; | ||
function walk(nodeList, walker, depth = 0) { | ||
function walk( | ||
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types | ||
nodeList, walker, depth = 0) { | ||
for (const node of nodeList) { | ||
@@ -11,3 +13,3 @@ walker(node, depth); | ||
} | ||
if (node.childNodes && node.childNodes.length) { | ||
if (node.childNodes && node.childNodes.length > 0) { | ||
walk(node.childNodes, walker, depth + 1); | ||
@@ -14,0 +16,0 @@ } |
{ | ||
"name": "@markuplint/parser-utils", | ||
"version": "3.0.0-dev.96+3b9f1720", | ||
"version": "3.0.0-dev.176+f6ad62e9", | ||
"description": "Utility module for markuplint parser plugin", | ||
@@ -21,9 +21,8 @@ "repository": "git@github.com:markuplint/markuplint.git", | ||
}, | ||
"devDependencies": { | ||
"@types/uuid": "^9.0.0" | ||
}, | ||
"dependencies": { | ||
"@markuplint/ml-ast": "3.0.0-dev.96+3b9f1720", | ||
"@markuplint/types": "3.0.0-dev.96+3b9f1720", | ||
"@markuplint/ml-ast": "3.0.0-dev.176+f6ad62e9", | ||
"@markuplint/types": "3.0.0-dev.176+f6ad62e9", | ||
"@types/uuid": "^9.0.0", | ||
"tslib": "^2.4.1", | ||
"type-fest": "^3.8.0", | ||
"uuid": "^9.0.0" | ||
@@ -34,3 +33,3 @@ }, | ||
}, | ||
"gitHead": "3b9f17205d7754b29edf790bdbbf5e4931ba27a2" | ||
"gitHead": "f6ad62e992e1569be4067f1e90d2d6017a658f57" | ||
} |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
76372
0
49
2229
7
+ Added@types/uuid@^9.0.0
+ Addedtype-fest@^3.8.0
+ Addedtype-fest@3.13.1(transitive)