Skip to main content
net10.0.NETFramework4.8net8.0net9.0.NETStandard2.0.NETStandard2.1

Extracts snippets from code files and merges them into markdown documents.

Published
Sep 27, 2026
22d ago
Total Downloads
146.2K
146,188

Install

dotnet add package MarkdownSnippets --version 28.5.0
ProductVersions
.NET
net10.0net8.0net9.0
.NET Standard
netstandard2.0netstandard2.1
Other
.NETFramework4.8

README

MarkdownSnippets

A dotnet tool or MsBuild Task that extract snippets from code files and merges them into markdown documents.

See https://github.com/SimonCropp/MarkdownSnippets for full documentation.

Behavior

  • Recursively scan the target directory for code files containing snippets.
  • Recursively scan the target directory for markdown (.md or mdx) files.
  • Merge the snippets into those markdown files.

Installation

Ensure dotnet CLI is installed.

Install MarkdownSnippets.Tool

dotnet tool install -g MarkdownSnippets.Tool

Usage

mdsnippets C:\Code\TargetDirectory

If no directory is passed the current directory will be used, but only if it exists with a git repository directory tree. If not an error is returned.

Defining Snippets

Any code wrapped in a convention based comment will be picked up. The comment needs to start with begin-snippet: which is followed by the key. The snippet is then terminated by end-snippet.

// begin-snippet: MySnippetName
My Snippet Code
// end-snippet

Named C# regions will also be picked up, with the name of the region used as the key.

#region MySnippetName
My Snippet Code
#endregion

Using Snippets in Markdown

The raw snippet key can be used in any markdown document by subsequent surrounding it with snippet::

<!-- snippet: MySnippetName -->

Changes from Previous Version

No structural changes between v28.4.4 and v28.5.0.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 6 target frameworks; confirm the exact target used by your application.The published metadata declares 15 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.