1

I am using Markdown to compose posts for a static blog, generated by Pelican and hosted on Bitbucket. Markdown, processed by Pygments, allows me to turn on automatic line-numbering of my code by placing #!python (or whatever language name I like) at the beginning of a code block.

But in the HTML that is output and viewed in a browser, those line numbers can be selected by the user, which makes it hard to copy and paste my code.

What do I need to do do make the line numbers unselectable while leaving the code itself selectable?

brannerchinese
  • 1,909
  • 5
  • 24
  • 40

1 Answers1

2

Ah, shucks — I've just found it, right after posting. It's a CSS solution, applying

user-select: none;

to the class governing the line numbers in my code blocks. There are various browser-specific variants, too:

-moz-user-select: none;
-webkit-user-select: none;

et cetera.

brannerchinese
  • 1,909
  • 5
  • 24
  • 40