Sometimes strings in a notebook/package file end up garbled due to some unknown/unintentional conversion of the expression/cell/notebook. I could not find a way to revert such unreadable text to its original version. When I convert such a cell to OutputForm (via the menu option), the result looks similar to the original, but then I cannot copy the text anymore.
From this (inserted as image to maintain formatting):

To this:
"Set.\!\(\*
StyleBox[\"obj\",\nFontSlant->\"Italic\"]\).\!\(\*
StyleBox[\"new\",\nFontSlant->\"Italic\"]\), Set.\!\(\*
StyleBox[\"obj\",\nFontSlant->\"Italic\"]\).\!\(\*
StyleBox[\"field\",\nFontSlant->\"Italic\"]\).\!\(\*
StyleBox[\"new\",\nFontSlant->\"Italic\"]\) or Set.\!\(\*
StyleBox[\"obj\",\nFontSlant->\"Italic\"]\).\!\(\*
StyleBox[SubscriptBox[\"f\", \"1\"],\nFontSlant->\"Italic\"]\).\!\(\*
StyleBox[SubscriptBox[
StyleBox[\"f\",\nFontSlant->\"Italic\"], \"2\"],\n\
FontSlant->\"Italic\"]\).(\[Ellipsis]).\!\(\*
StyleBox[\"new\",\nFontSlant->\"Italic\"]\) is interpreted as \
SetField[\!\(\*
StyleBox[\"obj\",\nFontSlant->\"Italic\"]\), \!\(\*
StyleBox[\"new\",\nFontSlant->\"Italic\"]\)], SetField[\!\(\*
StyleBox[\"obj\",\nFontSlant->\"Italic\"]\), \!\(\*
StyleBox[\"field\",\nFontSlant->\"Italic\"]\), \!\(\*
StyleBox[\"new\",\nFontSlant->\"Italic\"]\)] or SetField[\!\(\*
StyleBox[\"obj\",\nFontSlant->\"Italic\"]\), \!\(\*
StyleBox[SubscriptBox[
StyleBox[\"f\",\nFontSlant->\"Italic\"], \"1\"],\n\
FontSlant->\"Italic\"]\), \!\(\*
StyleBox[SubscriptBox[\"f\", \"2\"],\nFontSlant->\"Italic\"]\), \
\[Ellipsis], \!\(\*
StyleBox[\"new\",\nFontSlant->\"Italic\"]\)] respectively. Note that \
Set modifies the behaviour of Dot."
I don't really know what the Cell > Convert To menuoptions do, as both cells are in StandardForm and are also set to StandardForm Display. Is there a way to revert the garbled text to its original without manually editing it? Anyone knows the cause of this behaviour? You are welcome to edit the title of this post as I had no idea how to make it informative.
Edit:
These conversions mostly happen in package files (.nb) when I comment out some usage messages or other formatted text. The text immediately converts to raw form when I remove the comment markers. Sadly, when I use kguler's answer below, and copy the text reverted by Normal, the pasted text appears again in raw form.
Answer
The fastest method keystroke-wise that I have found is:
Create new empty cell
Press Ctrl+Shift+E to get
Cell[BoxData[""], "Input"]Paste your expression into that one replacing the
""inside ofBoxData.Press Ctrl+Shift+E again.
Alternatively, plaste your expression into this and evaluate:
FrontEndExecute@FrontEnd`CellPrint[
(* expression here *)
]
Comments
Post a Comment