# tools/core/predicates/marker.predicate.ts

> 30 lines of code and 13 definitions.

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

## Definitions

- `opensAFence` (lexical_declaration, line 14)
- `opensASpan` (lexical_declaration, line 23)
- `forgedBoundaries` (lexical_declaration, line 27, exported)
- `FENCE_MARK` (lexical_declaration, line 1)
- `FENCE_MINIMUM` (lexical_declaration, line 3)
- `SPAN_OPEN` (lexical_declaration, line 5)
- `SPAN_CLOSE` (lexical_declaration, line 7)
- `ForgedBoundary` (interface_declaration, line 9, exported)
- `run` (lexical_declaration, line 15)
- `out` (lexical_declaration, line 28, exported)
- `lines` (lexical_declaration, line 29, exported)
- `index` (lexical_declaration, line 31, exported)
- `text` (lexical_declaration, line 32, exported)

## Source

```typescript
const FENCE_MARK = "`";

const FENCE_MINIMUM = 3;

const SPAN_OPEN = "┌";

const SPAN_CLOSE = "└";

export interface ForgedBoundary {
    readonly line: number;
    readonly text: string;
}

const opensAFence = function opensAFence(text: string): boolean {
    let run = 0;
    while (run < text.length && text.charAt(run) === FENCE_MARK) {
        run += 1;
    }

    return run >= FENCE_MINIMUM;
};

const opensASpan = function opensASpan(text: string): boolean {
    return text.startsWith(SPAN_OPEN) || text.startsWith(SPAN_CLOSE);
};

export const forgedBoundaries = function forgedBoundaries(body: string): ForgedBoundary[] {
    const out: ForgedBoundary[] = [];
    const lines = body.split("\n");

    for (let index = 0; index < lines.length; index += 1) {
        const text = (lines[index] ?? "").trimStart();
        if (!opensAFence(text) && !opensASpan(text)) {
            continue;
        }

        out.push({ line: index + 1, text: text.slice(0, 40) });
    }

    return out;
};
```
