Preserve unchanged Commonmark blocks
What does this MR do and why?
Context: These changes are behind the feature flag preserve_unchanged_markdown
It uses Markdown source maps to preserve parts of a Markdown document that aren’t changed by the user in the Content Editor. Why do we need to do this? In Markdown, you can apply the same format using different syntax, i.e.
Heading 1
===
# Heading 1
**Bold text** or __bold text__ or <strong>bold text</strong>
1. List item 1
1) List item 1
All the examples above represent equivalent formatting elements applied using different syntax. Before this change, the Content Editor couldn’t preserve the original syntax of a Markdown document. This change enables source preservation for a subset of GitLab Flavored Markdown features.
NOTICE: This MR doesn’t implement source preservation for inline elements yet. In other words, if you change a paragraph, the entire paragraph will be re-generated. We will implement an improvement that allows preserving segments of a paragraph.
Screenshots or screen recordings
Before this change | After this change |
---|---|
![]() |
![]() |
How to set up and validate locally
- Enable the
preserve_unchanged_markdown
feature flag. - Edit or create a Wiki page.
- Try one of the Markdown examples above where different syntax yield the same result.
- When you switch between source and rich text modes, if you don’t change anything in the Content Editor, the original Markdown syntax should be preserved.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #359019 (closed)