I have an opened Mathematica notebook containing several cells. Suppose, I am interested in one of them -- it may contain a complete or incomplete expression (e.g. with syntax errors, highlighted unbalanced brackets etc), possibly with embedded graphics, some of the identifiers automatically colorized by Mathematica Front End according to their meaning (undefined symbols,
Module locals, conflicting names...) and some possibly having a manually changed style (font, size, color etc). I need to get a
String whose content represents the content of this cell with highest possible fidelity (recall that Mathematica strings preserve formatting and support arbitrary embedded expressions including graphics). The string should mimic the structure and be editable to the same extent as the original cell (so it should not, for example, contain just a graphical image depicting the cell).
Could you please suggest how to do this?