highlighter.ts — astro Source File
Architecture documentation for highlighter.ts, a typescript file in the astro codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c3f3e4e9_d2b7_1cfa_2a27_54ddbd32ea17["highlighter.ts"] cb6699cf_7bbd_f6fb_8b06_3ad32b8cd143["./plugin.js"] c3f3e4e9_d2b7_1cfa_2a27_54ddbd32ea17 --> cb6699cf_7bbd_f6fb_8b06_3ad32b8cd143 843ebc21_6b03_1189_429e_b5ee11f99cf6["prismjs"] c3f3e4e9_d2b7_1cfa_2a27_54ddbd32ea17 --> 843ebc21_6b03_1189_429e_b5ee11f99cf6 665ec234_be10_b986_d675_d31137a146f6["index.js"] c3f3e4e9_d2b7_1cfa_2a27_54ddbd32ea17 --> 665ec234_be10_b986_d675_d31137a146f6 style c3f3e4e9_d2b7_1cfa_2a27_54ddbd32ea17 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import Prism from 'prismjs';
import loadLanguages from 'prismjs/components/index.js';
import { addAstro } from './plugin.js';
const languageMap = new Map([['ts', 'typescript']]);
export function runHighlighterWithAstro(lang: string | undefined, code: string) {
if (!lang) {
lang = 'plaintext';
}
let classLanguage = `language-${lang}`;
const ensureLoaded = (language: string) => {
if (language && !Prism.languages[language]) {
loadLanguages([language]);
}
};
if (languageMap.has(lang)) {
ensureLoaded(languageMap.get(lang)!);
} else if (lang === 'astro') {
ensureLoaded('typescript');
addAstro(Prism);
} else {
ensureLoaded('markup-templating'); // Prism expects this to exist for a number of other langs
ensureLoaded(lang);
}
if (lang && !Prism.languages[lang]) {
console.warn(`Unable to load the language: ${lang}`);
}
const grammar = Prism.languages[lang];
let html = code;
if (grammar) {
html = Prism.highlight(code, grammar, lang);
}
return { classLanguage, html };
}
Domain
Subdomains
Functions
Dependencies
- ./plugin.js
- index.js
- prismjs
Source
Frequently Asked Questions
What does highlighter.ts do?
highlighter.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 highlighter.ts?
highlighter.ts defines 1 function(s): runHighlighterWithAstro.
What does highlighter.ts depend on?
highlighter.ts imports 3 module(s): ./plugin.js, index.js, prismjs.
Where is highlighter.ts in the architecture?
highlighter.ts is located at packages/astro-prism/src/highlighter.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro-prism/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free