shikidown
API reference

Types

Every type exported from the shikidown entry point.

import type {
  MarkdownConfig,
  MarkdownItInstance,
  MarkdownThemePair,
  ComponentModule,
  ComponentModuleSource,
  ParsedBlock,
  RenderedBlock,
} from 'shikidown';

MarkdownConfig

The object accepted by provideMarkdown(). Every field is optional.

interface MarkdownConfig {
  theme?: StringLiteralUnion<BundledTheme> | MarkdownThemePair;
  extraThemes?: ThemeInput[];
  languages?: StringLiteralUnion<BundledLanguage>[];
  extraLanguages?: LanguageInput[];
  components?: Record<string, Type<unknown>>;
  componentModules?: ComponentModuleSource[];
  plugins?: MarkdownItPluginSource[];
  markdownOptions?: MarkdownItOptions;
  incrementalRendering?: boolean;
  blockCacheSize?: number;
}

theme and languages reuse Shiki's own StringLiteralUnion types, so you get the bundled names as autocomplete suggestions while still being able to pass a custom one — but only the names in DEFAULT_THEME_NAMES/DEFAULT_LANGUAGE_NAMES are actually preloaded by shikidown itself. extraThemes/extraLanguages take ThemeInput/LanguageInput, the raw types @shikijs/core accepts, for themes/languages your own app imports and preloads on top of those defaults. Field-by-field defaults are in Configuration.

MarkdownItOptionshtml, xhtmlOut, breaks, langPrefix, linkify, typographer, quotes — is an internal type, not exported. Pass an object literal and TypeScript will check it structurally.


MarkdownItInstance

The type of a markdown-it instance — what a plugins entry receives.

type MarkdownItInstance = InstanceType<typeof MarkdownIt>;

Use it to type a plugin you write yourself:

import type { MarkdownItInstance } from 'shikidown';

function myPlugin(md: MarkdownItInstance): void {
  md.use(/* … */);
}

Reach for this instead of markdown-it's default export. Across v14 and v15 that export is not the same kind of symbol — a class in v14, a callable const in v15 — and only the latter fails when used in type position (TS2749: 'MarkdownIt' refers to a value, but is being used as a type here). MarkdownItInstance resolves correctly under both.


MarkdownThemePair

interface MarkdownThemePair {
  dark: StringLiteralUnion<BundledTheme>;
  light: StringLiteralUnion<BundledTheme>;
}

Passing a pair rather than a single string makes Shiki emit both themes in one pass — light as inline styles, dark as --shiki-dark-* CSS variables. See Dual-theme code blocks.


ComponentModule

type ComponentModule = Record<string, unknown>;

A module that exports components. Exports which are not components are ignored, so this is deliberately as loose as import * as demos from './demos' really is.


ComponentModuleSource

type ComponentModuleSource = ComponentModule | (() => Promise<ComponentModule>);

Either an already-imported module, or a loader that returns one. The loader form is what keeps a page's components out of the initial bundle:

const sources: ComponentModuleSource[] = [
  demos,                              // eager
  () => import('./page.demos'),       // lazy
];

See Lazy-loaded components.


ParsedBlock

interface ParsedBlock {
  readonly hash: string;
  readonly startLine: number;
  readonly endLine: number;
  readonly tokens: MdToken[];
  readonly source: string;
}

A group of consecutive markdown-it tokens forming one self-contained root block.

FieldMeaning
hashFNV-1a hash of source, hex — the block's stable identity
startLine0-based, inclusive
endLine0-based, exclusive
tokensThe token subset to hand to md.renderer.render()
sourceRaw source text, used as the cache key

ParsedBlock is an intermediate shape: no public method returns it. It is exported so you can type your own token-level tooling.


RenderedBlock

interface RenderedBlock {
  readonly hash: string;
  readonly html: string;
}

What parseBlocksAsync() returns. html is a raw string, not SafeHtml — sanitisation is the caller's decision.

Use hash as the tracking key when rendering the list yourself:

@for (block of blocks(); track block.hash) {
  <div [innerHTML]="block.html"></div>
}

Not exported

Some symbols are visible in the source but deliberately kept out of the public API. They are listed here so you do not go looking for them.

SymbolWhy
MARKDOWN_CONFIGInjection token, an implementation detail. Configure through provideMarkdown().
MARKDOWN_COMPONENTSProvided by provideMarkdown() but not read anywhere — treat it as absent.
MarkdownItOptionsStructural type; pass an object literal instead.
MdTokenAlias of markdown-it's own token type — import it from markdown-it.
hashSource()The FNV-1a helper. Block hashes are already exposed on ParsedBlock and RenderedBlock.

On this page