How to copy text with markup from codemirror editor to other application

Copying from CodeMirror only copies the plain text. The highlighting is purely a display issue, the content is treated as just text. You could use something like the runmode addon to create a syntax highlighted view that the user can copy from, but that won’t be editable.