mdz.ts

mdz - minimal markdown dialect for Fuz documentation.

Parses an enhanced markdown dialect with: - inline formatting: code, bold, italic, strikethrough - auto-detected links: external URLs (https://...) and internal paths (/path) - markdown links: [text](url) with custom display text - inline code in backticks (creates Code nodes; auto-linking to identifiers/modules is handled by the rendering layer via MdzNodeView.svelte) - paragraph breaks (double newline) - block elements: headings, horizontal rules, code blocks - HTML elements and Svelte components (opt-in via context)

Key constraint: preserves ALL whitespace exactly as authored, and is rendered with white-space pre or pre-wrap.

Design philosophy

- False negatives over false positives: When in doubt, treat as plain text. Block elements can interrupt paragraphs without blank lines; inline formatting is strict. - One way to do things: Single unambiguous syntax per feature. No alternatives. - Explicit over implicit: Clear delimiters and column-0 requirements avoid ambiguity. - Simple over complete: Prefer simple parsing rules over complex edge case handling.

Status

This is an early proof of concept with missing features and edge cases.

Declarations
#

16 declarations

view source

mdz_parse
#

MdzBaseNode
#

MdzBoldNode
#

MdzCodeblockNode
#

MdzCodeNode
#

MdzComponentNode
#

MdzElementNode
#

MdzHeadingNode
#

mdz.ts view source

MdzHeadingNode

inheritance

extends:

type

type 'Heading'

level

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

id

type string

children

type Array<MdzNode>

MdzHrNode
#

MdzItalicNode
#

MdzLinkNode
#

mdz.ts view source

MdzLinkNode

inheritance

extends:

type

type 'Link'

reference

type string

children

type Array<MdzNode>

link_type

type 'external' | 'internal'

MdzNode
#

MdzParagraphNode
#

MdzParser
#

mdz.ts view source

Parser for mdz format. Single-pass lexer/parser with text accumulation for efficiency. Used by mdz_parse, which should be preferred for simple usage.

constructor

type new (template: string): MdzParser

template
type string

parse

Main parse method. Returns flat array of nodes, with paragraph nodes wrapping content between double newlines.

Block elements (headings, HR, codeblocks) are detected at every column-0 position — they can interrupt paragraphs without requiring blank lines.

type (): MdzNode[]

returns MdzNode[]

MdzStrikethroughNode
#

MdzTextNode
#

Depends on
#

Imported by
#