Display/inline math detection refinements.
More newline smartness; fix preformatted blocks.