Repository navigation
Block Library: Parse Markdown when converting Classic blocks - #79958
Mustafabharmal wants to merge 1 commit into
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
I am closing this PR as I notice that the file where I have worked for this issue is removed, So will be creating the new changes to different file. PR that removed packages/block-library/src/freeform/migration-notice.js #79894 |
What?
Closes #79871.
Updates the Classic block's Convert to blocks action so Markdown content is correctly converted into Gutenberg blocks instead of being preserved as literal Markdown inside a Paragraph block.
Why?
Markdown content inserted outside the editor (for example using WP-CLI) is loaded into a Classic block when the post is opened in Gutenberg.
When the user clicks Convert to blocks, the current conversion flow treats the content as HTML and bypasses Gutenberg's Markdown conversion, resulting in content such as:
being converted into a Paragraph block containing the literal Markdown rather than a Heading block.
The issue is limited to the Classic block conversion flow.
How?
This PR updates the Classic block migration action to reuse Gutenberg's existing Markdown conversion flow.
Before passing the content to
pasteHandler, the automatic paragraph wrappers generated by the Classic editor are removed using the existingremoveputility from@wordpress/autop. The resulting plain text is then passed topasteHandlerinBLOCKSmode, allowing Gutenberg's existing Markdown parser to generate the appropriate blocks.This keeps the implementation minimal by reusing existing utilities instead of introducing any custom Markdown parsing logic.
Testing Instructions
Additional testing
Verify list conversion. Create another post:
Repeat the conversion steps above.
Verify the content is converted into a List block.
Screenshots or screencast
Before:
## Radiohead rocksbecomes a Paragraph blockBefore.Markdown.Fix.mov
After:
## Radiohead rocksbecomes a Heading blockAfter.Markdown.Fix.mov