Closed
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Affected packages and versions
1.2.4
Link to runnable example
https://stackblitz.com/edit/node-58lyzx?file=index.js
Steps to reproduce
import { remark as remarFactory } from 'remark';
import { visit } from 'unist-util-visit';
const remark = remarFactory();
// clean extra attributes that make it hard to see issue
function scrubber(tree) {
visit(tree, function (node) {
node.value = undefined;
node.position = undefined;
node.spread = undefined;
node.lang = undefined;
node.identifier = undefined;
node.label = undefined;
node.title = undefined;
node.url = undefined;
});
}
const content = `[a](<�>)`;
const originalAst = remark.parse(content);
const newContent = remark.stringify(originalAst);
const newAst = remark.parse(newContent);
scrubber(originalAst);
scrubber(newAst);
console.log(JSON.stringify(originalAst, null, 4));
console.log(JSON.stringify(newAst, null, 4));
results in
{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"children": [
{
"type": "text"
}
]
}
]
}
]
}
then
{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text"
}
]
}
]
}
Expected behavior
structure of document should remain the same
Actual behavior
link disappeared
Runtime
Node v16
Package manager
npm v7
OS
Linux
Build and bundle tools
No response