You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to create a custom transform on "link" nodes to support adding additional custom attributes and in doing so, I noticed that the title attribute declared in markdown was never returned when calling Markdoc.parse.
In the Commonmark spec, link-titles can be declared with the following syntax:
[link](/uri "title")
When running the parse function on a link with this syntax, however, only the href attribute is returned. No title attribute is ever returned from the parser.
Based on the documentation for link node, I expected href and optionally the title attribute to be available in the node attributes when the markdown is parsed.
To reproduce
The issue can be reproduced by running the following file.
importMarkdoc,{Node}from"@markdoc/markdoc";functionprintNodeAttributes(ast: Node){if(ast.type==="link"){console.log(`Node type: ${ast.type}`);console.log(`Node attributes: ${JSON.stringify(ast.attributes)}`);}if(ast.children){ast.children.forEach((child)=>printNodeAttributes(child));}}consttestLink=`[Markdoc](https://markdoc.io "markdoc link title")`;constast=Markdoc.parse(testLink);printNodeAttributes(ast);
The output is
Node type: link
Node attributes: {"href":"https://markdoc.io"}
I was expecting
Node type: link
Node attributes: {"href":"https://markdoc.io", title: "markdoc link title"}
What happened?
I was trying to create a custom transform on "link" nodes to support adding additional custom attributes and in doing so, I noticed that the title attribute declared in markdown was never returned when calling Markdoc.parse.
In the Commonmark spec, link-titles can be declared with the following syntax:
[link](/uri "title")
When running the parse function on a link with this syntax, however, only the href attribute is returned. No title attribute is ever returned from the parser.
Based on the documentation for link node, I expected href and optionally the title attribute to be available in the node attributes when the markdown is parsed.
To reproduce
The issue can be reproduced by running the following file.
The output is
I was expecting
Version
0.1.1
Additional context
It looks like the source of the issue may be here
It looks like the handleAttrs function is only returning href for link nodes.
The text was updated successfully, but these errors were encountered: