Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce option for hljs-meta tags to not be user-selectable. #372

Open
sg495 opened this issue Dec 15, 2021 · 3 comments
Open

Introduce option for hljs-meta tags to not be user-selectable. #372

sg495 opened this issue Dec 15, 2021 · 3 comments

Comments

@sg495
Copy link

sg495 commented Dec 15, 2021

Currently, the >>> and ... in Python REPL snippets are selectable in HTML docs (much as they are here, on Github):

>>> mylist = [
... 0, 1, 2, 3,
... 4, 5, 6, 7
... ]
>>> mylist
[0, 1, 2, 3, 4, 5, 6, 7]

This is inconvenient for people wanting to copy-paste the code, e.g. to reproduce the results: they have to manually remove the >>> and .... Lately, I've noticed snippets on Read the Docs where the >>> and ... are conveniently excluded from the selection. I have looked at the CSS of this snippet, and adding the following to css.mako seems to do the trick:

  .hljs-meta {
    user-select: none;
    pointer-events: none;
  }

I'm not sure about the impact of making hljs-meta tags not user-selectable across the board, but to me this seems sufficiently useful a feature to at least deserve a config entry. If this needs further investigation, I'm happy to have a deeper look and make a pull request 😄.

@sg495
Copy link
Author

sg495 commented Dec 15, 2021

On Firefox 95.0, the hljs-meta spans are replaced with blank lines when the text is copied (this also happens in the Read the Docs snippet I linked previously, so I think it's an issue with user-select: none, perhaps specifically inside HTML <code> tags). On latest Chrome/Edge it works fine.

I tried the following, but it doesn't fix this issue on Firefox:

  .hljs-meta {
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    pointer-events: none;
  }

I'll investigate further.

@kernc
Copy link
Member

kernc commented Dec 15, 2021

I don't mind using above snippet (the one without vendor prefixes). Some blank lines (BMO#1273836) are still better than nothing. PR welcome.

@sg495 sg495 closed this as completed Jan 15, 2022
@kernc
Copy link
Member

kernc commented Jan 15, 2022

Is there an issue with making .hljs-meta tags not user-selectable as you proposed? I think it a legitimate request, and it should find its way into the codebase eventually. 😄

@kernc kernc reopened this Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants