Explanation: TeX uses dynamic programming to minimize the sum of cubes of unused space on each line. Constrain does this minimization in real time inside an HTML canvas. It doesn't implement all the features of TeX, like allowing overfull boxes or automatic hyphenation.