
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
@astropub/code
Advanced tools
A lightweight Astro component for syntax highlighting and rendering beautifully formatted code blocks.
Astro Code enables code syntax highlighting and rendering in Astro projects.
Install the component via npm:
npm install @astropub/code
Import and use the component in your Astro files:
---
import Code from "@astropub/code"
---
<Code lang="js" code="const str = 'string'">
To display a syntax-highlighted code block:
---
import Code from "@astropub/code"
---
<Code lang="html" code="<h1>Hello, Astro!</h1>"></Code>
Pass an array of strings to the code prop:
---
import Code from "@astropub/code"
---
<Code lang="css" code={[
"body {",
" margin: 0;",
"}"
]}></Code>
Out of the box, Astro Code supports these languages via Prism.js:
Language | Type Value |
---|---|
Scripting | js jsx ts tsx |
Content | html json svg xml |
Styling | css |
Shell | sh |
Atttribute | Type | Description |
---|---|---|
code | string string[] | Code to render. |
lang | string | Language of highlighting. |
The highlightText
method can be used to highlight a given plain text string with a language.
import { highlightText } from "@astropub/code/highlight"
export const usage = () => {
highlightText("const a = true", "js)
}
The highlightTextNode
method can be used to highlight a Text node with a language.
import { highlightTextNode } from "@astropub/code/highlight"
export const usage = (node: Text) => {
highlightText(node, "js)
}
Licensed under the MIT-0 License.
Enjoy!
FAQs
A lightweight Astro component for syntax highlighting and rendering beautifully formatted code blocks.
The npm package @astropub/code receives a total of 420 weekly downloads. As such, @astropub/code popularity was classified as not popular.
We found that @astropub/code demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.