Replies: 3 comments 1 reply
-
Hey @EmNudge — the inline styling is provided by Shiki which is what Astro uses to process code blocks by default. However, you can still choose to switch to Prism for syntax highlighting and retain the older behaviour you preferred. See the Syntax highlighting guide in the Astro Docs for more details. |
Beta Was this translation helpful? Give feedback.
-
This seems to be the same as #276 |
Beta Was this translation helpful? Give feedback.
-
If you're OK with using a Rehype plugin, I wrote one that highlights the code blocks with starry-night and adds the language information (amongst other things). It supports applying additional metadata on code blocks (e.g., highlighting lines, prompt indicators, captions, etc). There's no API to add your own metadata though. |
Beta Was this translation helpful? Give feedback.
-
Body
Summary
Add back the parsed language from code blocks into the resulting markup.
Background & Motivation
In earlier versions of Astro, code blocks included the language and did not have inline styling. Currently, code blocks do not have the language included in the resulting markup.
While the code is styled as if it is javascript, the
js
string was not added to any part of the resulting markup. I had code that relied on being able to parse what kind of language the code block was. If it was JavaScript, special considerations could be made.Goals
<pre>
tag.Example
Astro code:
Resulting markup:
Beta Was this translation helpful? Give feedback.
All reactions