MCPcopy
hub / github.com/yzhang-gh/vscode-markdown / removeSectionNumbers

Function removeSectionNumbers

src/toc.ts:104–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102}
103
104function 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
124function normalizePath(path: string): string {
125 return path.replace(/\\/g, '/').toLowerCase();

Callers

nothing calls this directly

Calls 2

isMdEditorFunction · 0.90
buildTocFunction · 0.85

Tested by

no test coverage detected