For example, this might be done by minimizing the number of \begin{...} commands, etc. Of course, the output would need to look identical.The simplification need not be optimal. It should just cover a lot of common cases. For example, suppose you have a list and each item has boldface tags around it. It would be better to boldface the entire list instead.I think this is a problem that needs solving for WYSIWYG word processors such as TeXmacs. It would be nice if TeXmacs can constantly simplify the document tree while you edit in WYSIWYG.