8000 Code copy button adds new line · Issue #6327 · squidfunk/mkdocs-material · GitHub
[go: up one dir, main page]

Skip to content

Code copy button adds new line #6327

@maxsitt

Description

@maxsitt

Context

No response

Bug description

Currently, when copying code with the code copy button, a new line is automatically added when pasting the copied code somewhere else. This does not happen if the code is copied manually by selecting everything in the code block.

Especially when copying code that should be run in a Terminal/command prompt, the new line that is automatically added when copying the code with the code copy button can lead to problems in some cases, e.g. code is run immediately when pasting. Expected behaviour of the code copy button should be exactly the same as for copying code manually: copy only the content in the code block without adding a new line.

Related links

Reproduction

9.4.8-code-copy-button.zip

Steps to reproduce

  1. Create new mkdocs project with all required packages up to date (2023-11-13).
  2. Add the code copy button feature to the mkdocs.yml:
    theme:
      name: material
      features:
      - content.code.copy
    
  3. Add a code block in index.md.
  4. From the served/built site, copy the code manually by selecting the content in the code block and paste it to an empty text document: no new line is added.
  5. Copy the code with the code copy button: a new line is added.

Browser

No response

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0