Do not render footers, headers and sidebars if (after formatting) they are empty. Resolves #398 .

Might benefit from refactoring, but does the job. Thoughts?