
Company News
Socket Partners with Replit to Block Malicious Packages in AI-Powered Development
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.
mdast-util-substitute
Advanced tools
mdast utility to parse and serialize inline substitution (:sub[...]{...})
mdast utilities for inline substitution (:sub[INITIAL]{REPLACEMENT}).
Inline substitution enables progressive disclosure — show brief content initially, reveal full content on activation. This package provides the mdast utilities; for a complete solution, use remark-substitute.
npm install mdast-util-substitute
import { fromMarkdown } from 'mdast-util-from-markdown'
import { toMarkdown } from 'mdast-util-to-markdown'
import { sub } from 'micromark-extension-substitute'
import { subFromMarkdown, subToMarkdown } from 'mdast-util-substitute'
// Parse
const tree = fromMarkdown(':sub[initial]{replacement}', {
extensions: [sub()],
mdastExtensions: [subFromMarkdown()]
})
// Stringify
const md = toMarkdown(tree, {
extensions: [subToMarkdown()]
})
Subinterface Sub extends Parent {
type: 'sub'
children: PhrasingContent[] // Empty at this layer
data: {
replacement: PhrasingContent[] // Empty at this layer
rawInitial: string // Raw INITIAL text (escapes processed)
rawReplacement: string // Raw REPLACEMENT text (escapes processed)
}
}
At the mdast-util layer, raw content is stored in rawInitial and rawReplacement. The children and replacement arrays are populated later by remark-substitute, which re-parses the raw content as inline Markdown.
When serializing to markdown:
] in INITIAL is escaped as \]} in REPLACEMENT is escaped as \}MIT
FAQs
mdast utility to parse and serialize inline substitution (:sub[...]{...})
We found that mdast-util-substitute 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.

Company News
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.

Security News
npm confirmed a tooling bug incorrectly marked several one-character packages as security holders and said it was working on a rollback.

Research
/Security News
Newer packages in this compromise use native extensions and .pth loaders to execute JavaScript stealers in developer environments.