@markuplint/parser-utils 4.5.1 → 4.6.1-alpha.0

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 ADDED
@@ -0,0 +1,8 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [4.6.1-alpha.0](https://github.com/markuplint/markuplint/compare/@markuplint/parser-utils@4.6.0...@markuplint/parser-utils@4.6.1-alpha.0) (2024-05-04)
7
+
8
+ **Note:** Version bump only for package @markuplint/parser-utils
package/lib/debugger.js CHANGED
@@ -62,7 +62,7 @@ function tokenDebug(n, type = '') {
62
62
  }
63
63
  return `[${n.startLine}:${n.startCol}]>[${n.endLine}:${n.endCol}](${n.startOffset},${n.endOffset})${
64
64
  // @ts-ignore
65
- n.potentialName ?? n.nodeName ?? n.name ?? n.type ?? type}${'isGhost' in n && n.isGhost ? '(👻)' : ''}${'isBogus' in n && n.isBogus ? '(👿)' : ''}: ${visibleWhiteSpace(n.raw)}`;
65
+ n.potentialName ?? n.nodeName ?? n.name ?? n.type ?? type}${'isGhost' in n && n.isGhost ? '(👻)' : ''}${'isBogus' in n && n.isBogus ? '(👿)' : ''}${'conditionalType' in n && n.conditionalType ? ` (${n.conditionalType})` : ''}: ${visibleWhiteSpace(n.raw)}`;
66
66
  }
67
67
  function visibleWhiteSpace(chars) {
68
68
  return chars.replaceAll('\n', '⏎').replaceAll('\t', '→').replaceAll(/\s/g, '␣');
@@ -73,6 +73,7 @@ ignoreBlock, throwErrorWhenTagHasUnresolved = true) {
73
73
  const psNode = {
74
74
  ...token,
75
75
  type: 'psblock',
76
+ conditionalType: null,
76
77
  depth: node.depth,
77
78
  nodeName: `#ps:${tag.type}`,
78
79
  parentNode: node.parentNode,
@@ -102,6 +103,7 @@ ignoreBlock, throwErrorWhenTagHasUnresolved = true) {
102
103
  const psNode = {
103
104
  ...token,
104
105
  type: 'psblock',
106
+ conditionalType: null,
105
107
  depth: node.depth,
106
108
  nodeName: `#ps:${tag.type}`,
107
109
  parentNode: node.parentNode,
package/lib/parser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Token, ChildToken, QuoteSet, ParseOptions, ParserOptions, Tokenized, ValueType } from './types.js';
2
- import type { EndTagType, MLASTDocument, MLASTParentNode, MLParser, ParserAuthoredElementNameDistinguishing, MLASTElement, MLASTElementCloseTag, MLASTToken, MLASTNodeTreeItem, MLASTTag, MLASTText, MLASTAttr, MLASTChildNode, MLASTSpreadAttr, ElementType, Walker, MLASTHTMLAttr } from '@markuplint/ml-ast';
2
+ import type { EndTagType, MLASTDocument, MLASTParentNode, MLParser, ParserAuthoredElementNameDistinguishing, MLASTElement, MLASTElementCloseTag, MLASTToken, MLASTNodeTreeItem, MLASTTag, MLASTText, MLASTAttr, MLASTChildNode, MLASTSpreadAttr, ElementType, Walker, MLASTHTMLAttr, MLASTPreprocessorSpecificBlockConditionalType } from '@markuplint/ml-ast';
3
3
  import { AttrState } from './enums.js';
4
4
  import { ParserError } from './parser-error.js';
5
5
  export declare abstract class Parser<Node extends {} = {}, State extends unknown = null> implements MLParser {
@@ -71,7 +71,7 @@ export declare abstract class Parser<Node extends {} = {}, State extends unknown
71
71
  }): readonly MLASTNodeTreeItem[];
72
72
  visitPsBlock(token: ChildToken & {
73
73
  readonly nodeName: string;
74
- }, childNodes?: readonly Node[], originBlockNode?: Node): readonly MLASTNodeTreeItem[];
74
+ }, childNodes?: readonly Node[], conditionalType?: MLASTPreprocessorSpecificBlockConditionalType, originBlockNode?: Node): readonly MLASTNodeTreeItem[];
75
75
  visitChildren(children: readonly Node[], parentNode: MLASTParentNode | null): readonly MLASTNodeTreeItem[];
76
76
  visitSpreadAttr(token: Token): MLASTSpreadAttr | null;
77
77
  visitAttr(token: Token, options?: {
package/lib/parser.js CHANGED
@@ -308,11 +308,12 @@ export class Parser {
308
308
  }
309
309
  return [startTag, ...siblings];
310
310
  }
311
- visitPsBlock(token, childNodes = [], originBlockNode) {
311
+ visitPsBlock(token, childNodes = [], conditionalType = null, originBlockNode) {
312
312
  const block = {
313
313
  ...token,
314
314
  ...this.createToken(token),
315
315
  type: 'psblock',
316
+ conditionalType,
316
317
  nodeName: `#ps:${token.nodeName}`,
317
318
  childNodes: [],
318
319
  isBogus: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/parser-utils",
3
- "version": "4.5.1",
3
+ "version": "4.6.1-alpha.0",
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>",
@@ -27,17 +27,17 @@
27
27
  "clean": "tsc --build --clean"
28
28
  },
29
29
  "dependencies": {
30
- "@markuplint/ml-ast": "4.2.0",
31
- "@markuplint/ml-spec": "4.4.1",
32
- "@markuplint/types": "4.3.0",
30
+ "@markuplint/ml-ast": "4.3.1-alpha.0",
31
+ "@markuplint/ml-spec": "4.5.1-alpha.0",
32
+ "@markuplint/types": "4.4.1-alpha.0",
33
33
  "@types/uuid": "9.0.8",
34
34
  "debug": "4.3.4",
35
35
  "espree": "10.0.1",
36
- "type-fest": "4.15.0",
36
+ "type-fest": "4.18.1",
37
37
  "uuid": "9.0.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@typescript-eslint/typescript-estree": "7.7.0"
40
+ "@typescript-eslint/typescript-estree": "7.8.0"
41
41
  },
42
- "gitHead": "b029c86a6b3a9ea8189d2e5535e3023aaea753fd"
42
+ "gitHead": "d091e2199e3dc6757c2c8edbf01fd19e8b072015"
43
43
  }