Wouldn't it be cool to right click anywhere in a code block and have the option "copy code block to clipboard"?
I now programmed this Greasemonkey script for Firefox to add a 'select code' text below every
pre tag. If clicked the tag content will be selected and the user can copy it using CTRL+C or similar.
It looks like this:
I have created another Greasemonkey (Firefox) / Tampermonkey (Chrome) script that use clipboard.js.
When you hover a code section (
<pre><code>) there is a small
</> sign that appears on the top right corner of the script. You click it and voilà !
The code is available on this Gist.
How to use it :
- Install Greasemonkey (Firefox) / Tampermonkey (Chrome) for your browser.
- Read the code in the Gist (if you do not understand some code, do not install it) ! Click on the raw version of the gist.
- Install it.
Edit : I have created a second version. In the first version the button is not visible if the code is scrolled down. In the second version it stays visible ... and it has a different appearance (more
\tex one ;)).