# tools/core/resolvers/marker.resolver.ts

> 70 lines of code and 11 definitions.

Tree: Coordination tree
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tools-core-resolvers-marker-resolver-ts
Source text: https://banes-lab.com/assets/sources/source.a937923488a4b1b68582169ca618165b550c44cd5cd2513d48aeb33b3c1182b9.generated.txt

## Definitions

- `isLead` (lexical_declaration, line 5)
- `classBoundLeads` (lexical_declaration, line 24, exported)
- `declaredLeads` (lexical_declaration, line 58, exported)
- `HEADING_LEAD` (lexical_declaration, line 1)
- `BACKTICK` (lexical_declaration, line 3)
- `CLASS_BOUND_MARKER` (lexical_declaration, line 22)
- `out` (lexical_declaration, line 59, exported)
- `cursor` (lexical_declaration, line 66, exported)
- `open` (lexical_declaration, line 68, exported)
- `close` (lexical_declaration, line 73, exported)
- `candidate` (lexical_declaration, line 78, exported)

## Source

```typescript
const HEADING_LEAD = "### ";

const BACKTICK = "`";

const isLead = function isLead(candidate: string): boolean {
    if (candidate.length < 2) {
        return false;
    }
    if (!candidate.endsWith(":")) {
        return false;
    }

    for (const char of candidate.slice(0, -1)) {
        if (char < "A" || char > "Z") {
            return false;
        }
    }

    return true;
};

const CLASS_BOUND_MARKER = "presuppose a CLASS";

export const classBoundLeads = function classBoundLeads(accumulator: string): string[] {
    const out: string[] = [];

    for (const line of accumulator.split("\n")) {
        if (line.startsWith(HEADING_LEAD)) {
            break;
        }
        if (!line.includes(CLASS_BOUND_MARKER)) {
            continue;
        }

        let cursor = 0;
        while (cursor < line.length) {
            const open = line.indexOf(BACKTICK, cursor);
            if (open === -1) {
                break;
            }

            const close = line.indexOf(BACKTICK, open + 1);
            if (close === -1) {
                break;
            }

            const candidate = line.slice(open + 1, close).trim();
            if (isLead(candidate) && !out.includes(candidate)) {
                out.push(candidate);
            }
            cursor = close + 1;
        }
    }

    return out;
};

export const declaredLeads = function declaredLeads(accumulator: string): string[] {
    const out: string[] = [];

    for (const line of accumulator.split("\n")) {
        if (line.startsWith(HEADING_LEAD)) {
            break;
        }

        let cursor = 0;
        while (cursor < line.length) {
            const open = line.indexOf(BACKTICK, cursor);
            if (open === -1) {
                break;
            }

            const close = line.indexOf(BACKTICK, open + 1);
            if (close === -1) {
                break;
            }

            const candidate = line.slice(open + 1, close).trim();
            if (isLead(candidate) && !out.includes(candidate)) {
                out.push(candidate);
            }
            cursor = close + 1;
        }
    }

    return out;
};
```
