(body: CaptureRequest)
| 274 | } |
| 275 | |
| 276 | function 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 | |
| 312 | function createNoteContent(body: CaptureRequest): string { |
| 313 | const text = trimToValue(body.text) |
no test coverage detected