-
-
Notifications
You must be signed in to change notification settings - Fork 156
feat(@textlint/ast-node-types): add missing LinkReference
, ImageReference
and Definition
node types
#1459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…, and `Definition` Node types
LinkReference
, ImageReference
and Definition
Node typesLinkReference
, ImageReference
and Definition
node types
LinkReference
, ImageReference
and Definition
node typesLinkReference
, ImageReference
and Definition
node types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR adds support for the missing AST node types—LinkReference, ImageReference, and Definition—to ensure that @textlint/ast-node-types fully reflects the nodes produced by the AST.
- Updated TypeofTxtNode.ts to include mappings for LinkReference, ImageReference, and Definition nodes (with their respective "exit" types).
- Extended NodeType.ts and ASTNodeTypes.ts with new interface definitions and enum values.
- Updated test files and documentation to cover the new node types.
Reviewed Changes
File | Description |
---|---|
packages/@textlint/ast-node-types/src/TypeofTxtNode.ts | Adds node type mappings for LinkReference, ImageReference, and Definition nodes |
packages/@textlint/ast-node-types/src/NodeType.ts | Introduces new interfaces for TxtLinkReferenceNode, TxtImageReferenceNode, and TxtDefinitionNode, including the TxtReference mixin |
packages/@textlint/ast-node-types/src/ASTNodeTypes.ts | Updates enum values to include the new node types |
packages/@textlint/types/test/Rule/TxtNode-test.ts | Adds test cases to validate the type mappings for the new node types |
packages/@textlint/ast-node-types/src/index.ts | Exports the newly added node types |
docs/txtnode.md | Updates documentation to reflect the newly supported AST node types |
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
I didn't include LinkReference, ImageReference, etc. because they are unique features of Markdown. I'll have to think a bit more about whether it would be a breaking change. If it is, we might want to bring it out with the next major version. |
@azu, thanks for your response! Actually, I’ve developed a rule called
Regarding your comment, I believe that adding more types won’t cause any breaking changes. Since these types weren’t implemented in earlier versions of Textlint, adding them now won’t break existing builds—it’s simply a feature request. Moreover, the README states that adding a new type is considered a minor change. Additionally, Textlint is already able to access This means that previous users who have used these nodes won’t experience any build-breaking issues. I really hope this feature will be included in the next minor update! If you have any other opinions, please feel free to let me know! |
…ence-imagereference-and-definition-node-types
OK, Thanks for details.
I was thinking there might be an implementation like https://github.com/search?q=Object.keys%28ASTNodeTypes%29&type=code&ref=simplesearch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@azu Hello,
Thank you for your hard work and contributions to open source!
In this PR, I've added
LinkReference
,ImageReference
, andDefinition
node types to@textlint/ast-node-types
.Rationale
Please take a look at the AST Tree of this example.
You'll notice that the AST includes
LinkReference
,ImageReference
, andDefinition
nodes, but they are missing from@textlint/ast-node-types
.LinkReference
ImageReference
Definition
Since these node types exist in the AST but are missing from
@textlint/ast-node-types
, I believe adding them will improve consistency and support for processing these structures.Looking forward to your feedback!