Co-authored-by: Nate Moore <nate@astro.build>
This commit is contained in:
parent
51847a276f
commit
1f0dd31d92
3 changed files with 9 additions and 8 deletions
7
.changeset/old-pears-design.md
Normal file
7
.changeset/old-pears-design.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
'@astrojs/prism': patch
|
||||
---
|
||||
|
||||
Fix `<Prism />` component indentation
|
||||
|
||||
Prefer `class="language-plaintext"` to `class="language-undefined"`
|
|
@ -11,8 +11,4 @@ const { class: className, lang, code } = Astro.props as Props;
|
|||
const { classLanguage, html } = runHighlighterWithAstro(lang, code);
|
||||
---
|
||||
|
||||
<pre
|
||||
class={[className, classLanguage].join(
|
||||
' '
|
||||
)}> <code class={classLanguage}><Fragment set:html={html} /></code>
|
||||
</pre>
|
||||
<pre class={[className, classLanguage].filter(Boolean).join(' ')}><code class={classLanguage} set:html={html} /></pre>
|
||||
|
|
|
@ -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]);
|
||||
|
|
Loading…
Reference in a new issue