MCPcopy Index your code
hub / github.com/massCodeIO/massCode / getMarkdownFenceLanguage

Function getMarkdownFenceLanguage

src/main/api/routes/captures.ts:276–310  ·  view source on GitHub ↗
(body: CaptureRequest)

Source from the content-addressed store, hash-verified

274}
275
276function getMarkdownFenceLanguage(body: CaptureRequest): string | undefined {
277 const sourceName
278 = trimToValue(body.contextLabel)
279 ?? trimToValue(body.sourceTitle)
280 ?? trimToValue(body.source?.title)
281 ?? trimToValue(body.pageTitle)
282
283 if (!sourceName) {
284 return undefined
285 }
286
287 const extension = sourceName.match(/\.([a-z0-9]+)(?:$|[\s?#])/i)?.[1]
288 if (!extension) {
289 return undefined
290 }
291
292 const languages: Record<string, string> = {
293 cjs: 'js',
294 css: 'css',
295 html: 'html',
296 js: 'js',
297 json: 'json',
298 jsx: 'jsx',
299 md: 'md',
300 mjs: 'js',
301 sh: 'sh',
302 ts: 'ts',
303 tsx: 'tsx',
304 vue: 'vue',
305 yaml: 'yaml',
306 yml: 'yaml',
307 }
308
309 return languages[extension.toLowerCase()]
310}
311
312function createNoteContent(body: CaptureRequest): string {
313 const text = trimToValue(body.text)

Callers 1

createNoteContentFunction · 0.85

Calls 1

trimToValueFunction · 0.70

Tested by

no test coverage detected