VSCode MarkDown-TOC 插件开发与发布

1. VSCode MarkDown-TOC 插件

1.1. MarkDown-TOC 插件目录生成错误 auto

使用该插件自动生成 TOC, 但发现是一大坨很乱的字。仔细观察发现没有换行, 而且出现很多 audo 字符。

1.2. 解决

参考: https://github.com/AlanWalk/markdown-toc/issues/89

  1. 打开设置
  2. 搜索 eol
  3. 改为 \n

2. vscode 插件开发

这里以 markdown-toc 插件举例。

2.1. 发布

From: https://code.visualstudio.com/api/working-with-extensions/publishing-extension

特别要注意的是:

  1. 在设置 Personal Access Token 的时候 organization 一定要选择 “All accessible organizations” 否则设置的 token 不会生效。

在这里插入图片描述

  1. 可以直接登录 https://marketplace.visualstudio.com/manage/publishers/CharlesWan 进行手动上传 vsix 文件进行发布,免去命令行的麻烦。

在这里插入图片描述

npm install -g vsce
$ vsce login charleswan
$ vsce package
$ vsce publish

2.2. 执行 npm install 时提示: Error installing vscode.d.ts: Error: Request returned status code: 404

原因是这个包依赖的 vscode 包太旧了,访问原来的地址 https://vscode-update.azurewebsites.net/api/releases/stable 报错: Cannot GET /api/releases/stable

解决方法:

There are two ways to get out of that situation:

  • The latest vscode module already points to update.code.visualstudio.com. So the easy fix is to just update vscode to 1.1.37 in your dependencies.
  • The vscode module has been deprecated since about a year. So the right fix is to follow the migration guide and move out of that module.

If you’re going to have regressive licensing, you need to make sure old builds stay available at their old URL’s.

All builds are still available in update.code.visualstudio.com, as vscode-builds was just a redirect to that service.

2.3. 升级为 TypeScript 2.0

From: https://code.visualstudio.com/updates/v1_6#_authoring-in-typescript

Open the package.json file and do the following changes:

  • Change the TypeScript developer dependency from "typescript": "x.x.x" to "typescript": "^2.0.3".
  • Add a developer dependency for the Node.js typings using "@types/node": "^6.0.40".
  • If your extension has Mocha tests, change the developer dependency to at least Mocha version 2.3.3.
  • Add a developer dependency for the Mocha typing using "@types/mocha": "^2.2.32".
  • In the script section, exchange the compile script with "compile": "tsc -watch -p ./" and the vscode:prepublish with "vscode:prepublish": "tsc -p ./".

The devDependencies section should look like this:

"devDependencies": {
    "typescript": "^2.0.3",
    "vscode": "^1.0.0", // Or a higher version if necessary
    "mocha": "^2.3.3",
    "@types/node": "^6.0.40",
    "@types/mocha": "^2.2.32"
}

and the scripts section something like this:

"scripts": {
    "vscode:prepublish": "tsc -p ./",
    "compile": "tsc -watch -p ./",
    "postinstall": "node ./node_modules/vscode/bin/install"
}
  • Open the tsconfig.json file and exchange the line "noLib": true with "lib": [ "es6" ] and "target": "es5" with "target": "es6".

The file should look something like this:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "outDir": "out",
    "lib": ["es6"],
    "sourceMap": true,
    "rootDir": "."
  },
  "exclude": ["node_modules", ".vscode-test"]
}

run npm install.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云满笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值