Copy to clipboard button

It could be very useful to have a copy to clipboard button optionally attached to inline code blocks. Something like:

`contents`[copy]

This is more of a feature in Discourse, I have enabled show copy button on codeblocks and it should be visible now:

public class HelloWorld
{
	public static void main(String[] args) {
		System.out.println("Hello World!");
	}
}
1 Like

There’s the question of whether a “copy to clipboard” button should be part of the spec since it’s used for application behaviour rather than the actual content of the document. Enabling the button in an application setting (as with Discourse) might be sufficient.

I would also question whether you would want this button enabled for some code blocks/spans and not others in the same document; it feels like a general behaviour rather than a specific behaviour. General behaviour could be toggled via Jekyll-style metadata if you wanted it to be portable between applications.