* Blank out fenced and inline code spans so the #tag / [[link]] / asset * scanners never read code as content. Fence detection is line-based and * indentation-tolerant: a fence nested under a list item is still a code block, * so its contents (e.g. a C `#include` line) must not be scanned. A * c
(body: string)
| 1458 | * apps/server/internal/vault/parse.go — keep the three in sync. |
| 1459 | */ |
| 1460 | function stripCodeContent(body: string): string { |
| 1461 | if (!body.includes('`') && !body.includes('~')) return body |
| 1462 | const lines = body.split('\n') |
| 1463 | let inFence = false |
| 1464 | let fenceChar = '' |
| 1465 | let fenceLen = 0 |
| 1466 | for (let i = 0; i < lines.length; i++) { |
| 1467 | const line = lines[i] as string |
| 1468 | const m = /^[ \t]*(`{3,}|~{3,})(.*)$/.exec(line) |
| 1469 | if (m) { |
| 1470 | const marker = m[1] as string |
| 1471 | const char = marker[0] as string |
| 1472 | const rest = m[2] as string |
| 1473 | if (!inFence) { |
| 1474 | // A backtick fence's info string may not contain a backtick (CommonMark), |
| 1475 | // which keeps a single-line ``` ```inline``` ``` out of fence handling. |
| 1476 | if (char === '~' || !rest.includes('`')) { |
| 1477 | inFence = true |
| 1478 | fenceChar = char |
| 1479 | fenceLen = marker.length |
| 1480 | lines[i] = ' ' |
| 1481 | continue |
| 1482 | } |
| 1483 | } else if (char === fenceChar && marker.length >= fenceLen && rest.trim() === '') { |
| 1484 | inFence = false |
| 1485 | lines[i] = ' ' |
| 1486 | continue |
| 1487 | } |
| 1488 | } |
| 1489 | if (inFence) lines[i] = ' ' |
| 1490 | } |
| 1491 | return lines.join('\n').replace(/`[^`\n]*`/g, ' ') |
| 1492 | } |
| 1493 | |
| 1494 | function localAssetTargetKind(target: string): ImportedAssetKind | null { |
| 1495 | const clean = target.split('#')[0]?.split('?')[0] ?? target |
no outgoing calls
no test coverage detected