Home / File/ rehype-shiki.ts — astro Source File

rehype-shiki.ts — astro Source File

Architecture documentation for rehype-shiki.ts, a typescript file in the astro codebase. 5 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 5 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  7bd3a558_f9fb_1400_68d9_87e777276501["rehype-shiki.ts"]
  cefdad35_fdf4_bf05_5cfc_12d17b85bef1["./highlight.js"]
  7bd3a558_f9fb_1400_68d9_87e777276501 --> cefdad35_fdf4_bf05_5cfc_12d17b85bef1
  071212f5_2d93_d106_2e4e_681b5f27b774["./shiki.js"]
  7bd3a558_f9fb_1400_68d9_87e777276501 --> 071212f5_2d93_d106_2e4e_681b5f27b774
  2ebb1f90_a903_fafc_eb9b_ce29b5c61608["./types.js"]
  7bd3a558_f9fb_1400_68d9_87e777276501 --> 2ebb1f90_a903_fafc_eb9b_ce29b5c61608
  f76e2597_e3e8_c502_d293_a666b44d49ce["hast"]
  7bd3a558_f9fb_1400_68d9_87e777276501 --> f76e2597_e3e8_c502_d293_a666b44d49ce
  54ce55cc_9dc1_4ebd_28dd_358c1e22d4e7["unified"]
  7bd3a558_f9fb_1400_68d9_87e777276501 --> 54ce55cc_9dc1_4ebd_28dd_358c1e22d4e7
  style 7bd3a558_f9fb_1400_68d9_87e777276501 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { Root } from 'hast';
import type { Plugin } from 'unified';
import { highlightCodeBlocks } from './highlight.js';
import { createShikiHighlighter, type ShikiHighlighter } from './shiki.js';
import type { ShikiConfig } from './types.js';

export const rehypeShiki: Plugin<[ShikiConfig, string[]?], Root> = (config, excludeLangs) => {
	let highlighterAsync: Promise<ShikiHighlighter> | undefined;

	return async (tree) => {
		highlighterAsync ??= createShikiHighlighter({
			langs: config?.langs,
			theme: config?.theme,
			themes: config?.themes,
			langAlias: config?.langAlias,
		});
		const highlighter = await highlighterAsync;

		await highlightCodeBlocks(
			tree,
			(code, language, options) => {
				return highlighter.codeToHast(code, language, {
					meta: options?.meta,
					wrap: config?.wrap,
					defaultColor: config?.defaultColor,
					transformers: config?.transformers,
				});
			},
			excludeLangs,
		);
	};
};

Domain

Subdomains

Functions

Dependencies

  • ./highlight.js
  • ./shiki.js
  • ./types.js
  • hast
  • unified

Frequently Asked Questions

What does rehype-shiki.ts do?
rehype-shiki.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in rehype-shiki.ts?
rehype-shiki.ts defines 1 function(s): rehypeShiki.
What does rehype-shiki.ts depend on?
rehype-shiki.ts imports 5 module(s): ./highlight.js, ./shiki.js, ./types.js, hast, unified.
Where is rehype-shiki.ts in the architecture?
rehype-shiki.ts is located at packages/markdown/remark/src/rehype-shiki.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/markdown/remark/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free