Search code examples
wolfram-mathematicamathematica-frontend

Is it possible to create MakeBoxesStop wrapper?


It is known that output expressions are passed through MakeBoxes to turn the graphics expressions into the box language which the front end uses to represent graphics (when $Output has default option FormatType->StandardForm). For example, if we evaluate:

HoldComplete[Graphics[Disk[]]]

we get a disk wrapped by HoldComplete:

screenshot

This is because HoldComplete does not stop MakeBoxes from converting its contents to typeset expression:

In[4]:= MakeBoxes@HoldComplete[Graphics[Disk[]]]
Out[4]= RowBox[{"HoldComplete", "[", GraphicsBox[DiskBox[{0, 0}]], "]"}]

So my question is: is it possible to make some additional definitions to MakeBoxes such that wrapping any expression with head MakeBoxesStop will prevent MakeBoxes from converting this expression to typeset form? In this case the expression should look in output as any other expression with no rules associated with symbols in it; in the above case:

screenshot

P.S. Please do not suggest to use InputForm since I am not satisfied with its default behavior.


Solution

  • Starting from Mathematica 11.0, we have DisableFormatting wrapper which prevents formatting inside of held expressions:

    Hold[DisableFormatting@Graphics[Disk[]]]
    

    >     Hold[DisableFormatting[Graphics[Disk[]]]]

    Strongly related answer by Carl Woll: