Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

@nousdev/plugin-shiki

Syntax highlighting transform plugin for the Nous pipeline, powered by Shiki.

Installation

npm install @nousdev/plugin-shiki

Usage

import { createShikiPlugin } from '@nousdev/plugin-shiki';

const plugin = createShikiPlugin({
  theme: 'github-dark',
  darkTheme: 'github-dark-dimmed',
  languages: ['typescript', 'python', 'bash'],
});

// Register with the Nous build pipeline
const result = await buildAll({
  // ...
  plugins: [plugin],
});

The plugin walks the NDM tree during the transform phase, locates codeBlock nodes with a language annotation, and injects pre-rendered highlighted HTML via Shiki. The raw value is preserved for copy-to-clipboard and AI indexing.

Language grammars are loaded on demand with deduplication to prevent race conditions during concurrent highlighting.

API

createShikiPlugin(options?: ShikiPluginOptions): NousPlugin

Returns a Nous transform plugin that applies Shiki syntax highlighting to all code blocks in the document tree.

ShikiPluginOptions

Option Type Default Description
theme string? 'github-dark' Shiki theme for syntax highlighting
darkTheme string? -- Optional second theme for dual-theme rendering
languages string[]? All bundled Restrict which language grammars to load. Unlisted languages render as plain text.

Shiki supports all languages bundled with TextMate grammars. Refer to the Shiki languages list for available identifiers.

Dependencies

  • @nousdev/types
  • shiki

Part of Nous

This package is part of Nous, an adaptive documentation infrastructure that transforms Markdown into agent-ready knowledge.

License

MIT