Code without clipboard

Hi

Two ticks in the markdown and we get <code> The code will have the clipboard next to it. Is is possible to deactivate the “copy to clipboard” in some cases? Bonus points for “code on one page with and without clipboard”. :wink:

Thanks in advance
Cheers
Nils

Okay, what I did now is this: In base.html.twig of my theme I deleted this line of code

{% do assets.addJs('theme://js/clipboard.min.js') %}

Now the JS that does the clipboard magic is no longer included. This works but it’s only an all-or-nothing solution. It would be nice to control whether the clip-board function is activated on code or not.

Maybe one of you has a better idea?

Best
Nils

Your suggestion worked perfectly and was exactly what I was looking for. I wanted to differentiate a few keywords using a monospace font and the copy-to-clipboard icon was a distraction. For just four keywords I was too lazy to create a CSS span class to do the same thing. Besides, the salmon-pink highlight is rather cool. :grinning:

Well, I’m kind of impressed :wink: I’d most likely just throw it into <pre>tag, so it would display as a monospace, but w/o all the code decorations :joy:
BTW, what theme are you using?

I’m using Paul Hibbits’ Learn2 Git Sync theme. My site is a document repository with several thousand pages of text, so being able to do the data entry and editing on my home computer and then syncing content through GitHub was a life-saver.

1 Like