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

rehype-prism.ts — astro Source File

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

File typescript CoreAstro RenderingEngine 4 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  da185abf_9199_136b_bcd0_fc95377bf70f["rehype-prism.ts"]
  cefdad35_fdf4_bf05_5cfc_12d17b85bef1["./highlight.js"]
  da185abf_9199_136b_bcd0_fc95377bf70f --> cefdad35_fdf4_bf05_5cfc_12d17b85bef1
  2832a16b_7543_e831_197a_94bd6022c901["highlighter"]
  da185abf_9199_136b_bcd0_fc95377bf70f --> 2832a16b_7543_e831_197a_94bd6022c901
  f76e2597_e3e8_c502_d293_a666b44d49ce["hast"]
  da185abf_9199_136b_bcd0_fc95377bf70f --> f76e2597_e3e8_c502_d293_a666b44d49ce
  54ce55cc_9dc1_4ebd_28dd_358c1e22d4e7["unified"]
  da185abf_9199_136b_bcd0_fc95377bf70f --> 54ce55cc_9dc1_4ebd_28dd_358c1e22d4e7
  style da185abf_9199_136b_bcd0_fc95377bf70f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { runHighlighterWithAstro } from '@astrojs/prism/dist/highlighter';
import type { Root } from 'hast';
import type { Plugin } from 'unified';
import { highlightCodeBlocks } from './highlight.js';

export const rehypePrism: Plugin<[string[]?], Root> = (excludeLangs) => {
	return async (tree) => {
		await highlightCodeBlocks(
			tree,
			(code, language) => {
				let { html, classLanguage } = runHighlighterWithAstro(language, code);

				return Promise.resolve(
					`<pre class="${classLanguage}" data-language="${language}"><code class="${classLanguage}">${html}</code></pre>`,
				);
			},
			excludeLangs,
		);
	};
};

Domain

Subdomains

Functions

Dependencies

  • ./highlight.js
  • hast
  • highlighter
  • unified

Frequently Asked Questions

What does rehype-prism.ts do?
rehype-prism.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-prism.ts?
rehype-prism.ts defines 1 function(s): rehypePrism.
What does rehype-prism.ts depend on?
rehype-prism.ts imports 4 module(s): ./highlight.js, hast, highlighter, unified.
Where is rehype-prism.ts in the architecture?
rehype-prism.ts is located at packages/markdown/remark/src/rehype-prism.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