@markuplint/html-parser 3.0.0-canary.5 → 3.0.0-dev.177
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/attr-tokenizer.js +11 -10
- package/lib/create-tree.d.ts +7 -1
- package/lib/create-tree.js +22 -33
- package/lib/get-namespace.js +1 -1
- package/lib/index.d.ts +4 -5
- package/lib/index.js +9 -11
- package/lib/optimize-starts-head-or-body.d.ts +7 -4
- package/lib/optimize-starts-head-or-body.js +5 -1
- package/lib/parse-raw-tag.d.ts +13 -5
- package/lib/parse-raw-tag.js +7 -7
- package/lib/parse.js +1 -2
- package/package.json +10 -6
- package/test/attr-tokenizer.spec.js +675 -0
- package/test/get-namespace.spec.js +21 -0
- package/test/index.spec.js +1246 -0
- package/test/optimize-starts-head-or-body.spec.js +25 -0
- package/test/parse-raw-tag.spec.js +483 -0
- package/lib/const.d.ts +0 -3
- package/lib/const.js +0 -7
- package/lib/flatten-nodes.d.ts +0 -2
- package/lib/flatten-nodes.js +0 -238
- package/lib/remove-deprecated-node.d.ts +0 -7
- package/lib/remove-deprecated-node.js +0 -41
- package/lib/tag-splitter.d.ts +0 -7
- package/lib/tag-splitter.js +0 -92
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
package/lib/attr-tokenizer.js
CHANGED
|
@@ -5,17 +5,18 @@ const reAttrsInStartTag =
|
|
|
5
5
|
// eslint-disable-next-line no-control-regex
|
|
6
6
|
/(\s*)([^\x00-\x1f\x7f-\x9f "'>/=]+)(?:(\s*)(=)(\s*)(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s]*)))?/;
|
|
7
7
|
function attrTokenizer(raw, line, col, startOffset) {
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8
9
|
const attrMatchedMap = raw.match(reAttrsInStartTag);
|
|
9
10
|
if (!attrMatchedMap) {
|
|
10
11
|
throw new SyntaxError('Illegal attribute token');
|
|
11
12
|
}
|
|
12
|
-
const spacesBeforeAttrString = attrMatchedMap[1];
|
|
13
|
-
const nameChars = attrMatchedMap[2];
|
|
14
|
-
const spacesBeforeEqualChars = attrMatchedMap[3]
|
|
15
|
-
const equalChars = attrMatchedMap[4]
|
|
16
|
-
const spacesAfterEqualChars = attrMatchedMap[5]
|
|
13
|
+
const spacesBeforeAttrString = (_a = attrMatchedMap[1]) !== null && _a !== void 0 ? _a : '';
|
|
14
|
+
const nameChars = (_b = attrMatchedMap[2]) !== null && _b !== void 0 ? _b : '';
|
|
15
|
+
const spacesBeforeEqualChars = (_c = attrMatchedMap[3]) !== null && _c !== void 0 ? _c : '';
|
|
16
|
+
const equalChars = (_d = attrMatchedMap[4]) !== null && _d !== void 0 ? _d : null;
|
|
17
|
+
const spacesAfterEqualChars = (_e = attrMatchedMap[5]) !== null && _e !== void 0 ? _e : '';
|
|
17
18
|
const quoteChars = attrMatchedMap[6] != null ? '"' : attrMatchedMap[7] != null ? "'" : null;
|
|
18
|
-
const valueChars = attrMatchedMap[6]
|
|
19
|
+
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);
|
|
19
20
|
let offset = startOffset;
|
|
20
21
|
const spacesBeforeName = (0, parser_utils_1.tokenizer)(spacesBeforeAttrString, line, col, offset);
|
|
21
22
|
line = spacesBeforeName.endLine;
|
|
@@ -48,11 +49,11 @@ function attrTokenizer(raw, line, col, startOffset) {
|
|
|
48
49
|
const endQuote = (0, parser_utils_1.tokenizer)(quoteChars, line, col, offset);
|
|
49
50
|
const attrToken = (0, parser_utils_1.tokenizer)(nameChars +
|
|
50
51
|
spacesBeforeEqualChars +
|
|
51
|
-
(equalChars
|
|
52
|
+
(equalChars !== null && equalChars !== void 0 ? equalChars : '') +
|
|
52
53
|
spacesAfterEqualChars +
|
|
53
|
-
(quoteChars
|
|
54
|
-
(valueChars
|
|
55
|
-
(quoteChars
|
|
54
|
+
(quoteChars !== null && quoteChars !== void 0 ? quoteChars : '') +
|
|
55
|
+
(valueChars !== null && valueChars !== void 0 ? valueChars : '') +
|
|
56
|
+
(quoteChars !== null && quoteChars !== void 0 ? quoteChars : ''), name.startLine, name.startCol, name.startOffset);
|
|
56
57
|
return {
|
|
57
58
|
type: 'html-attr',
|
|
58
59
|
uuid: (0, parser_utils_1.uuid)(),
|
package/lib/create-tree.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { MLASTNode } from '@markuplint/ml-ast';
|
|
2
|
-
export declare function createTree(
|
|
2
|
+
export declare function createTree(
|
|
3
|
+
rawCode: string,
|
|
4
|
+
isFragment: boolean,
|
|
5
|
+
offsetOffset: number,
|
|
6
|
+
offsetLine: number,
|
|
7
|
+
offsetColumn: number,
|
|
8
|
+
): MLASTNode[];
|
package/lib/create-tree.js
CHANGED
|
@@ -5,15 +5,18 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const parser_utils_1 = require("@markuplint/parser-utils");
|
|
6
6
|
const parse5_1 = require("parse5");
|
|
7
7
|
const parse_raw_tag_1 = tslib_1.__importDefault(require("./parse-raw-tag"));
|
|
8
|
-
const P5_OPTIONS = {
|
|
8
|
+
const P5_OPTIONS = {
|
|
9
|
+
scriptingEnabled: false,
|
|
10
|
+
sourceCodeLocationInfo: true,
|
|
11
|
+
};
|
|
9
12
|
function createTree(rawCode, isFragment, offsetOffset, offsetLine, offsetColumn) {
|
|
10
|
-
const doc = isFragment
|
|
11
|
-
? (0, parse5_1.parseFragment)(rawCode, P5_OPTIONS)
|
|
12
|
-
: (0, parse5_1.parse)(rawCode, P5_OPTIONS);
|
|
13
|
+
const doc = isFragment ? (0, parse5_1.parseFragment)(rawCode, P5_OPTIONS) : (0, parse5_1.parse)(rawCode, P5_OPTIONS);
|
|
13
14
|
return createTreeRecursive(doc, null, rawCode, offsetOffset, offsetLine, offsetColumn);
|
|
14
15
|
}
|
|
15
16
|
exports.createTree = createTree;
|
|
16
|
-
function createTreeRecursive(rootNode,
|
|
17
|
+
function createTreeRecursive(rootNode,
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
19
|
+
parentNode, rawHtml, offsetOffset, offsetLine, offsetColumn) {
|
|
17
20
|
const nodeList = [];
|
|
18
21
|
const childNodes = getChildNodes(rootNode);
|
|
19
22
|
let prevNode = null;
|
|
@@ -33,11 +36,16 @@ function createTreeRecursive(rootNode, parentNode, rawHtml, offsetOffset, offset
|
|
|
33
36
|
}
|
|
34
37
|
return nodeList;
|
|
35
38
|
}
|
|
36
|
-
function nodeize(originNode,
|
|
39
|
+
function nodeize(originNode,
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
41
|
+
prevNode,
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
43
|
+
parentNode, rawHtml, offsetOffset, offsetLine, offsetColumn) {
|
|
44
|
+
var _a, _b, _c;
|
|
37
45
|
const nextNode = null;
|
|
38
46
|
const location = getLocation(originNode);
|
|
39
47
|
if (!location) {
|
|
40
|
-
const prevToken = prevNode
|
|
48
|
+
const prevToken = prevNode !== null && prevNode !== void 0 ? prevNode : parentNode;
|
|
41
49
|
const startOffset = prevToken ? prevToken.endOffset : 0;
|
|
42
50
|
const endOffset = prevToken ? prevToken.endOffset : 0;
|
|
43
51
|
const startLine = prevToken ? prevToken.endLine : 0;
|
|
@@ -72,18 +80,18 @@ function nodeize(originNode, prevNode, parentNode, rawHtml, offsetOffset, offset
|
|
|
72
80
|
return node;
|
|
73
81
|
}
|
|
74
82
|
const { startOffset, endOffset, startLine, endLine, startCol, endCol } = location;
|
|
75
|
-
const raw = rawHtml.slice(startOffset, endOffset
|
|
83
|
+
const raw = rawHtml.slice(startOffset, endOffset !== null && endOffset !== void 0 ? endOffset : startOffset);
|
|
76
84
|
switch (originNode.nodeName) {
|
|
77
85
|
case '#documentType': {
|
|
78
86
|
return {
|
|
79
87
|
uuid: (0, parser_utils_1.uuid)(),
|
|
80
88
|
raw,
|
|
81
89
|
// @ts-ignore
|
|
82
|
-
name: originNode.name
|
|
90
|
+
name: (_a = originNode.name) !== null && _a !== void 0 ? _a : '',
|
|
83
91
|
// @ts-ignore
|
|
84
|
-
publicId: originNode.publicId
|
|
92
|
+
publicId: (_b = originNode.publicId) !== null && _b !== void 0 ? _b : '',
|
|
85
93
|
// @ts-ignore
|
|
86
|
-
systemId: originNode.systemId
|
|
94
|
+
systemId: (_c = originNode.systemId) !== null && _c !== void 0 ? _c : '',
|
|
87
95
|
startOffset: startOffset + offsetOffset,
|
|
88
96
|
endOffset: endOffset + offsetOffset,
|
|
89
97
|
startLine: startLine + offsetLine,
|
|
@@ -143,7 +151,7 @@ function nodeize(originNode, prevNode, parentNode, rawHtml, offsetOffset, offset
|
|
|
143
151
|
const tagLoc = 'startTag' in location ? location.startTag : null;
|
|
144
152
|
const startTagRaw = tagLoc
|
|
145
153
|
? rawHtml.slice(tagLoc.startOffset, tagLoc.endOffset)
|
|
146
|
-
: rawHtml.slice(startOffset, endOffset
|
|
154
|
+
: rawHtml.slice(startOffset, endOffset !== null && endOffset !== void 0 ? endOffset : startOffset);
|
|
147
155
|
const tagTokens = (0, parse_raw_tag_1.default)(startTagRaw, startLine, startCol, startOffset, offsetOffset, offsetLine, offsetColumn);
|
|
148
156
|
const tagName = tagTokens.tagName;
|
|
149
157
|
let endTag = null;
|
|
@@ -231,29 +239,10 @@ function nodeize(originNode, prevNode, parentNode, rawHtml, offsetOffset, offset
|
|
|
231
239
|
* getChildNodes
|
|
232
240
|
*
|
|
233
241
|
* - If node has "content" property then parse as document fragment.
|
|
234
|
-
* - If node is <noscript> then that childNodes is a TextNode. But parse as document fragment it for disabled script.
|
|
235
242
|
*/
|
|
236
243
|
function getChildNodes(rootNode) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (!textNode || textNode.nodeName !== '#text') {
|
|
240
|
-
return [];
|
|
241
|
-
}
|
|
242
|
-
// @ts-ignore
|
|
243
|
-
const html = textNode.value;
|
|
244
|
-
// @ts-ignore
|
|
245
|
-
const { startOffset, startLine, startCol } = textNode.sourceCodeLocation;
|
|
246
|
-
const breakCount = startLine - 1;
|
|
247
|
-
const indentWidth = startCol - 1;
|
|
248
|
-
const offsetSpaces = ' '.repeat(startOffset - Math.max(breakCount, 0) - Math.max(indentWidth, 0)) +
|
|
249
|
-
'\n'.repeat(breakCount) +
|
|
250
|
-
' '.repeat(indentWidth);
|
|
251
|
-
const fragment = (0, parse5_1.parseFragment)(`${offsetSpaces}${html}`, P5_OPTIONS);
|
|
252
|
-
const childNodes = fragment.childNodes.slice(offsetSpaces ? 1 : 0);
|
|
253
|
-
// const childNodes = ('childNodes' in _childNodes && _childNodes.childNodes) || [];
|
|
254
|
-
return childNodes;
|
|
255
|
-
}
|
|
256
|
-
return rootNode.content ? rootNode.content.childNodes : rootNode.childNodes || [];
|
|
244
|
+
var _a;
|
|
245
|
+
return rootNode.content ? rootNode.content.childNodes : (_a = rootNode.childNodes) !== null && _a !== void 0 ? _a : [];
|
|
257
246
|
}
|
|
258
247
|
function hasLocation(node) {
|
|
259
248
|
return 'sourceCodeLocation' in node;
|
package/lib/get-namespace.js
CHANGED
|
@@ -27,7 +27,7 @@ function getNamespace(tagName, parentNamespace = DEFAULT_NAMESPACE) {
|
|
|
27
27
|
const doc = (0, parse5_1.parse)(tag);
|
|
28
28
|
node = doc.childNodes[0];
|
|
29
29
|
}
|
|
30
|
-
if ('namespaceURI' in node) {
|
|
30
|
+
if (node && 'namespaceURI' in node) {
|
|
31
31
|
return node.namespaceURI;
|
|
32
32
|
}
|
|
33
33
|
return DEFAULT_NAMESPACE;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
export { default as attrTokenizer } from './attr-tokenizer';
|
|
1
2
|
export { default as isDocumentFragment } from './is-document-fragment';
|
|
2
|
-
export { parse } from './parse';
|
|
3
|
-
export { flattenNodes } from './flatten-nodes';
|
|
4
|
-
export { removeDeprecatedNode } from './remove-deprecated-node';
|
|
5
|
-
export { getNamespace } from './get-namespace';
|
|
6
3
|
export { default as parseRawTag } from './parse-raw-tag';
|
|
7
|
-
export {
|
|
4
|
+
export { getNamespace } from './get-namespace';
|
|
5
|
+
export { parse } from './parse';
|
|
6
|
+
export { createTree } from './create-tree';
|
package/lib/index.js
CHANGED
|
@@ -3,18 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.createTree = exports.parse = exports.getNamespace = exports.parseRawTag = exports.isDocumentFragment = exports.attrTokenizer = void 0;
|
|
7
|
+
var attr_tokenizer_1 = require("./attr-tokenizer");
|
|
8
|
+
Object.defineProperty(exports, "attrTokenizer", { enumerable: true, get: function () { return __importDefault(attr_tokenizer_1).default; } });
|
|
7
9
|
var is_document_fragment_1 = require("./is-document-fragment");
|
|
8
10
|
Object.defineProperty(exports, "isDocumentFragment", { enumerable: true, get: function () { return __importDefault(is_document_fragment_1).default; } });
|
|
9
|
-
var parse_1 = require("./parse");
|
|
10
|
-
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_1.parse; } });
|
|
11
|
-
var flatten_nodes_1 = require("./flatten-nodes");
|
|
12
|
-
Object.defineProperty(exports, "flattenNodes", { enumerable: true, get: function () { return flatten_nodes_1.flattenNodes; } });
|
|
13
|
-
var remove_deprecated_node_1 = require("./remove-deprecated-node");
|
|
14
|
-
Object.defineProperty(exports, "removeDeprecatedNode", { enumerable: true, get: function () { return remove_deprecated_node_1.removeDeprecatedNode; } });
|
|
15
|
-
var get_namespace_1 = require("./get-namespace");
|
|
16
|
-
Object.defineProperty(exports, "getNamespace", { enumerable: true, get: function () { return get_namespace_1.getNamespace; } });
|
|
17
11
|
var parse_raw_tag_1 = require("./parse-raw-tag");
|
|
18
12
|
Object.defineProperty(exports, "parseRawTag", { enumerable: true, get: function () { return __importDefault(parse_raw_tag_1).default; } });
|
|
19
|
-
var
|
|
20
|
-
Object.defineProperty(exports, "
|
|
13
|
+
var get_namespace_1 = require("./get-namespace");
|
|
14
|
+
Object.defineProperty(exports, "getNamespace", { enumerable: true, get: function () { return get_namespace_1.getNamespace; } });
|
|
15
|
+
var parse_1 = require("./parse");
|
|
16
|
+
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_1.parse; } });
|
|
17
|
+
var create_tree_1 = require("./create-tree");
|
|
18
|
+
Object.defineProperty(exports, "createTree", { enumerable: true, get: function () { return create_tree_1.createTree; } });
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { MLASTNode } from '@markuplint/ml-ast';
|
|
2
2
|
export declare function isStartsHeadTagOrBodyTag(rawCode: string): boolean;
|
|
3
3
|
export declare function optimizeStartsHeadTagOrBodyTagSetup(rawCode: string): {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
code: string;
|
|
5
|
+
heads: string[];
|
|
6
|
+
bodies: string[];
|
|
7
7
|
};
|
|
8
|
-
export declare function optimizeStartsHeadTagOrBodyTagResume(
|
|
8
|
+
export declare function optimizeStartsHeadTagOrBodyTagResume(
|
|
9
|
+
nodeList: MLASTNode[],
|
|
10
|
+
replacements: ReturnType<typeof optimizeStartsHeadTagOrBodyTagSetup>,
|
|
11
|
+
): void;
|
|
@@ -34,7 +34,11 @@ function optimizeStartsHeadTagOrBodyTagSetup(rawCode) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
exports.optimizeStartsHeadTagOrBodyTagSetup = optimizeStartsHeadTagOrBodyTagSetup;
|
|
37
|
-
function optimizeStartsHeadTagOrBodyTagResume(
|
|
37
|
+
function optimizeStartsHeadTagOrBodyTagResume(
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
39
|
+
nodeList,
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
41
|
+
replacements) {
|
|
38
42
|
nodeList.forEach(node => {
|
|
39
43
|
if (!node.nodeName.startsWith(`x-${UNDUPLICATED_CHAR}`)) {
|
|
40
44
|
return;
|
package/lib/parse-raw-tag.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import type { MLASTAttr, MLToken } from '@markuplint/ml-ast';
|
|
2
2
|
type TagTokens = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
tagName: string;
|
|
4
|
+
attrs: MLASTAttr[];
|
|
5
|
+
selfClosingSolidus: MLToken;
|
|
6
|
+
endSpace: MLToken;
|
|
7
7
|
};
|
|
8
|
-
export default function parseRawTag(
|
|
8
|
+
export default function parseRawTag(
|
|
9
|
+
raw: string,
|
|
10
|
+
startLine: number,
|
|
11
|
+
startCol: number,
|
|
12
|
+
startOffset: number,
|
|
13
|
+
offsetOffset?: number,
|
|
14
|
+
offsetLine?: number,
|
|
15
|
+
offsetColumn?: number,
|
|
16
|
+
): TagTokens;
|
|
9
17
|
export {};
|
package/lib/parse-raw-tag.js
CHANGED
|
@@ -3,23 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const parser_utils_1 = require("@markuplint/parser-utils");
|
|
5
5
|
const attr_tokenizer_1 = tslib_1.__importDefault(require("./attr-tokenizer"));
|
|
6
|
-
const const_1 = require("./const");
|
|
7
6
|
// eslint-disable-next-line no-control-regex
|
|
8
7
|
const reAttrsInStartTag = /\s*[^\x00-\x1f\x7f-\x9f "'>/=]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^\s]*))?/;
|
|
9
8
|
const reEndTokens = /(\s*\/)?(\s*)>$/;
|
|
10
9
|
function parseRawTag(raw, startLine, startCol, startOffset, offsetOffset = 0, offsetLine = 0, offsetColumn = 0) {
|
|
10
|
+
var _a, _b;
|
|
11
11
|
let offset = startOffset + offsetOffset;
|
|
12
12
|
let line = startLine + offsetLine;
|
|
13
13
|
let col = startCol + (startLine === 1 ? offsetColumn : 0);
|
|
14
|
-
const matches = raw.match(
|
|
15
|
-
|
|
14
|
+
const matches = raw.match(parser_utils_1.reTag);
|
|
15
|
+
const tagWithAttrs = matches === null || matches === void 0 ? void 0 : matches[1];
|
|
16
|
+
if (!tagWithAttrs) {
|
|
16
17
|
throw new SyntaxError(`Invalid tag syntax: "${raw}"`);
|
|
17
18
|
}
|
|
18
|
-
const tagWithAttrs = matches[1];
|
|
19
19
|
// eslint-disable-next-line no-control-regex
|
|
20
20
|
const tagNameSplitted = tagWithAttrs.split(/[\u0000\u0009\u000A\u000C\u0020/>]/);
|
|
21
21
|
const tagName = tagNameSplitted[0] || tagNameSplitted[1];
|
|
22
|
-
if (!tagName || (!
|
|
22
|
+
if (!tagName || (!parser_utils_1.reTagName.test(tagName) && !(0, parser_utils_1.isPotentialCustomElementName)(tagName))) {
|
|
23
23
|
throw new SyntaxError(`Invalid tag name: "${tagName}" in <${tagWithAttrs}>`);
|
|
24
24
|
}
|
|
25
25
|
const tagStartPos = tagWithAttrs.indexOf(tagName);
|
|
@@ -41,11 +41,11 @@ function parseRawTag(raw, startLine, startCol, startOffset, offsetOffset = 0, of
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
const endTokens = reEndTokens.exec(raw);
|
|
44
|
-
const selfClosingSolidus = (0, parser_utils_1.tokenizer)(endTokens
|
|
44
|
+
const selfClosingSolidus = (0, parser_utils_1.tokenizer)((_a = endTokens === null || endTokens === void 0 ? void 0 : endTokens[1]) !== null && _a !== void 0 ? _a : '', line, col, offset);
|
|
45
45
|
line = selfClosingSolidus.endLine;
|
|
46
46
|
col = selfClosingSolidus.endCol;
|
|
47
47
|
offset = selfClosingSolidus.endOffset;
|
|
48
|
-
const endSpace = (0, parser_utils_1.tokenizer)(endTokens
|
|
48
|
+
const endSpace = (0, parser_utils_1.tokenizer)((_b = endTokens === null || endTokens === void 0 ? void 0 : endTokens[2]) !== null && _b !== void 0 ? _b : '', line, col, offset);
|
|
49
49
|
return {
|
|
50
50
|
tagName,
|
|
51
51
|
attrs,
|
package/lib/parse.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.parse = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const parser_utils_1 = require("@markuplint/parser-utils");
|
|
6
6
|
const create_tree_1 = require("./create-tree");
|
|
7
|
-
const flatten_nodes_1 = require("./flatten-nodes");
|
|
8
7
|
const is_document_fragment_1 = tslib_1.__importDefault(require("./is-document-fragment"));
|
|
9
8
|
const optimize_starts_head_or_body_1 = require("./optimize-starts-head-or-body");
|
|
10
9
|
const parse = (rawCode, options) => {
|
|
@@ -18,7 +17,7 @@ const parse = (rawCode, options) => {
|
|
|
18
17
|
rawCode = data.code;
|
|
19
18
|
}
|
|
20
19
|
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);
|
|
21
|
-
const nodeList = (0,
|
|
20
|
+
const nodeList = (0, parser_utils_1.flattenNodes)(nodeTree, rawCode);
|
|
22
21
|
if (data) {
|
|
23
22
|
(0, optimize_starts_head_or_body_1.optimizeStartsHeadTagOrBodyTagResume)(nodeList, data);
|
|
24
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/html-parser",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-dev.177+e94f3601",
|
|
4
4
|
"description": "HTML parser for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -11,16 +11,20 @@
|
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
|
+
"typedoc": {
|
|
15
|
+
"entryPoint": "./src/index.ts"
|
|
16
|
+
},
|
|
14
17
|
"scripts": {
|
|
15
18
|
"build": "tsc",
|
|
16
19
|
"dev": "tsc --build --watch",
|
|
17
20
|
"clean": "tsc --build --clean"
|
|
18
21
|
},
|
|
19
22
|
"dependencies": {
|
|
20
|
-
"@markuplint/ml-ast": "3.0.0-
|
|
21
|
-
"@markuplint/parser-utils": "3.0.0-
|
|
22
|
-
"parse5": "
|
|
23
|
-
"tslib": "^2.4.
|
|
23
|
+
"@markuplint/ml-ast": "3.0.0-dev.177+e94f3601",
|
|
24
|
+
"@markuplint/parser-utils": "3.0.0-dev.177+e94f3601",
|
|
25
|
+
"parse5": "7.1.2",
|
|
26
|
+
"tslib": "^2.4.1",
|
|
27
|
+
"type-fest": "^3.8.0"
|
|
24
28
|
},
|
|
25
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "e94f3601bf93366d1a2c7385ff7235817d82f7c9"
|
|
26
30
|
}
|