Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Document library

OfficeIMO.Markdown

Build, parse, and render Markdown with a typed AST and fluent API. Multiple reader profiles, HTML rendering, and zero dependencies.

MIT licensed No Office required Cross-platform .NET
Install dotnet add package OfficeIMO.Markdown
Independent first-page render of the generated Markdown release readiness PDF: an evidence table, a checked task list, rollout details and a decision callout
Release readiness report

The Markdown source and themed PDF are generated from one document model. The preview is an independent render of the first-party PDF.

Download source Markdown · View source · Explore the example
C# · excerpt cut from the example source; the full file is linked above
MarkdownDocument document = MarkdownDocument.Create()
    .H1("Release readiness report")
    .P(p => p.Bold("Release 4.2.0").Text(" · candidate ").Code("4.2.0-rc.3").Text(" · decision due Friday"))
    .H2("Readiness summary")
    .Table(table => table
        .Headers("Gate", "Owner", "Result", "Evidence")
        .Row("Automated checks", "Engineering", "Passed", "1,284 tests, 0 failures")
        .Row("Package inspection", "Release manager", "Passed", "Contents and metadata match")
        .Row("Upgrade rehearsal", "Platform", "Passed", "4.1.x to 4.2.0 on staging")
        .Row("Security review", "Security", "Passed", "No open findings")
        .Row("Production approval", "Service owner", "Pending", "Awaiting sign-off"))
    .H2("Release checklist")
    .Ul(list => list
        .ItemTask("Versioned artifacts are reproducible.", done: true)
        .ItemTask("Upgrade and rollback notes are published.", done: true)
        .ItemTask("Monitoring ownership is confirmed.", done: true)
        .ItemTask("Service owner records the approval.", done: false))
    .H2("Rollout")
    .Dl(list => list
        .Item("Window", "Tuesday 06:00-08:00 UTC")
        .Item("Rollback", "Redeploy 4.1.8, about 15 minutes")
        .Item("Owner", "Release manager, on call until noon"))
    .Callout(
        "warning",
        "Decision required",
        "Production publication starts only after the service owner records approval.");

Why OfficeIMO.Markdown?

OfficeIMO.Markdown is a purpose-built Markdown engine for .NET. It gives you a strongly typed AST, a fluent builder for document construction, and multiple reader profiles so you can parse CommonMark, GFM, or OfficeIMO-flavored Markdown with one library. Every node carries source span information, which makes it a practical fit for tooling, linters, and editor integrations.

Features

  • Fluent document builder — construct Markdown documents programmatically with a chainable API
  • Typed block & inline AST model — headings, paragraphs, lists, tables, code blocks, emphasis, links, and images as strongly typed objects
  • Source spans for every node — line, column, and offset tracking for diagnostics and editor support
  • Multiple reader profiles — OfficeIMO, CommonMark, GFM, and Portable profiles with configurable strictness; CommonMark 0.31.2: 652/652 spec examples
  • HTML rendering — emit fragment or full-page HTML with customizable templates
  • Front matter support — read, edit and write YAML front matter, including nested values, through OfficeIMO.Yaml without losing comments or formatting
  • TOC helpers & callouts — generate table of contents from headings and render note/warning/tip callouts
  • Tables from objects — build Markdown tables directly from collections with column selectors
  • Input normalization presets — normalize line endings, whitespace, and encoding before parsing
  • Post-parse document transforms — rewrite, filter, or augment the AST after parsing
  • Extension API — register custom block and inline parsers for domain-specific syntax
  • Zero external dependencies — ships as a single assembly with no third-party references

Quick start

using OfficeIMO.Markdown;

var doc = MarkdownDocument.Create()
    .FrontMatter(new { title = "Release Notes", tags = new[] { "docs", "release" } })
    .H1("Release Notes")
    .P("Version 3.0 introduces several improvements.")
    .H2("New Features")
    .Ul(ul => ul
        .Item("Fluent document builder")
        .Item("Typed AST and traversal helpers")
        .Item("HTML fragment and full-page rendering"))
    .H2("Performance")
    .Table(t => t
        .Headers("Package", "Change", "Owner")
        .Row("OfficeIMO.Markdown", "Typed AST traversal", "Documentation")
        .Row("OfficeIMO.Word.Markdown", "Word conversion", "Automation")
        .Row("OfficeIMO.Markdown.Html", "HTML conversion", "Web"))
    .Code("powershell", "dotnet add package OfficeIMO.Markdown");

string markdown = doc.ToMarkdown();
string html = doc.ToHtml(new MarkdownHtmlExportOptions { Kind = MarkdownHtmlKind.Fragment });

var parsed = MarkdownDocument.Parse(
    markdown,
    MarkdownLoadOptions.CreateGitHubFlavoredMarkdownProfile());

// Inspect the AST
foreach (var block in parsed.DescendantsAndSelf())
{
    Console.WriteLine(block.GetType().Name);
}

Compatibility

Target FrameworkSupported
.NET 10.0Yes
.NET 8.0Yes
.NET Standard 2.0Yes
.NET Framework 4.7.2Yes

The CommonMark profile matches all 652 examples of the official CommonMark 0.31.2 specification, and the GFM profile passes all 52 tracked cmark-gfm extension fixtures. The compatibility matrix lists every extension family and its exact boundary.

OfficeIMO.Markdown runs on Windows, Linux, and macOS. Its checked-in NativeAOT smoke publishes and executes fluent composition and rendering; use the deployment guide to reproduce that baseline and then add the exact extensions your application needs.

GuideDescription
Markdown documentationStart with the package overview and document model.
Builder APICompose documents fluently with headings, tables, and callouts.
PSWriteOffice Markdown cmdletsGenerate Markdown from PowerShell objects and scripts.
Word to MarkdownConvert between Word documents and Markdown workflows.

Same engine, other surfaces

Use OfficeIMO another way

Next step

Turn the package into a working document.

Follow a focused guide and inspect the API reference for this package.

Example source