Preserve unchanged Markdown when saving changes in the Content Editor
Problem
The Content Editor forgets all the formatting preferences of a Markdown file when saving changes. This is because the Content Editor re-generates the entire Markdown source from the Markdown API output instead of only generating Markdown for the parts of the file that were edited in the editor.
Proposal
We have to preserve the formatting preferences of the Markdown source that the user hasn’t edited in the Content Editor.
Potential solutions
There are two paths we can explore to address this problem.
AST comparison
Two Markdown files with the same content but different formatting preferences will generate the same Abstract Syntax Tree (AST). The Content Editor could compare the AST of the original source file and the AST of the source generated by the editor itself. If two nodes in both ASTs are equal, the Content Editor can choose the source code of the original source file for that node.
Allow targeting blocks of a Markdown file
This solution re-designs the editing experience of Markdown files to only load specific blocks of the file into the Content Editor instead of the entire file. A Markdown AST allows us to identify which block the Content Editor should replace when saving changes to the original source.