Skip to content

UnitParser

Defined in: packages/speculator/src/parse/types.ts:22

Interface for format-specific unit parsers

Both markdown and HTML parsers implement this interface, allowing the orchestrator to route units to the correct parser.

readonly format: SourceFormat

Defined in: packages/speculator/src/parse/types.ts:24

Format this parser handles

parse(content, sourceMapper): (Section | Block)[]

Defined in: packages/speculator/src/parse/types.ts:37

Parse a final composed string into AST blocks using a source mapper for location tracking.

Overload 1: New API with content string and SourceMapper Overload 2: Legacy API with SourceUnit-like object (backwards compat for tests)

string

Full composed source string

SourceMapper

Mapper to resolve absolute offsets to original files

(Section | Block)[]

Array of top-level blocks/sections

parse(unit): (Section | Block)[]

Defined in: packages/speculator/src/parse/types.ts:38

string

string

string

Record<string, string>

number

(Section | Block)[]