Skip to content

Formatting API: Code block should disallow formats #48116

@codebykat

Description

@codebykat

Description

Formatting such as bold, italic, etc should not be run within code blocks. As we discussed internally, we are customizing a version of the code block to add __unstableDisableFormats to its RichText component, but this should probably be incorporated into this repository as well. We haven't been able to come up with a compelling use-case for allowing formatting within code blocks, and once you add Markdown-as-you-type it becomes very likely that text within code blocks gets formatted when it shouldn't (underscores, etc.).

Related discussion at pdr0wL-10Y-p2

Step-by-step reproduction instructions

  1. Have a code block
  2. Observe that you are able to format text within it, though that doesn't make sense semantically

Screenshots, screen recording, code snippet

No response

Environment info

Standalone Gutenberg (block-editor package)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions