Fix trimming trailing paragraphs in Markdown that contain elements.

The code for trimming empty paragraphs didn't consider that a paragraph
may have children but not text. It now checks for any child nodes before
determining whether to trim.

Reviewed at https://reviews.reviewboard.org/r/6671/