flagstaff
API reference

flagstaff/markdown

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

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

Functions

markdown

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

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.

function markdownBlocks(text: string, done?: boolean): MarkdownBlock[];
ParameterType
textstring
done (optional)boolean

Returns MarkdownBlock[]

Interfaces

MarkdownBlock

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

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

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

On this page