Detect element nesting level; minor code cleanup

Added code to detect the nesting level of headings (according to HTML5 sectioning elements -- would need to expand upon this code to account for non-HTML5 elements that have been given a sectioning role).

Code cleanups were to remove tab characters and make indentation more consistent.