Skip to content

Raw Handler: Handle presence of both markdown and block markup when pasting#70093

Open
karthikeya-io wants to merge 1 commit intoWordPress:trunkfrom
karthikeya-io:fix/paste-handler
Open

Raw Handler: Handle presence of both markdown and block markup when pasting#70093
karthikeya-io wants to merge 1 commit intoWordPress:trunkfrom
karthikeya-io:fix/paste-handler

Conversation

@karthikeya-io
Copy link
Copy Markdown
Contributor

@karthikeya-io karthikeya-io commented May 9, 2025

What?

Closes: #70065

The PR handles the presence of both markdown and block markup when pasting.

Why?

Currently, when content containing both Markdown and block markup is pasted, it doesn’t parse as expected.
Example

```
<!-- wp:pattern {"slug":"twentytwentyfive/header"} /-->

```

The block markup inside the fenced code block is incorrectly rendered as content, rather than being treated as code.

How?

The pasted content is now passed through a Markdown-to-HTML converter before block parsing begins. Additionally, After parsing any classic content is converted to blocks using the rawHandler.
This allows mixed content to be parsed correctly. For instance:

<!-- wp:pattern {"slug":"twentytwentyfive/header"} /-->
# Some heading
```
<!-- wp:pattern {"slug":"twentytwentyfive/header"} /-->
```

Testing Instructions

  1. Open a post
  2. Paste content containing a mix of Markdown and block markup to match format (cmd/ctrl + shift + v). Example:
<!-- wp:pattern {"slug":"twentytwentyfive/header"} /-->
# Some heading
```
<!-- wp:pattern {"slug":"twentytwentyfive/header"} /-->
```
  1. Confirm that:
  • The block markup outside the code block is parsed into blocks.
  • The block markup inside the fenced code block is preserved as code and not parsed as a block.

Testing Instructions for Keyboard

Screenshots or screencast

Before After
image image

@karthikeya-io karthikeya-io marked this pull request as ready for review May 12, 2025 08:03
@github-actions
Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: karthikeya-io <karthikeya01@git.wordpress.org>
Co-authored-by: jonathanbossenger <psykro@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Feature] Blocks Overall functionality of blocks [Feature] Paste [Package] Blocks /packages/blocks and removed [Feature] Blocks Overall functionality of blocks labels May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Paste [Package] Blocks /packages/blocks [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pasting Markdown as plain text that contains Block markup in the fenced code blocks syntax causes an error

2 participants