Skip to content

Improve pasted code handling and language mismatch feedback #514

Description

@code-snippets-bot

Feature request

Forum topic: https://wordpress.org/support/topic/dealing-with-extra-opening-closing-main-code-tags-included-in-the-snippet/

When users paste code into a snippet, the editor should handle language wrapper tags that the selected snippet type already supplies.

Requested behaviour

  • Detect and strip matching opening and closing wrapper tags when code is pasted, such as PHP, CSS, and JavaScript tags.
  • Show an informative warning when pasted code appears to use a different language from the selected snippet type.
  • Make the warning clear before save, so users understand why the snippet cannot be saved or run.

Acceptance criteria

  • Pasting code with matching outer wrapper tags stores only the code body.
  • Pasting code that appears to be for a different snippet language shows a visible, actionable warning.
  • Existing valid code pastes are unchanged.

Related work

The request for a clear notice when a snippet action fails is also covered by #488.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions