plugin.ts — astro Source File
Architecture documentation for plugin.ts, a typescript file in the astro codebase.
Entity Profile
Relationship Graph
Source Code
export function addAstro(Prism: typeof import('prismjs')) {
if (Prism.languages.astro) {
return;
}
let scriptLang: string;
if (Prism.languages.typescript) {
scriptLang = 'typescript';
} else {
scriptLang = 'javascript';
console.warn(
'Prism TypeScript language not loaded, Astro scripts will be treated as JavaScript.',
);
}
let script = Prism.util.clone(Prism.languages[scriptLang]);
// eslint-disable-next-line regexp/no-useless-assertions
let space = /(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source;
let braces = /(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source;
let spread = /(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;
function re(source: string, flags?: string) {
source = source
.replace(/<S>/g, function () {
return space;
})
.replace(/<BRACES>/g, function () {
return braces;
})
.replace(/<SPREAD>/g, function () {
return spread;
});
return RegExp(source, flags);
}
spread = re(spread).source;
Prism.languages.astro = Prism.languages.extend('markup', script);
(Prism.languages.astro as any).tag.pattern = re(
/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/
.source,
);
(Prism.languages.astro as any).tag.inside['tag'].pattern = /^<\/?[^\s>/]*/;
(Prism.languages.astro as any).tag.inside['attr-value'].pattern =
/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/;
(Prism.languages.astro as any).tag.inside['tag'].inside['class-name'] =
/^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
(Prism.languages.astro as any).tag.inside['comment'] = script['comment'];
Prism.languages.insertBefore(
'inside',
'attr-name',
{
spread: {
pattern: re(/<SPREAD>/.source),
inside: Prism.languages.astro,
},
// ... (128 more lines)
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does plugin.ts do?
plugin.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 plugin.ts?
plugin.ts defines 1 function(s): addAstro.
Where is plugin.ts in the architecture?
plugin.ts is located at packages/astro-prism/src/plugin.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