diff --git a/html.go b/html.go index 2390e32..688ceb2 100644 --- a/html.go +++ b/html.go @@ -610,9 +610,19 @@ func (options *Html) DocumentFooter(out *bytes.Buffer) { // now clear the copied material from the main output buffer out.Truncate(options.tocMarker) + // corner case spacing issue + if options.flags&HTML_COMPLETE_PAGE != 0 { + out.WriteByte('\n') + } + // insert the table of contents out.Write(options.toc.Bytes()) + // corner case spacing issue + if options.flags&HTML_COMPLETE_PAGE == 0 && options.flags&HTML_OMIT_CONTENTS == 0 { + out.WriteByte('\n') + } + // write out everything that came after it if options.flags&HTML_OMIT_CONTENTS == 0 { out.Write(temp.Bytes()) @@ -630,13 +640,17 @@ func (options *Html) TocHeader(text []byte, level int) { for level > options.currentLevel { switch { case bytes.HasSuffix(options.toc.Bytes(), []byte("\n")): + // this sublist can nest underneath a header size := options.toc.Len() options.toc.Truncate(size - len("\n")) case options.currentLevel > 0: options.toc.WriteString("