Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easy way to add 'copy to clipboard' to GitHub markdown?

Specifically, I have blocks of code for install that I want the user to be able to quickly copy and paste into a terminal. I'd like a button to 'copy to clipboard' for the code block. Since there's a 'copy to clipboard' button for the git clone URLs, I was wondering if I could piggy back off that or if not whether there was some relatively simple I could add to the MD to make this happen. Or is this simply not possible with the processing and 'safication' the MD text goes through?

like image 221
zanerock Avatar asked Aug 09 '15 20:08

zanerock


People also ask

How do you copy an image in markdown?

Copy an image. Hit ctrl+alt+v to paste image to markdown document.

How do you add a code block in Markdown?

The basic Markdown syntax allows you to create code blocks by indenting lines by four spaces or one tab. If you find that inconvenient, try using fenced code blocks. Depending on your Markdown processor or editor, you'll use three backticks ( ``` ) or three tildes ( ~~~ ) on the lines before and after the code block.


1 Answers

The copy button is now a reality (May 2021), as tweeted by Nat Friedman

We just added a "Copy" button to all code blocks on GitHub.

Copy

like image 53
VonC Avatar answered Sep 22 '22 15:09

VonC