# flagstaff/markdown

> Every export of flagstaff/markdown, with its signature and doc comment: markdownBlocks, markdown, plus 3 types.

Source: https://flagstaff.interlace.tools/docs/api/markdown

<!-- Generated by scripts/api-reference.ts from the built dist/*.d.ts. Do not edit; run `npx tsx scripts/api-reference.ts`. -->

```ts
import { markdownBlocks, markdown } from 'flagstaff/markdown';
```

## Functions

### markdown

Markdown streamed in: its committed source off a terminal, the document so far drawn on one.

```ts
function markdown(): Component<MarkdownState>;
```

**Returns** `Component<MarkdownState>`

### markdownBlocks

The blocks committed so far. Only complete lines are read — a line is complete when a
newline follows it, or when the stream is `done` — which is what makes the answer the same
wherever the stream was cut.

```ts
function markdownBlocks(text: string, done?: boolean): MarkdownBlock[];
```

| Parameter | Type |
| :-- | :-- |
| `text` | `string` |
| `done` (optional) | `boolean` |

**Returns** `MarkdownBlock[]`

## Interfaces

### MarkdownBlock

```ts
interface MarkdownBlock {
    kind: MarkdownBlockKind;
    /** The block's source, its lines as they arrived. */
    source: string;
    /** Where the block's source ends in the stream: `text.slice(0, end)` is committed. */
    end: number;
}
```

### MarkdownState

```ts
interface MarkdownState {
    /** Everything the stream has produced so far. */
    text: string;
    /** The stream has ended: the last block is committed too. */
    done?: boolean;
}
```

## Types

### MarkdownBlockKind

```ts
type MarkdownBlockKind = 'heading' | 'paragraph' | 'list' | 'code';
```
