# core/renderers/baseline.renderer.ts

> 62 lines of code and 11 definitions.

Tree: Bane's Lab Content
Language: typescript
Layer: product
Canonical: https://banes-lab.com/anatomy/content#file-content-core-renderers-baseline-renderer-ts
Source text: https://banes-lab.com/source/content/core/renderers/baseline.renderer.ts.txt

Listed in [core/renderers](https://banes-lab.com/api/source/content/core/renderers.md), before [core/renderers/chapter.renderer.ts](https://banes-lab.com/source/content/core/renderers/chapter.renderer.ts.md).

## Definitions

- `row` (lexical_declaration, line 19)
- `wordsPerSentence` (lexical_declaration, line 23)
- `renderBaseline` (lexical_declaration, line 27, exported)
- `FRONTMATTER` (lexical_declaration, line 11)
- `CELL` (lexical_declaration, line 12)
- `EDGE` (lexical_declaration, line 13)
- `EDGE_END` (lexical_declaration, line 14)
- `RULE` (lexical_declaration, line 15)
- `HEADING` (lexical_declaration, line 16)
- `DECIMALS` (lexical_declaration, line 17)
- `lines` (lexical_declaration, line 28, exported)

## Contained in

- [core/renderers](https://banes-lab.com/anatomy/content/folder-content-core-renderers.md)

## Linked from

- [core/renderers](https://banes-lab.com/anatomy/content/folder-content-core-renderers.md)

## Source

```typescript
import { BASELINE_CONCERN, BASELINE_NAME, DOC_STATUS, DOC_TYPE } from "#configuration/constants/tone.constants";
import {
    BASELINE_HEADERS,
    BASELINE_INTRO,
    BASELINE_SUMMARY,
    BASELINE_TITLE,
} from "#configuration/strings/baseline.strings";
import { LINE_END } from "#configuration/constants/inventory.constants";
import type { ToneBaseline } from "#types/tone.types";

const FRONTMATTER = "---";
const CELL = " | ";
const EDGE = "| ";
const EDGE_END = " |";
const RULE = "---";
const HEADING = "# ";
const DECIMALS = 1;

const row = function row(cells: readonly string[]): string {
    return EDGE + cells.join(CELL) + EDGE_END;
};

const wordsPerSentence = function wordsPerSentence(words: number, sentences: number): string {
    return sentences === 0 ? String(0) : (words / sentences).toFixed(DECIMALS);
};

export const renderBaseline = function renderBaseline(baseline: ToneBaseline): string {
    const lines = [
        FRONTMATTER,
        `type: ${DOC_TYPE}`,
        `name: ${BASELINE_NAME}`,
        `summary: ${BASELINE_SUMMARY}`,
        `concern: ${BASELINE_CONCERN}`,
        `status: ${DOC_STATUS}`,
        FRONTMATTER,
        "",
        HEADING + BASELINE_TITLE,
        "",
        BASELINE_INTRO,
        "",
        row(BASELINE_HEADERS),
        row(BASELINE_HEADERS.map(() => RULE)),
    ];
    for (const metrics of baseline.modules) {
        lines.push(
            row([
                metrics.module,
                String(metrics.literals),
                String(metrics.sentences),
                wordsPerSentence(metrics.words, metrics.sentences),
                String(metrics.longestSentence),
                String(metrics.agentlessPassives),
                String(metrics.chainedSentences),
                String(metrics.longDashes),
                String(metrics.semicolons),
                String(metrics.digitMetrics),
                String(metrics.bannedTerms),
                String(metrics.firstPerson),
                String(metrics.secondPerson),
                String(metrics.collectivePerson),
                String(metrics.labeledItems),
            ]),
        );
    }
    return lines.join(LINE_END) + LINE_END;
};
```
