
Product
Socket Threat Intel Now Shows Which Malware Campaigns Were Blocked or Detected
Socket Threat Intel now shows which malware campaigns were blocked or detected in your organization, with links to scans and Firewall events.
markdown-code
Advanced tools
Stop copy-pasting code into documentation. Keep your markdown examples automatically synchronized with real source files.
Your documentation has code examples, but they get outdated:
markdown-code keeps your documentation in sync automatically:
```js
function greet(name) {
return 'Hello ' + name; // Oops, code changed but docs didn't!
}
```
```js snippet=src/utils/greet.js
function greet(name) {
return `Hello, ${name}! Welcome to our app.`; // Always current!
}
```
Result: Your documentation stays accurate as your code evolves.
No installation required - use it directly:
npx markdown-code --help
npx markdown-code init --extract
Or install once, then use the shorter md-code command:
npm install -g markdown-code
Now you can use the convenient md-code binary:
md-code --help
md-code init --extract
Note: All examples in this README show both
npx markdown-codeandmd-codevariants.
Use the snippet= directive in your fenced code blocks:
```ts snippet=path/to/file.ts
// This content will be replaced
```
```ts snippet=path/to/file.ts#L10-L20
// This will include lines 10-20 only
```
```ts snippet=path/to/file.ts#L5
// This will include from line 5 to end of file
```
markdown-code provides two powerful workflows for keeping your documentation in sync with your code:
Perfect for projects with existing markdown documentation that contains code blocks.
Use this when:
How it works:
npx markdown-code check (or md-code check) to discover manageable code blocksnpx markdown-code init --extract (or md-code init --extract) to extract them into snippet filesPerfect for keeping documentation in sync with your actual project source code.
Use this when:
How it works:
npx markdown-code sync (or md-code sync) to populate markdown with current source contentnpx markdown-code check (or md-code check) detects driftnpx markdown-code sync (or md-code sync) to update documentation with latest changes#Lx-Ly syntax.markdown-coderc.json| Command | Description | Example |
|---|---|---|
npx markdown-code / md-code | Update markdown with snippet content (default) | npx markdown-code or md-code |
npx markdown-code sync / md-code sync | Same as above, explicit | npx markdown-code sync or md-code sync |
npx markdown-code check / md-code check | Verify files are in sync (CI-friendly) | npx markdown-code check or md-code check |
npx markdown-code init / md-code init | Create config and snippets directory | npx markdown-code init or md-code init |
npx markdown-code extract / md-code extract | Extract code blocks to snippet files | npx markdown-code extract or md-code extract |
npx markdown-code init --extract / md-code init --extract | Setup + extract in one step | npx markdown-code init --extract or md-code init --extract |
| Option | Description | Example |
|---|---|---|
--config | Custom configuration file | npx markdown-code --config custom.json or md-code --config custom.json |
--snippet-root | Override snippet directory | npx markdown-code --snippet-root ./src or md-code --snippet-root ./src |
--markdown-glob | Override markdown file pattern | npx markdown-code --markdown-glob "docs/**/*.md" or md-code --markdown-glob "docs/**/*.md" |
--exclude-glob | Override exclusion patterns | npx markdown-code --exclude-glob "node_modules/**,dist/**" or md-code --exclude-glob "node_modules/**,dist/**" |
--include-extensions | Override file extensions | npx markdown-code --include-extensions .ts,.js,.py or md-code --include-extensions .ts,.js,.py |
Create a .markdown-coderc.json file in your project root:
{
"snippetRoot": "./snippets",
"markdownGlob": "**/*.md",
"excludeGlob": [
"node_modules/**",
".git/**",
"dist/**",
"build/**",
"coverage/**",
".next/**",
".nuxt/**",
"out/**",
"target/**",
"vendor/**"
],
"includeExtensions": [
".ts",
".js",
".py",
".java",
".cpp",
".c",
".go",
".rs",
".php",
".rb",
".swift",
".kt"
]
}
| Option | Description | Default |
|---|---|---|
| snippetRoot | Base directory for resolving snippet paths | "." |
| markdownGlob | Glob pattern to find Markdown files | "**/*.md" |
| excludeGlob | Array of glob patterns to exclude from processing | Common build/dependency directories |
| includeExtensions | File extensions to consider for snippets and extraction | [".ts", ".js", ".tsx", ".jsx", ".py", ".rb", ".go", ".rs", ".java", ".cpp", ".c", ".cs", ".php", ".sh", ".bash", ".zsh", ".fish", ".json", ".yaml", ".yml", ".toml", ".xml", ".html", ".css", ".scss", ".less", ".sql", ".md", ".txt"] |
See CONTRIBUTING.md for development setup and contribution guidelines.
MIT License - see the LICENSE file for details.
FAQs
Keep code examples in Markdown synchronized with actual source files
The npm package markdown-code receives a total of 506 weekly downloads. As such, markdown-code popularity was classified as not popular.
We found that markdown-code demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.

Product
Socket Threat Intel now shows which malware campaigns were blocked or detected in your organization, with links to scans and Firewall events.

Security News
Fixes for eMudhra and Brotli are out. Getting them everywhere they’re needed means tracking down bundled libraries, runtimes, and certificate stores.

Threat Research
/Security News
Socket uncovered secret-stealing workflows that ran in LiteLLM’s GitHub repository 11 days before the supply chain attack on PyPI and Docker.