Filter to normalize Markdown?

A bunch of our content comes from Pandoc. This causes a couple of problems with edits. The first edit with Netlify CMS creates a big pull request that’s almost all reformatting of Markdown. Also, the Markdown occasionally converts to something that doesn’t render right in Hugo.

To avoid problems like this, is there a way to run the content from Pandoc through a filter to normalize it for the Markdown flavor that the Markdown editor in Netlify CMS uses?

Can remark-stringify help here? Something else?

If we had a filter that could normalize the Markdown, we could include that in our Pandoc conversion pipeline.

Welcome to the Netlify community forums! I believe remark-stringify is being used internally, so that may be a good approach. Perhaps @erez can shed some light on the matter.

I gave it a quick go, and it seems like the right approach. I’ll need to make the settings match.

I have zero experience with remark myself but this might be a nudge in the right direction?

1 Like

That approach seems good to me.
Since netlify-cms-widget-markdown is a separate npm package you might be able to install it and used the exported functions directly.

I tried directly using netlify-cms-widget-markdown. That way should provide the best compatibility, but I had problems. That is a webpack package (ECMAScript modules), but I’m trying to use it directly in node (calling CommonJS modules). My JavaScript/node skills were not up to this. I tried using esm but got many errors. For now, it looks like I’ll extract a subset from that widget.