MCPcopy Create free account
hub / github.com/UNLINEARITY/Obsidian-CodeSpace / sliceFileContent

Function sliceFileContent

src/code_embed_markdown.ts:223–232  ·  view source on GitHub ↗
(content: string, startLine: number, endLine: number)

Source from the content-addressed store, hash-verified

221}
222
223export function sliceFileContent(content: string, startLine: number, endLine: number): string {
224 if (startLine <= 1 && endLine <= 0) {
225 return content;
226 }
227
228 const lines = content.split("\n");
229 const clampedStart = Math.min(Math.max(startLine, 1), lines.length);
230 const clampedEnd = endLine > 0 ? Math.min(Math.max(endLine, clampedStart), lines.length) : lines.length;
231 return lines.slice(clampedStart - 1, clampedEnd).join("\n");
232}
233
234export async function expandCodeEmbedsInMarkdown(
235 plugin: CodeSpacePlugin,

Callers 2

replacePopupCodeEmbedsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected