From 1f0dd31d9239b5e3dca99c88d021e7a9a3e2054d Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Thu, 11 Aug 2022 10:59:48 -0500 Subject: [PATCH] fix(#4246): fix Prism indentation and class (#4251) Co-authored-by: Nate Moore --- .changeset/old-pears-design.md | 7 +++++++ packages/astro-prism/Prism.astro | 6 +----- packages/astro-prism/src/highlighter.ts | 4 +--- 3 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 .changeset/old-pears-design.md diff --git a/.changeset/old-pears-design.md b/.changeset/old-pears-design.md new file mode 100644 index 000000000..e31be82ac --- /dev/null +++ b/.changeset/old-pears-design.md @@ -0,0 +1,7 @@ +--- +'@astrojs/prism': patch +--- + +Fix `` component indentation + +Prefer `class="language-plaintext"` to `class="language-undefined"` diff --git a/packages/astro-prism/Prism.astro b/packages/astro-prism/Prism.astro index 44cf4748a..fab9dafe2 100644 --- a/packages/astro-prism/Prism.astro +++ b/packages/astro-prism/Prism.astro @@ -11,8 +11,4 @@ const { class: className, lang, code } = Astro.props as Props; const { classLanguage, html } = runHighlighterWithAstro(lang, code); --- -
	
-
+
diff --git a/packages/astro-prism/src/highlighter.ts b/packages/astro-prism/src/highlighter.ts index 3dffefae9..c0e58054e 100644 --- a/packages/astro-prism/src/highlighter.ts +++ b/packages/astro-prism/src/highlighter.ts @@ -5,12 +5,10 @@ import { addAstro } from './plugin.js'; const languageMap = new Map([['ts', 'typescript']]); export function runHighlighterWithAstro(lang: string | undefined, code: string) { - let classLanguage = `language-${lang}`; - if (!lang) { lang = 'plaintext'; } - + let classLanguage = `language-${lang}`; const ensureLoaded = (language: string) => { if (language && !Prism.languages[language]) { loadLanguages([language]);