()
| 102 | } |
| 103 | |
| 104 | function removeSectionNumbers() { |
| 105 | const editor = window.activeTextEditor; |
| 106 | if (!isMdEditor(editor)) { |
| 107 | return; |
| 108 | } |
| 109 | const doc = editor.document; |
| 110 | const toc = buildToc(editor.document); |
| 111 | let edit = new WorkspaceEdit(); |
| 112 | toc.forEach(entry => { |
| 113 | const lineNum = entry.lineNum; |
| 114 | const lineText = doc.lineAt(lineNum).text; |
| 115 | const newText = lineText.includes('#') |
| 116 | ? lineText.replace(/^(\s{0,3}#+ +)((?:\d{1,2}\.)* )?(.*)/, (_, g1, _g2, g3) => `${g1}${g3}`) |
| 117 | : lineText.replace(/^(\s{0,3})((?:\d{1,2}\.)* )?(.*)/, (_, g1, _g2, g3) => `${g1}${g3}`); |
| 118 | edit.replace(doc.uri, doc.lineAt(lineNum).range, newText); |
| 119 | }); |
| 120 | |
| 121 | return workspace.applyEdit(edit); |
| 122 | } |
| 123 | |
| 124 | function normalizePath(path: string): string { |
| 125 | return path.replace(/\\/g, '/').toLowerCase(); |
nothing calls this directly
no test coverage detected