tweak triple quoted string indenting algorithm

Restores the trailing newline when the terminator occupies its own line.
Otherwise, instead of using the last line to set the deindent level,
scan for the longest common prefix.

Also, handle tab/space mixing.