resolves #967 - toc doesn't display nested elements correctly

- check for child toc before outputting closing </li> on parent element
Merge PR #969 from @kenfinnigan