Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Architecture

The plugin is a three-stage pipeline, one file per stage:

src/plugin.ts also wires the stages together, and src/shared.ts holds a few helpers they share.

Placeholder
The listingPlaceholder node the {listing} directive emits. It carries the directive’s options, and the pipeline fills it in and finally replaces it.
Collector
The code behind a :source:. It sets the placeholder’s items (see Add a collector).
Item
The plain object that flows between the stages, one per listed thing. See Items for the fields it carries.
Transform
selectItems in src/transform.ts. It filters, sorts, and limits the items.
Display
The code behind a :display:. It turns the selected items into one AST node.

Why three stages

The design came from several one-off plugins, listed below, that each hand-rolled their own collect-and-display logic. It separates the stages so that other plugins can reuse the same displays; if that turns out to be more complex than it’s worth, we’ll simplify it.

Use cases it was built for

This was designed to be a single tool that could be re-used across these use-cases:

For built-in functionality:

For plugin-level extensions functionality (ie, we want other MyST plugins to extend myst-listing functionality to meet these extra use-cases):