Skip to content
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

roundtrippping content causes definition to disappear #47

Closed
4 tasks done
ChristianMurphy opened this issue Nov 22, 2021 · 4 comments
Closed
4 tasks done

roundtrippping content causes definition to disappear #47

ChristianMurphy opened this issue Nov 22, 2021 · 4 comments
Labels
💪 phase/solved Post is done

Comments

@ChristianMurphy
Copy link
Member

Initial checklist

Affected packages and versions

1.2.4

Link to runnable example

https://stackblitz.com/edit/node-st1b3g?file=index.js

Steps to reproduce

Run

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));

result is:

{
    "type": "root",
    "children": [
        {
            "type": "definition"
        }
    ]
}

then

{
    "type": "root",
    "children": [
        {
            "type": "paragraph",
            "children": [
                {
                    "type": "text"
                }
            ]
        }
    ]
}

and the output text is

[a]: 

Expected behavior

definition content is preserved

Actual behavior

definition content disapepars

Runtime

Node v16

Package manager

npm v7

OS

Linux

Build and bundle tools

No response

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Nov 22, 2021
@ChristianMurphy
Copy link
Member Author

also happens with

[a]

[a]: 

@ChristianMurphy
Copy link
Member Author

@wooorm wooorm closed this as completed in a57b805 Nov 23, 2021
@github-actions

This comment has been minimized.

@wooorm wooorm added the 💪 phase/solved Post is done label Nov 23, 2021
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Nov 23, 2021
@wooorm
Copy link
Member

wooorm commented Nov 23, 2021

released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done
Development

No branches or pull requests

2 participants