StripBoxes

StripBoxes[expr]

will strip out unnecessary boxes, spaces, and styles from a format expression.

Details

  • StripBoxes takes a typesetting box expression and returns a box expression that is stripped of various nonsemantic elements such as whitespace and comments. It also strips style boxes, which may change the visual appearance but are generally ignored for evaluation purposes.
  • StripBoxes may take a BoxData expression or any other box. Regardless of the input, the output is always wrapped in BoxData.
  • When boxes are sent by the front end to the kernel for evaluation, the front end strips the boxes using a more extensive process that may depend upon active stylesheets and front end option settings. However, when working with functions that directly serialize notebook constructs such as NotebookRead, no stripping will occur.

Examples

open allclose all

Basic Examples  (1)

Strip unwanted whitespace and styles from a box expression:

Scope  (3)

Strip StyleBox expressions:

Strip non-semantic whitespace:

Strip comments:

Properties & Relations  (2)

By default, no stripping happens in TagBox or InterpretationBox:

StripWrapperBoxes->True causes stripping to happen:

The presence of some whitespace can prevent MakeExpression from interpreting a box structure:

Use StripBoxes to strip whitespace and other boxes that interfere with interpretation:

Wolfram Research (2007), StripBoxes, Wolfram Language function, https://reference.wolfram.com/language/ref/StripBoxes.html.

Text

Wolfram Research (2007), StripBoxes, Wolfram Language function, https://reference.wolfram.com/language/ref/StripBoxes.html.

CMS

Wolfram Language. 2007. "StripBoxes." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/StripBoxes.html.

APA

Wolfram Language. (2007). StripBoxes. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StripBoxes.html

BibTeX

@misc{reference.wolfram_2023_stripboxes, author="Wolfram Research", title="{StripBoxes}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/StripBoxes.html}", note=[Accessed: 29-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_stripboxes, organization={Wolfram Research}, title={StripBoxes}, year={2007}, url={https://reference.wolfram.com/language/ref/StripBoxes.html}, note=[Accessed: 29-March-2024 ]}