In rich text editor, links are over-zealously escaped in the resulting markdown on save
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Work on this issue](https://contributors.gitlab.com/manage-issue?action=work&projectId=278964&issueIid=346846) - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=346846) </details> <!--IssueSummary end--> ## Problem to solve As reported in https://gitlab.com/gitlab-org/gitlab/-/issues/332629#note_745539518, Cyrillic characters written in the Content Editor or read from existing pages get replaced with URL-encoded strings. ### Steps to reproduce 1. Using the plain text editor, add the following markdown to a comment or an issue: ```md # пример заголовка [link to this header](#пример-заголовка) ``` 2. Switch to rich text editor. Change the link text to something else. 3. Switch back to plain text editor. 4. Notice the URL in the link is escaped ```md # пример заголовка [link to this header](#%D0%BF%D1%80%D0%B8%D0%BC%D0%B5%D1%80-%D0%B7%D0%B0%D0%B3%D0%BE%D0%BB%D0%BE%D0%B2%D0%BA%D0%B0) test ``` ### Video ![CleanShot 2025-04-10 at 18.19.49.mp4](https://gitlab.com/-/project/278964/uploads/05b877ad1083fd099eb93575362965eb/CleanShot_2025-04-10_at_18.19.49.mp4) ### Implementation guide In [`app/assets/javascripts/content_editor/services/serialization_helpers.js`](https://gitlab.com/gitlab-org/gitlab/-/blob/85b7e2e8c1cd2a145c7901f0f1ff31338311cf30/app/assets/javascripts/content_editor/services/serialization_helpers.js#L667), lines 660 and 667, we use `state.esc` to escape the URL of the link when serializing prosemirror content to markdown. This was copied from original implementation of [`prosemirror-markdown`](https://github.com/ProseMirror/prosemirror-markdown), but [that implementation has since changed](https://github.com/ProseMirror/prosemirror-markdown/commit/8e456de723a64a05de6d6dbe110b24d395eff316). We need to remove `state.esc` instances mentioned above, and do an implementation [similar to upstream](https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L133). Tests need to be added/updated in [`spec/frontend/content_editor/services/markdown_serializer_spec.js`](https://gitlab.com/gitlab-org/gitlab/-/blob/85b7e2e8c1cd2a145c7901f0f1ff31338311cf30/spec/frontend/content_editor/services/markdown_serializer_spec.js).
issue