Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@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 220 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.