Copy Code Snippets While Preserving Hilighting

Is there a way to copy code snippets while preserving highlighting/coloring?

I can successfully copy the example code snippet from the side bar just by selecting it and hitting copy:
Selected:
image
Pasted:
image

However, I cannot figure out a way to do this with a regular code block, since once you click on it all of the highlighting disappears and it reverts to plain text. I have also tried selecting the nodes around it, using the one click export snippet, and using the export as formatted feature but none of these approaches work.