Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Insert a blank line after the anchor. #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class MarkdownTocTools {
if (!this.options.INSERT_ANCHOR) return;
headerList.forEach(element => {
let name = element.hash.match(REGEXP_ANCHOR)[1];
let text = [ '<a id="markdown-', name, '" name="', name, '"></a>\n' ];
let text = [ '<a id="markdown-', name, '" name="', name, '"></a>\n\n' ];
let insertPosition = new Position(element.line, 0);
editBuilder.insert(insertPosition, text.join(''));
});
Expand All @@ -258,7 +258,8 @@ class MarkdownTocTools {
let lineText = doc.lineAt(index).text;
if(lineText.match(REGEXP_MARKDOWN_ANCHOR) == null) continue;

let range = new Range(new Position(index, 0), new Position(index + 1, 0));
let deleteLineCount = (index + 1 < doc.lineCount && doc.lineAt(index + 1).text.trim() === '') ? 2 : 1;
let range = new Range(new Position(index, 0), new Position(index + deleteLineCount, 0));
editBuilder.delete(range);
}
}
Expand Down