ktsu.Frontmatter
1.2.0
Prefix Reserved
dotnet add package ktsu.Frontmatter --version 1.2.0
NuGet\Install-Package ktsu.Frontmatter -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ktsu.Frontmatter" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ktsu.Frontmatter" Version="1.2.0" />
<PackageReference Include="ktsu.Frontmatter" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ktsu.Frontmatter --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ktsu.Frontmatter, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ktsu.Frontmatter@1.2.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ktsu.Frontmatter&version=1.2.0
#tool nuget:?package=ktsu.Frontmatter&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ktsu.Frontmatter
A .NET library for processing and manipulating YAML frontmatter in markdown files.
Features
- Extract, add, replace, and remove frontmatter from markdown documents
- Combine multiple frontmatter sections into a single section
- Standardize property names using intelligent matching
- Sort properties according to standard conventions
- Merge similar properties using different strategies
- High performance with caching for repeated operations
Installation
dotnet add package ktsu.Frontmatter
Usage
using ktsu.Frontmatter;
// Extract frontmatter from a markdown document
string markdown = File.ReadAllText("document.md");
var frontmatter = Frontmatter.ExtractFrontmatter(markdown);
// Add frontmatter to a document
var properties = new Dictionary<string, object>
{
{ "title", "My Document" },
{ "date", DateTime.Now },
{ "tags", new[] { "documentation", "markdown" } }
};
string withFrontmatter = Frontmatter.AddFrontmatter(markdown, properties);
// Replace frontmatter
string replaced = Frontmatter.ReplaceFrontmatter(markdown, properties);
// Remove frontmatter
string withoutFrontmatter = Frontmatter.RemoveFrontmatter(markdown);
// Combine multiple frontmatter sections
string combined = Frontmatter.CombineFrontmatter(markdown);
// Customize property naming and ordering
string customized = Frontmatter.CombineFrontmatter(
markdown,
FrontmatterNaming.Standard, // Standardize property names
FrontmatterOrder.Sorted, // Sort properties in standard order
FrontmatterMergeStrategy.Conservative // Merge similar properties
);
// Extract just the document body (content after frontmatter)
string body = Frontmatter.ExtractBody(markdown);
Advanced Features
Property Naming
Control how property names are handled:
FrontmatterNaming.AsIs
: Keep property names as-isFrontmatterNaming.Standard
: Standardize property names using common conventions
Property Ordering
Control how properties are ordered:
FrontmatterOrder.AsIs
: Keep properties in the order they appearFrontmatterOrder.Sorted
: Sort properties according to standard conventions
Merge Strategies
Control how similar properties are merged:
FrontmatterMergeStrategy.None
: Do not merge any propertiesFrontmatterMergeStrategy.Conservative
: Only merge properties using predefined mappingsFrontmatterMergeStrategy.Aggressive
: Merge properties using basic pattern matchingFrontmatterMergeStrategy.Maximum
: Merge properties using semantic analysis
License
MIT
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- HashDepot (>= 3.1.0)
- ktsu.Extensions (>= 1.5.2)
- ktsu.FuzzySearch (>= 1.2.0)
- YamlDotNet (>= 16.3.0)
-
net9.0
- HashDepot (>= 3.1.0)
- ktsu.Extensions (>= 1.5.2)
- ktsu.FuzzySearch (>= 1.2.0)
- YamlDotNet (>= 16.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
## v1.2.0 (minor)
Changes since v1.1.0:
- Add unit tests for Frontmatter functionality and update solution file ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.1.0 (major)
Changes since 0.0.0.0:
- Initial commit ([@matt-edmondson](https://github.com/matt-edmondson))