Skip to content

Commit

Permalink
fix: Trim empty sections before joining to avoid spare newlines in do…
Browse files Browse the repository at this point in the history
…cument
  • Loading branch information
gregdan3 committed Sep 17, 2023
1 parent 0e290ef commit 76a76dc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ module.exports = function insert(str, options) {
sections.splice(1, 0, open + toc(last, options).content + '\n\n' + close);
}

// Trim empty sections to avoid adding newlines to document in join
sections = sections.filter((section) => section.length > 0);

var resultString = sections.join('\n\n') + newlines;
// if front-matter was found, put it back now
if (obj) {
Expand Down

0 comments on commit 76a76dc

Please sign in to comment.