Code blocks with markdown syntax have a Copy Formatted button.
To access it, mouse over the dark blue box.
A blue file icon will appear on the right side.
You can click it to copy the box's content.
Your clipboard will now paste pre-formatted content.