Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hex codes and #Hashtags incorrectly parsed and stripped as Markdown headers #69221

Open
3 of 6 tasks
im3dabasia opened this issue Feb 17, 2025 · 2 comments · May be fixed by #69229
Open
3 of 6 tasks

Hex codes and #Hashtags incorrectly parsed and stripped as Markdown headers #69221

im3dabasia opened this issue Feb 17, 2025 · 2 comments · May be fixed by #69229
Assignees
Labels
[Feature] Paste [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@im3dabasia
Copy link
Contributor

im3dabasia commented Feb 17, 2025

Description

Hex color codes like #ffffff and hashtags used in social media (e.g., #Hashtag) are incorrectly parsed by the editor.

The expected behavior is that hex color codes and hashtags should remain intact as plain text without the # being stripped.

Investigation:

When text with # (like #ffffff) is pasted, it is first treated as a header due to the # prefix. This results in incorrect HTML (<h1>ffffff</h1>). Since the content is processed with inline: true, the system later attempts to correct this by stripping the <h1> tag, leaving only the text inside. As a result, the final output is <p>ffffff</p>, with the # completely removed.

Step-by-step reproduction instructions

  1. Paste a hex color code like or a hashtag like #Hashtag into the editor.
  2. Notice that the # is missing.

Screenshots, screen recording, code snippet

Screen.Recording.2025-02-17.at.6.14.06.PM.mov

Related snippets:

This is the place where the incorrect text is generated.

export default function markdownConverter( text ) {
return converter.makeHtml(
slackMarkdownVariantCorrector( bulletsToAsterisks( text ) )
);
}

Environment info

No response

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
@im3dabasia im3dabasia added the [Type] Bug An existing feature does not function as intended label Feb 17, 2025
@Takshil-Kunadia
Copy link
Contributor

Hi @im3dabasia @Mamaduka . I would like to take up this issue.

@Takshil-Kunadia
Copy link
Contributor

Takshil-Kunadia commented Feb 18, 2025

In the ShowdownJS implementation used here, I came across documentation that mentions an option requireSpaceBeforeHeadingText to enforce a mandatory space between the # symbol and the heading text.

ref: ShowdownJS docs

On enabling this,
If a hex value is pasted(with no space), it retains the #.

1739855513192526.mp4

If a value with a space is pasted, it behaves as expected.

1739855543722253.mp4

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Paste [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants