# Get highlighted code

**URL:** https://discuss.codemirror.net/t/get-highlighted-code/637
**Category:** Uncategorized
**Created:** [February 4, 2016, 2:23pm UTC](https://discuss.codemirror.net/t/get-highlighted-code/637 "2016-02-04T14:23:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![RavenousRat](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@RavenousRat](https://discuss.codemirror.net/u/RavenousRat)
#### Post date: [February 4, 2016, 2:23pm UTC](https://discuss.codemirror.net/t/get-highlighted-code/637/1 "2016-02-04T14:23:28Z")

</div>

HI.

I open CodeMirror in a dialog where I write SourceCode with CM-functionality. When I hit the save button, I want to copy the hightlighted CM-text in a div outside of that dialog (highlighting should remain there).

I found the method getValue() where I get the string from CM without styling.  
Is there a possibillity to get the highlighted html Code? Or maybe line by line with styling classes from CM?

I want to copy the codeblock exactly the way it looks in another html-element.

Every help is more than appreciated 🙂

---

<div class="post-metadata">

### Author: ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)
#### Post date: [February 4, 2016, 2:39pm UTC](https://discuss.codemirror.net/t/get-highlighted-code/637/2 "2016-02-04T14:39:09Z")

</div>

This isn’t possible, but you might get a similar effect by running [runmode](http://codemirror.net/doc/manual.html#addon_runmode) over the string you get.

---

<div class="post-metadata">

### Author: ![RavenousRat](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@RavenousRat](https://discuss.codemirror.net/u/RavenousRat)
#### Post date: [February 4, 2016, 2:45pm UTC](https://discuss.codemirror.net/t/get-highlighted-code/637/3 "2016-02-04T14:45:43Z")

</div>

Thanks for that quick reply!

Yes runmode could fix my problem in a good manner. I’ll try it.

Thanks

EDIT: Runmode was a good tip. That worked great 🙂
