Got it. Line breaking seems to be the hard part, based on the above-linked article and the descriptions in the TeXBook, because of the combinatorial explosion.

On Sat, Feb 15, 2020 at 12:44 PM Arthur A. Gleckler <xxxxxx@speechcode.com> wrote:
On Fri, Feb 14, 2020 at 11:44 PM John Cowan <xxxxxx@ccil.org> wrote:
 
Making Emacs format a file from the command line is basically a one-line shell script.

Generally, Emacs will indent code, but it won't adjust line breaks.