请问如何批量设置小标题 |
您所在的位置:网站首页 › 如何设置小节标题 › 请问如何批量设置小标题 |
编、分编、章、节、条、款 对应的标题等级是确定的吧?确定的话就好说 markdown最多支持到六级标题,“款”需要作为标题吗? 我刚写了一个,可以直接修改一个文件的: { function change(text) { return text.split("\n").map((line) => { line = line.replace(/^第(.+)分编/, "## 第$1分编"); line = line.replace(/^第(.+)编/, "# 第$1编"); line = line.replace(/^第(.+)章/, "### 第$1章"); line = line.replace(/^第(.+)节/, "#### 第$1节"); line = line.replace(/^第(.+)条/, "##### 第$1条"); return line; }).join("\n"); } let file = app.workspace.getActiveFile(); app.vault .read(file) .then(text => app.vault.modify(file, change(text))); }方式是 shift + ctrl + i打开控制台,然后打开相应的文件,复制代码执行。目前只支持到五级标题 效果: 执行前: image406×526 11.2 KB 执行后: image404×651 16.8 KB |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |