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.
remark-code-blocks
Advanced tools
Remark plugin to extract
code
nodes from markdown.
npm i -S remark-code-blocks
const toVfile = require('to-vfile')
const unified = require('unified')
const parser = require('remark-parser')
const stringify = require('remark-stringify')
const codeblocks = require('remark-code-blocks')
unified()
.use(parser)
.use(stringify)
.use(codeblocks, { /* options */ })
.process(toVfile('./example.md'))
.then(file => {
/* file.data.codeblocks = [ ... ] */
})
or use the standalone function which takes a tree as its first argument.
const toVfile = require('to-vfile')
const unified = require('unified')
const parser = require('remark-parser')
const { codeblocks } = require('remark-code-blocks')
const tree = unified().use(parser).parse(toVfile('./example.md'))
const code = codeblocks(tree, { /* options */ })
Use as a plugin to extract code nodes.
The results are stored in file.data
in a codeblocks
property by default. You can override the name of the property using options.name
.
Also exports a standalone function.
Type: string
Default: all
Specify a language and only extract code nodes with that language. Otherwise all
code nodes are extracted.
Type: string
Default: codeblocks
Specify the name of the property in file.data
Type: function
Default: none
Add a function to run over the nodes values before storing them in file.data
MIT © Paul Zimmer
FAQs
Extract code blocks from an MDAST tree
The npm package remark-code-blocks receives a total of 1,045 weekly downloads. As such, remark-code-blocks popularity was classified as popular.
We found that remark-code-blocks demonstrated a not healthy version release cadence and project activity because the last version was released 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.