WordPress / WordPress/gutenberg

Markdown syntax is incorrectly parsed in post title field, when pasting

Open Beginner friendly
#78,956 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

[Feature] Paste [Type] Bug
Dominant language
JavaScript
Stars
11.8k
Forks
4.9k
PR merge metrics
PR metrics pending

Description

Description

Pasting text containing Markdown syntax (e.g. #) into the post title field results in loss of the original characters due to unintended Markdown conversion.

Step-by-step reproduction instructions
  1. Create a new post.
  2. Click into the post title field. Open the browser console
  3. Paste the following text:
    # 3 reason why

Expected Behavior

The title field should treat input as plain text and preserve all characters exactly as pasted

Actual Behavior

The pasted text is interpreted as Markdown and converted into a heading

Console
Received HTML (pasteHandler):

 <html>
<body>
<!--StartFragment--><span style="color: rgb(255, 255, 255); font-family: &quot;Monaspace Neon&quot;, ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 11.9px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: break-spaces; background-color: rgb(33, 40, 48); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"># 3 reason why</span><!--EndFragment-->
</body>
</html>
paste-handler.ts:40 Received plain text (pasteHandler):

 # 3 reason why
paste-handler.ts:40 Processed HTML piece:

 <h1>3 reason why</h1>
Screenshots, screen recording, code snippet

No response

Environment info

WP 7.0, default GB editor, TT5, GeneratePress
Chromium, Win 10

Please confirm that you have searched existing issues in the repo.
  • Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
  • Yes
Please confirm which theme type you used for testing.
  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with paste-handler.ts and reproduce the issue by pasting the provided Markdown-like title into the post title field. Trace how the pasted plain text becomes an h1, then verify that the title preserves the # characters exactly and is no longer converted to Markdown.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.