Add "preceding text" test cases for doctest indentation
Rewrite code for doctest indentation

This combines the check_indent and measure_indent into a single pass.