I usually close all the parenthesis on the same line, also I don't put spaces around ternary operators:

`(p) => (p is Document) ? p : ((p is Pretty) ? p.pretty : text(p.toString()))));`

Note that I don't care too much about style, and I can always fix it myself instead of bothering you if I really want to, so please feel free to ignore.