MCPcopy Index your code
hub / github.com/UNLINEARITY/Obsidian-CodeSpace / createFencedCodeBlock

Function createFencedCodeBlock

src/code_embed_markdown.ts:146–155  ·  view source on GitHub ↗
(content: string, ext: string)

Source from the content-addressed store, hash-verified

144}
145
146export function createFencedCodeBlock(content: string, ext: string): string {
147 const markdownLanguage = getMarkdownLanguage(ext);
148 const fenceMatches = content.match(/`+/g) ?? [];
149 let longestFence = 0;
150 for (const fence of fenceMatches) {
151 longestFence = Math.max(longestFence, fence.length);
152 }
153 const fence = "`".repeat(Math.max(3, longestFence + 1));
154 return `${fence}${markdownLanguage}\n${content}\n${fence}`;
155}
156
157export function resolveCodeEmbedReference(
158 plugin: CodeSpacePlugin,

Callers 3

replacePopupCodeEmbedsFunction · 0.90
renderCodeEmbedFunction · 0.90

Calls 1

getMarkdownLanguageFunction · 0.85

Tested by

no test coverage detected