Skip to content

Copy/paste behavior inside of a code block #92

@Aerowinder

Description

@Aerowinder

Context

Config - zensical.toml:

[project.markdown_extensions.pymdownx.superfences]
[project.markdown_extensions.pymdownx.inlinehilite]
[project.markdown_extensions.pymdownx.highlight]
anchor_linenums = true
line_spans = "__span"
linenums = true
pygments_lang_class = true
[project.markdown_extensions.admonition]
[project.markdown_extensions.pymdownx.details]
[project.markdown_extensions.attr_list]
[project.markdown_extensions.pymdownx.snippets]
[project.markdown_extensions.pymdownx.tabbed]
alternate_style= true

[project.theme]
features = [
  "content.code.annotate",
  "content.code.copy",
  "content.code.select",
  "content.tabs.link",
  "navigation.path",
  "navigation.external_links",
  "search.highlight",
  "search.suggest"
]

[[project.theme.palette]]
scheme = "default"
toggle.icon = "lucide/sun"
toggle.name = "Switch to dark mode"

[[project.theme.palette]]
scheme = "slate"
toggle.icon = "lucide/moon"
toggle.name = "Switch to light mode"

Config - extras.css

.md-grid {
    max-width: 95%;
}

.md-nav__title {
    display: none;
}

Bug description

If I press the copy button in my code block, it looks like this (correct):

groupadd --system zensical
useradd --system -g zensical -d /opt/zensical -s /usr/sbin/nologin zensical
install -d -o zensical -g zensical /opt/zensical
usermod -aG zensical newuser

If I instead select the code block text with my mouse and copy with Ctrl+C (or use the line selection function to do the same), it looks like this:

groupadd --system zensical
useradd
 --system -g zensical -d /opt/zensical -s /usr/sbin/nologin zensical
install
 -d -o zensical -g zensical /opt/zensical
usermod
 -aG zensical newuser

This has been happening I think since I swapped over from MkDocs. Which would have been.... 0.17, 0.18 maybe? Somewhere in there.

Related links

N/A

Reproduction

I am able to easily reproduce this every time I manually copy snippets from my code blocks.

Steps to reproduce

  1. Generate a code block
  2. Copy the text out of it with Ctrl+C
  3. Observe the added new lines where they don't belong.
  4. I can make some snippets available if required, but it would require some sanitation on my end prior to submission.

Browser

Firefox

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions