Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mdtoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func Generate(input io.Reader, output io.Writer) error {
}
if !wroteHeader {
writeOutput(headerStart)
writeOutput("\n")
writeOutput("\n\n")
writeOutput(tocHeader)
writeOutput("\n\n")
wroteHeader = true
Expand All @@ -147,6 +147,7 @@ func Generate(input io.Reader, output io.Writer) error {
}

if wroteHeader {
writeOutput("\n")
writeOutput(headerEnd)
writeOutput("\n\n")
}
Expand Down
2 changes: 2 additions & 0 deletions testdata/atx/headerambiguity/output.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<!-- mdtocstart -->

# Table of Contents

- [Header](#header)
- [Header](#header-1)
- [Header](#header-2)
- [Header](#header-3)
- [Header](#header-4)

<!-- mdtocend -->

# Header
Expand Down
2 changes: 2 additions & 0 deletions testdata/atx/headerfirst/output.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- mdtocstart -->

# Table of Contents

- [Header](#header)

<!-- mdtocend -->

# Header
Expand Down
2 changes: 2 additions & 0 deletions testdata/atx/headerlast/output.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- mdtocstart -->

# Table of Contents

- [Header](#header)

<!-- mdtocend -->

Some text
Expand Down
2 changes: 2 additions & 0 deletions testdata/atx/headerwithhash/output.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- mdtocstart -->

# Table of Contents

- [#Header](#header)

<!-- mdtocend -->

# #Header
Expand Down
2 changes: 2 additions & 0 deletions testdata/atx/ignorecode/output.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- mdtocstart -->

# Table of Contents

- [Header](#header)

<!-- mdtocend -->

Some text
Expand Down
2 changes: 2 additions & 0 deletions testdata/atx/multiplelevels/output.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- mdtocstart -->

# Table of Contents

- [Header1](#header1)
Expand All @@ -8,6 +9,7 @@
- [Header5](#header5)
- [Header6](#header6)
- [AnotherHeader1](#anotherheader1)

<!-- mdtocend -->

# Header1
Expand Down
2 changes: 2 additions & 0 deletions testdata/atx/specialchars/output.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- mdtocstart -->

# Table of Contents

- [Header Special Char Cachaça Crap/%100%!@](#header-special-char-cachaça-crap100)

<!-- mdtocend -->

# Header Special Char Cachaça Crap/%100%!@
Expand Down
2 changes: 2 additions & 0 deletions testdata/atx/trimrightspace/output.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- mdtocstart -->

# Table of Contents

- [Header](#header)

<!-- mdtocend -->

# Header
Expand Down
2 changes: 2 additions & 0 deletions testdata/atx/updateheader/input.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- mdtocstart -->

# Table of Contents

- [Header](#header)

<!-- mdtocend -->

# Header
Expand Down
2 changes: 2 additions & 0 deletions testdata/atx/updateheader/output.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<!-- mdtocstart -->

# Table of Contents

- [Header](#header)
- [Header2](#header2)

<!-- mdtocend -->

# Header
Expand Down
2 changes: 2 additions & 0 deletions testdata/atx/withspaces/output.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<!-- mdtocstart -->

# Table of Contents

- [Header With Spaces](#header-with-spaces)
- [Header With More Spaces](#header-with----more----spaces)

<!-- mdtocend -->

# Header With Spaces
Expand Down
2 changes: 2 additions & 0 deletions testdata/removeheaders/input.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- mdtocstart -->

# Table of Contents

- [Header](#header)

<!-- mdtocend -->


Expand Down
2 changes: 2 additions & 0 deletions testdata/toconly/input.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<!-- mdtocstart -->

# Table of Contents

- [Header](#header)

<!-- mdtocend -->
2 changes: 2 additions & 0 deletions testdata/trimheaders/input.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- mdtocstart -->

# Table of Contents

- [Header](#header)

<!-- mdtocend -->


Expand Down