Table/issue 2868

This finishes up @cherti's original PR at #3055 by rebasing on master and updating to work on master.  I also fixed a few bugs and reformatted the code a bit.  After I submit this PR I'm probably going to rebase again to collapse down some of @cherti's original commits, but will still make sure they get credit.
I would vote to just do the `max_lines=1` testing even for the object case to avoid the possibility of serious performance impact for big arrays.  Also, who knows, maybe there is a subset of rows for which the format is fine and user intends to select that subset prior to outputting.  In that case the format string validation would be premature.