Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
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
46 changes: 24 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,23 @@
"main": "./out/src/extension",
"contributes": {
"commands": [
{
"command": "extension.updateMarkdownToc",
"title": "Markdown TOC: Insert/Update"
},
{
"command": "extension.deleteMarkdownToc",
"title": "Markdown TOC: Delete"
},
{
"command": "extension.updateMarkdownSections",
"title": "Markdown Sections: Insert/Update"
},
{
"command": "extension.deleteMarkdownSections",
"title": "Markdown Sections: Delete"
}],
{
"command": "extension.updateMarkdownToc",
"title": "Markdown TOC: Insert/Update"
},
{
"command": "extension.deleteMarkdownToc",
"title": "Markdown TOC: Delete"
},
{
"command": "extension.updateMarkdownSections",
"title": "Markdown Sections: Insert/Update"
},
{
"command": "extension.deleteMarkdownSections",
"title": "Markdown Sections: Delete"
}
],
"menus": {
"editor/context": [
{
Expand All @@ -71,7 +72,7 @@
}
]
},
"keybindings":[
"keybindings": [
{
"command": "extension.updateMarkdownToc",
"key": "ctrl+m t"
Expand Down Expand Up @@ -119,12 +120,12 @@
"type": "string",
"default": "github.com",
"description": "anchor mode.",
"enum": [
"github.com",
"bitbucket.org",
"ghost.org",
"enum": [
"github.com",
"bitbucket.org",
"ghost.org",
"gitlab.com"
]
]
}
}
}
Expand All @@ -135,6 +136,7 @@
"postinstall": "node ./node_modules/vscode/bin/install"
},
"dependencies": {
"@types/node": "^10.12.18",
"anchor-markdown-header": "^0.5.7"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ class MarkdownTocTools {
let insertSpaces = <boolean> workspace.getConfiguration("[markdown]")["editor.insertSpaces"];

if(lineEnding === undefined || lineEnding === null || lineEnding === "auto") {
// Default back to "\n" in case of VSCode update 1.29.0,
// where `Files > EOL` was set to the string value "auto".
// Use OS default line-endings where `Files > EOL` was set to the string value "auto".
// "eol=auto" was introduced in VSCode update 1.29.0.
// See https://github.com/AlanWalk/markdown-toc/issues/65
lineEnding = "\n";
lineEnding = require('os').EOL;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably change this to an import at the top of the file

import { EOL } from 'os';

This also allows for a change on line 249 in the insertAnchor method where it builds the text variable.

This

let text = [ '<a id="markdown-', name, '" name="', name, '"></a>\n' ];

Can be changed to

let text = [ '<a id="markdown-', name, '" name="', name, '"></a>', EOL ];

}
if(tabSize === undefined || tabSize === null) {
tabSize = <number> workspace.getConfiguration("editor").get("tabSize");
Expand Down
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"outDir": "out",
"noLib": true,
"sourceMap": true,
"rootDir": "."
"rootDir": ".",
"moduleResolution": "node",
"types": [
"node"
]
},
"exclude": [
"node_modules"
Expand Down