As per the content stack documentation here and the best practices for Markdowns here, headings shouldn't be followed by a # and there should be a space b/w the hash prefix and the headings. But the jsonToMarkdown is not following those best practices.
For example, the following test should pass but it's not:
const input = {
type: "doc",
children: [
{
type: "h1",
children: [{ text: "This is a heading" }],
},
],
};
const result = jsonToMarkdown(input);
expect(result.trim()).toBe("# This is a heading"); // Doesn't pass
expect(result.trim()).not.toBe("#This is a heading#"); // Doesn't pass