Is there a way to force either ToBoxes
or MakeBoxes
to respect the spacing that occurs in the code?
For example is there a way to force the following to print the code like so.
CellPrint@Cell[
BoxData@MakeBoxes[
f[
y
]
], "Input"]
would output
f[
y
]
MakeBoxes
(orToBoxes
) is a Mathematica expression. At the parsed expression level, spaces don't exist any more, having been either ignored or interpreted as multiplication by the parser, when the code was parsed (which, of course, happens at an earlier stage). Therefore, the general answer, AFAICT, is no, unless you provide an alternative parser, that would preserve the information about the spaces, and the appropriately modifiedMakeBoxes
function. $\endgroup$ – Leonid Shifrin Jul 31 '13 at 1:49