mdz_lexer.ts

mdz lexer — tokenizes input into a flat MdzToken[] stream.

Phase 1 of the synchronous parsing pipeline behind mdz_parse. Phase 2 (token parser) is in mdz_token_parser.ts.

view source

Declarations
#

35 declarations

MdzLexer
#

mdz_lexer.ts view source

import {MdzLexer} from '@fuzdev/mdz/mdz_lexer.js';

Tokenizes mdz input into a flat MdzToken stream for MdzTokenParser.

The lexer owns all structural decisions — block boundaries, list level stacks, blockquote prefix stripping (sub-lexing quote content as a mini-document with positions remapped to source offsets), and inline delimiter pairing bounded by #max_search_index — so the token parser only assembles the tree.

constructor

type new (text: string): MdzLexer

text

type string

rebind

Rebind to a new text, so one lexer instance can be reused across inputs — the streaming table path reuses one across a table's rows via MdzTableCellParser instead of allocating a lexer (and its memo Map) per row. The search memos survive when the text is identical (they're valid over the immutable text — the common case for rows parsed from one buffered chunk) and clear otherwise. Per-parse cursor state is reset by lex_table_cell itself.

type (text: string): void

text

type string
returns void

tokenize

type (): MdzToken[]

returns MdzToken[]

lex_table_cell

Tokenize a table cell's inline content [cell_start, cell_end) as a bounded inline run, with no wrapping cell tokens (the bare form of #emit_table_cell, sharing #tokenize_cell_inline). The streaming parser reuses it across a row's cells via MdzTableCellParser: the token buffer resets per call while the search memo — valid over the immutable bound text — carries across cells (the same reuse the sync lexer does in place).

type (cell_start: number, cell_end: number): MdzToken[]

cell_start

type number

cell_end

type number
returns MdzToken[]

MdzToken
#

MdzTokenAutolink
#

MdzTokenBase
#

mdz_lexer.ts view source

MdzTokenBase import type {MdzTokenBase} from '@fuzdev/mdz/mdz_lexer.js';

start

type number

end

type number

MdzTokenBlockquoteClose
#

mdz_lexer.ts view source

MdzTokenBlockquoteClose import type {MdzTokenBlockquoteClose} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'blockquote_close'

MdzTokenBlockquoteOpen
#

mdz_lexer.ts view source

MdzTokenBlockquoteOpen import type {MdzTokenBlockquoteOpen} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'blockquote_open'

MdzTokenBoldClose
#

MdzTokenBoldOpen
#

MdzTokenCode
#

MdzTokenCodeblock
#

mdz_lexer.ts view source

MdzTokenCodeblock import type {MdzTokenCodeblock} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'codeblock'

lang

type string | null

content

type string

MdzTokenHeadingEnd
#

MdzTokenHeadingStart
#

mdz_lexer.ts view source

MdzTokenHeadingStart import type {MdzTokenHeadingStart} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'heading_start'

level

type 1 | 2 | 3 | 4 | 5 | 6

MdzTokenHr
#

MdzTokenItalicClose
#

MdzTokenItalicOpen
#

MdzTokenLinkRef
#

mdz_lexer.ts view source

MdzTokenLinkRef import type {MdzTokenLinkRef} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'link_ref'

reference

type string

link_type

type 'external' | 'internal'

MdzTokenLinkTextClose
#

mdz_lexer.ts view source

MdzTokenLinkTextClose import type {MdzTokenLinkTextClose} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'link_text_close'

MdzTokenLinkTextOpen
#

mdz_lexer.ts view source

MdzTokenLinkTextOpen import type {MdzTokenLinkTextOpen} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'link_text_open'

MdzTokenListClose
#

MdzTokenListItemClose
#

mdz_lexer.ts view source

MdzTokenListItemClose import type {MdzTokenListItemClose} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'list_item_close'

MdzTokenListItemOpen
#

mdz_lexer.ts view source

MdzTokenListItemOpen import type {MdzTokenListItemOpen} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'list_item_open'

number?

Authored number (ordered lists only).

type number

MdzTokenListOpen
#

mdz_lexer.ts view source

MdzTokenListOpen import type {MdzTokenListOpen} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'list_open'

ordered

type boolean

MdzTokenParagraphBreak
#

mdz_lexer.ts view source

MdzTokenParagraphBreak import type {MdzTokenParagraphBreak} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'paragraph_break'

MdzTokenStrikethroughClose
#

mdz_lexer.ts view source

MdzTokenStrikethroughClose import type {MdzTokenStrikethroughClose} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'strikethrough_close'

MdzTokenStrikethroughOpen
#

mdz_lexer.ts view source

MdzTokenStrikethroughOpen import type {MdzTokenStrikethroughOpen} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'strikethrough_open'

MdzTokenTableCellClose
#

mdz_lexer.ts view source

MdzTokenTableCellClose import type {MdzTokenTableCellClose} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'table_cell_close'

MdzTokenTableCellOpen
#

mdz_lexer.ts view source

MdzTokenTableCellOpen import type {MdzTokenTableCellOpen} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'table_cell_open'

MdzTokenTableClose
#

MdzTokenTableOpen
#

mdz_lexer.ts view source

MdzTokenTableOpen import type {MdzTokenTableOpen} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'table_open'

align

Per-column alignment from the delimiter row; length is the column count.

type Array<MdzTableAlign>

MdzTokenTableRowClose
#

mdz_lexer.ts view source

MdzTokenTableRowClose import type {MdzTokenTableRowClose} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'table_row_close'

MdzTokenTableRowOpen
#

mdz_lexer.ts view source

MdzTokenTableRowOpen import type {MdzTokenTableRowOpen} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'table_row_open'

header

true for the header row, false for body rows.

type boolean

MdzTokenTagClose
#

mdz_lexer.ts view source

MdzTokenTagClose import type {MdzTokenTagClose} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'tag_close'

name

type string

MdzTokenTagOpen
#

mdz_lexer.ts view source

MdzTokenTagOpen import type {MdzTokenTagOpen} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'tag_open'

name

type string

is_component

type boolean

MdzTokenTagSelfClose
#

mdz_lexer.ts view source

MdzTokenTagSelfClose import type {MdzTokenTagSelfClose} from '@fuzdev/mdz/mdz_lexer.js';

inheritance

extends: MdzTokenBase

type

type 'tag_self_close'

name

type string

is_component

type boolean

MdzTokenText
#

Depends on
#

Imported by
#