@markuplint/parser-utils 4.6.4 → 4.6.6

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/CHANGELOG.md CHANGED
@@ -3,16 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [4.6.4](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.3...@markuplint/parser-utils@4.6.4) (2024-06-09)
6
+ ## [4.6.6](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.5...@markuplint/parser-utils@4.6.6) (2024-09-02)
7
+
8
+ **Note:** Version bump only for package @markuplint/parser-utils
9
+
7
10
 
8
11
 
9
- ### Bug Fixes
10
12
 
11
- * fix to export type files ([eff4bbf](https://github.com/markuplint/markuplint/commit/eff4bbfd127574809dc5e15d7cafe87699758ee0))
12
13
 
14
+ ## [4.6.5](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.4...@markuplint/parser-utils@4.6.5) (2024-06-25)
13
15
 
16
+ ### Bug Fixes
17
+
18
+ - **parser-utils:** modify to treat attrs start with `script` type quotation marks as spread attr ([617b6d0](https://github.com/markuplint/markuplint/commit/617b6d0fbba1d245ca21360908b643f123818037))
14
19
 
20
+ ## [4.6.4](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.3...@markuplint/parser-utils@4.6.4) (2024-06-09)
21
+
22
+ ### Bug Fixes
15
23
 
24
+ - fix to export type files ([eff4bbf](https://github.com/markuplint/markuplint/commit/eff4bbfd127574809dc5e15d7cafe87699758ee0))
16
25
 
17
26
  ## [4.6.3](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.2...@markuplint/parser-utils@4.6.3) (2024-05-28)
18
27
 
@@ -25,7 +25,13 @@ export function attrTokenizer(raw, quoteSet = defaultQuoteSet, startState = Attr
25
25
  let valueType = noQuoteValueType;
26
26
  let parser;
27
27
  let quoteEnd = '';
28
- const isBeforeValueStarted = startState === AttrState.BeforeValue;
28
+ // If the `quoteSet` contains a `script` type quotation mark and an attribute starts with that quotation mark,
29
+ // the attribute name and equals sign are considered omitted.
30
+ const scriptStartChars = quoteSet.filter(quote => quote.type === 'script').map(quote => quote.start);
31
+ if (scriptStartChars.some(scriptStartChar => raw.trim().startsWith(scriptStartChar))) {
32
+ state = AttrState.BeforeValue;
33
+ }
34
+ const isBeforeValueStarted = state === AttrState.BeforeValue;
29
35
  const chars = [...raw];
30
36
  while (chars.length > 0) {
31
37
  if (state === AttrState.AfterValue) {
@@ -420,9 +420,9 @@ export function searchIDLAttribute(name) {
420
420
  const camelizedName = camelize(name);
421
421
  const [idlPropName, contentAttrName] = /^on[a-z]/.test(name)
422
422
  ? [name.toLowerCase(), name.toLowerCase()]
423
- : list.find(([idlPropName, contentAttrName]) => idlPropName.toLowerCase() === camelizedName.toLowerCase() ||
423
+ : (list.find(([idlPropName, contentAttrName]) => idlPropName.toLowerCase() === camelizedName.toLowerCase() ||
424
424
  contentAttrName.toLowerCase() === name.toLowerCase() ||
425
- hyphenize(idlPropName) === name.toLowerCase()) ?? [];
425
+ hyphenize(idlPropName) === name.toLowerCase()) ?? []);
426
426
  return {
427
427
  idlPropName,
428
428
  contentAttrName,
package/lib/parser.d.ts CHANGED
@@ -5,6 +5,7 @@ import { ParserError } from './parser-error.js';
5
5
  export declare abstract class Parser<Node extends {} = {}, State extends unknown = null> implements MLParser {
6
6
  #private;
7
7
  state: State;
8
+ constructor(options?: ParserOptions, defaultState?: State);
8
9
  get authoredElementName(): ParserAuthoredElementNameDistinguishing | undefined;
9
10
  /**
10
11
  * Detect value as a true if its attribute is booleanish value and omitted.
@@ -27,13 +28,12 @@ export declare abstract class Parser<Node extends {} = {}, State extends unknown
27
28
  get endTag(): EndTagType;
28
29
  get rawCode(): string;
29
30
  get tagNameCaseSensitive(): boolean;
30
- constructor(options?: ParserOptions, defaultState?: State);
31
31
  tokenize(options?: ParseOptions): Tokenized<Node, State>;
32
32
  beforeParse(rawCode: string, options?: ParseOptions): string;
33
33
  parse(rawCode: string, options?: ParseOptions): MLASTDocument;
34
34
  afterParse(nodeList: readonly MLASTNodeTreeItem[], options?: ParseOptions): readonly MLASTNodeTreeItem[];
35
35
  parseError(error: any): ParserError;
36
- traverse(originNodes: readonly Node[], parentNode: MLASTParentNode | null | undefined, depth: number): {
36
+ traverse(originNodes: readonly Node[], parentNode: (MLASTParentNode | null) | undefined, depth: number): {
37
37
  childNodes: readonly MLASTChildNode[];
38
38
  siblings: readonly MLASTNodeTreeItem[];
39
39
  };
package/lib/parser.js CHANGED
@@ -23,6 +23,33 @@ import { ignoreFrontMatter } from './ignore-front-matter.js';
23
23
  import { ParserError } from './parser-error.js';
24
24
  import { sortNodes } from './sort-nodes.js';
25
25
  export class Parser {
26
+ constructor(options, defaultState) {
27
+ _Parser_instances.add(this);
28
+ _Parser_booleanish.set(this, false);
29
+ _Parser_defaultState.set(this, void 0);
30
+ _Parser_endTagType.set(this, 'omittable');
31
+ _Parser_ignoreTags.set(this, []);
32
+ _Parser_maskChar.set(this, void 0);
33
+ _Parser_tagNameCaseSensitive.set(this, false);
34
+ _Parser_selfCloseType.set(this, 'html');
35
+ _Parser_spaceChars.set(this, defaultSpaces);
36
+ _Parser_rawTextElements.set(this, ['style', 'script']);
37
+ _Parser_authoredElementName.set(this, void 0);
38
+ _Parser_originalRawCode.set(this, '');
39
+ _Parser_rawCode.set(this, '');
40
+ _Parser_defaultDepth.set(this, 0);
41
+ _Parser_walkMethodSequentailPrevNode.set(this, null);
42
+ __classPrivateFieldSet(this, _Parser_booleanish, options?.booleanish ?? __classPrivateFieldGet(this, _Parser_booleanish, "f"), "f");
43
+ __classPrivateFieldSet(this, _Parser_endTagType, options?.endTagType ?? __classPrivateFieldGet(this, _Parser_endTagType, "f"), "f");
44
+ __classPrivateFieldSet(this, _Parser_ignoreTags, options?.ignoreTags ?? __classPrivateFieldGet(this, _Parser_ignoreTags, "f"), "f");
45
+ __classPrivateFieldSet(this, _Parser_maskChar, options?.maskChar ?? __classPrivateFieldGet(this, _Parser_maskChar, "f"), "f");
46
+ __classPrivateFieldSet(this, _Parser_tagNameCaseSensitive, options?.tagNameCaseSensitive ?? __classPrivateFieldGet(this, _Parser_tagNameCaseSensitive, "f"), "f");
47
+ __classPrivateFieldSet(this, _Parser_selfCloseType, options?.selfCloseType ?? __classPrivateFieldGet(this, _Parser_selfCloseType, "f"), "f");
48
+ __classPrivateFieldSet(this, _Parser_spaceChars, options?.spaceChars ?? __classPrivateFieldGet(this, _Parser_spaceChars, "f"), "f");
49
+ __classPrivateFieldSet(this, _Parser_rawTextElements, options?.rawTextElements ?? __classPrivateFieldGet(this, _Parser_rawTextElements, "f"), "f");
50
+ __classPrivateFieldSet(this, _Parser_defaultState, defaultState ?? null, "f");
51
+ this.state = structuredClone(__classPrivateFieldGet(this, _Parser_defaultState, "f"));
52
+ }
26
53
  get authoredElementName() {
27
54
  return __classPrivateFieldGet(this, _Parser_authoredElementName, "f");
28
55
  }
@@ -55,33 +82,6 @@ export class Parser {
55
82
  get tagNameCaseSensitive() {
56
83
  return __classPrivateFieldGet(this, _Parser_tagNameCaseSensitive, "f");
57
84
  }
58
- constructor(options, defaultState) {
59
- _Parser_instances.add(this);
60
- _Parser_booleanish.set(this, false);
61
- _Parser_defaultState.set(this, void 0);
62
- _Parser_endTagType.set(this, 'omittable');
63
- _Parser_ignoreTags.set(this, []);
64
- _Parser_maskChar.set(this, void 0);
65
- _Parser_tagNameCaseSensitive.set(this, false);
66
- _Parser_selfCloseType.set(this, 'html');
67
- _Parser_spaceChars.set(this, defaultSpaces);
68
- _Parser_rawTextElements.set(this, ['style', 'script']);
69
- _Parser_authoredElementName.set(this, void 0);
70
- _Parser_originalRawCode.set(this, '');
71
- _Parser_rawCode.set(this, '');
72
- _Parser_defaultDepth.set(this, 0);
73
- _Parser_walkMethodSequentailPrevNode.set(this, null);
74
- __classPrivateFieldSet(this, _Parser_booleanish, options?.booleanish ?? __classPrivateFieldGet(this, _Parser_booleanish, "f"), "f");
75
- __classPrivateFieldSet(this, _Parser_endTagType, options?.endTagType ?? __classPrivateFieldGet(this, _Parser_endTagType, "f"), "f");
76
- __classPrivateFieldSet(this, _Parser_ignoreTags, options?.ignoreTags ?? __classPrivateFieldGet(this, _Parser_ignoreTags, "f"), "f");
77
- __classPrivateFieldSet(this, _Parser_maskChar, options?.maskChar ?? __classPrivateFieldGet(this, _Parser_maskChar, "f"), "f");
78
- __classPrivateFieldSet(this, _Parser_tagNameCaseSensitive, options?.tagNameCaseSensitive ?? __classPrivateFieldGet(this, _Parser_tagNameCaseSensitive, "f"), "f");
79
- __classPrivateFieldSet(this, _Parser_selfCloseType, options?.selfCloseType ?? __classPrivateFieldGet(this, _Parser_selfCloseType, "f"), "f");
80
- __classPrivateFieldSet(this, _Parser_spaceChars, options?.spaceChars ?? __classPrivateFieldGet(this, _Parser_spaceChars, "f"), "f");
81
- __classPrivateFieldSet(this, _Parser_rawTextElements, options?.rawTextElements ?? __classPrivateFieldGet(this, _Parser_rawTextElements, "f"), "f");
82
- __classPrivateFieldSet(this, _Parser_defaultState, defaultState ?? null, "f");
83
- this.state = structuredClone(__classPrivateFieldGet(this, _Parser_defaultState, "f"));
84
- }
85
85
  tokenize(options) {
86
86
  return {
87
87
  ast: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/parser-utils",
3
- "version": "4.6.4",
3
+ "version": "4.6.6",
4
4
  "description": "Utility module for markuplint parser plugin",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -28,17 +28,17 @@
28
28
  "clean": "tsc --build --clean"
29
29
  },
30
30
  "dependencies": {
31
- "@markuplint/ml-ast": "4.4.1",
32
- "@markuplint/ml-spec": "4.6.2",
33
- "@markuplint/types": "4.5.2",
34
- "@types/uuid": "9.0.8",
35
- "debug": "4.3.5",
36
- "espree": "10.0.1",
37
- "type-fest": "4.20.0",
38
- "uuid": "9.0.1"
31
+ "@markuplint/ml-ast": "4.4.3",
32
+ "@markuplint/ml-spec": "4.6.4",
33
+ "@markuplint/types": "4.5.4",
34
+ "@types/uuid": "10.0.0",
35
+ "debug": "4.3.6",
36
+ "espree": "10.1.0",
37
+ "type-fest": "4.26.0",
38
+ "uuid": "10.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@typescript-eslint/typescript-estree": "7.12.0"
41
+ "@typescript-eslint/typescript-estree": "8.3.0"
42
42
  },
43
- "gitHead": "0200dc1f7b1ffa7455b889696153e25dbae8241f"
43
+ "gitHead": "77cd5a25d5cf28c83253b7bfe02cd25b54e236b0"
44
44
  }