I start with
f[x]
.
In boxes, this is
RowBox[{"f", "[", "x", "]"}]
.
I apply MakeExpression
to give f[x]
again, as desired.
Then I try
f[
x]
,
which in boxes is RowBox[{"f", "[", "\[IndentingNewLine]", "x", "]"}]
. Applying MakeExpression
gives f[x]
, which is ok for my current purposes.
The problem arises when I try to apply this to Table
. Without the newline character, eg.
Table[x, {x, 2}]
,
converting to boxes and then using MakeExpression
works as expected.
Then I try
Table[x
, {x, 2}]
.
In boxes, this is RowBox[{"Table", "[",
RowBox[{"x", "\[IndentingNewLine]", ",",
RowBox[{"{", RowBox[{"x", ",", "2"}], "}"}]}], "]"}]
When I apply MakeExpression
to this, I get ErrorBox[RowBox[{"Table", "[",
ErrorBox[
RowBox[{"x", "\[IndentingNewLine]", ",",
RowBox[{"{", RowBox[{"x", ",", "2"}], "}"}]}]], "]"}]]
Does anyone know how I can get around this?
"\[IndentingNewLine]"
, why not just remove it? For example,/."\[IndentingNewLine]"->Nothing//MakeExpression
$\endgroup$DeleteCases[ (My box expression here) , "[IndentingNewLine]"]
, but it didn't do anything (I feel like it should have so I was a bit unsure about this). Your code replaces it with 'Nothing', which MakeExpression still can't read properly $\endgroup$