Syntax highlighting, do not copy line numbers when copying code

Hi!

I would like to have a numbered block code, but one that a user can copy-paste without the numbers this time. I am using the default syntax highlighting engine (Pygments).

Here is an example of code:

{{< highlight LaTeX "linenos=inline">}}
\documentclass[11pt,usenames,dvipsnames]{beamer}
\usetheme{CambridgeUS}
\usecolortheme{dolphin}
{{< / highlight >}}

Do you know how to do this?

Thanks!
Raphaël

Any solution to this? Thanks

If you switch to "linenos=table"the numbers are not within your selected lines, so copying is easy enough. You could also then use css and make your first column nonselectable.

If you want to stick with the inline, you could change the settings of the syntax highlighter to pygmentsUseClasses=true and again use css to prevent text selection of the ln class.

1 Like