We can type > and select python to insert python external language cell into notebook.
Then we can write python code inside it and evaluate it by pressing Enter.
Now I want to do a similar thing. Make my own cell that would work similar as external language cell, but instead of sending content of the cell to python kernel it would send its content into Mathematica own function.
Say, the function is:
myowncellevaluator[x_] :=
Module[{}, Print["Hello"]; ToExpression[StringSplit[x, "\n"]]]
And the cell could look for example like this:
n=2
7*n^2
Then by pressing Enter in the cell I want to send its content in the form of string into function myowncellevaluator - meaning I would get output of myowncellevaluator["n=2\n7*n^2"]
in output cell, which would be:
"Hello"
{2, 28}
How to create such a cell?
The cell could look like this after evaluation:

$Preand$Postdirectives? – MarcoB Sep 10 '22 at 17:10sage[code], code is string that contains Sagemath code. So I have to use escape characters inside string like\",\\n,\'... If I can write Sagemath code in cell like it is in cell for Python it would be more elegant. – azerbajdzan Sep 10 '22 at 17:30sagewhich in turn would send it to Sagemath kernel. – azerbajdzan Sep 10 '22 at 17:33