Skip to content

Highlighting specific lines adds blank lines when copying #3360

@squidfunk

Description

@squidfunk

Discussed in #3359

Originally posted by andrewetchen December 17, 2021
Hi everyone,

Using the copy-to-clipboard on code blocks with highlighted lines, extra lines are being added when pasted.

Using the highlighting specific lines Result as an example. The copy-to-clipboard produces extra lines when pasted:

image

Produces:

def bubble_sort(items):

    for i in range(len(items)):

        for j in range(len(items) - 1 - i):

            if items[j] > items[j + 1]:
                items[j], items[j + 1] = items[j + 1], items[j]

Current markdown_extensions

markdown_extensions:
  - admonition
  - attr_list
  - meta
  - pymdownx.details
  - pymdownx.highlight:
      linenums: true
  - pymdownx.inlinehilite
  - pymdownx.magiclink:
      repo_url_shortener: true
  - pymdownx.tabbed:
      alternate_style: true
  - pymdownx.superfences

Adding the following CSS is a workaround to get around this but not ideal:

.highlight .hll {
  display: inline;
}

Best regards,
Andrew

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