merge #12890: don't emit <p> tags in text mode when logdir specified.

Patch by Jeff McNeil.