MarkdigExtensions.Query 1.0.7

dotnet add package MarkdigExtensions.Query --version 1.0.7
                    
NuGet\Install-Package MarkdigExtensions.Query -Version 1.0.7
                    
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="MarkdigExtensions.Query" Version="1.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MarkdigExtensions.Query" Version="1.0.7" />
                    
Directory.Packages.props
<PackageReference Include="MarkdigExtensions.Query" />
                    
Project file
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 MarkdigExtensions.Query --version 1.0.7
                    
#r "nuget: MarkdigExtensions.Query, 1.0.7"
                    
#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 MarkdigExtensions.Query@1.0.7
                    
#: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=MarkdigExtensions.Query&version=1.0.7
                    
Install as a Cake Addin
#tool nuget:?package=MarkdigExtensions.Query&version=1.0.7
                    
Install as a Cake Tool

MarkdigExtensions.Query Logo

MarkdigExtensions.Query ๐Ÿ“„๐Ÿ”

NuGet version

MarkdigExtensions.Query is a powerful, jQuery-style query engine for traversing, filtering, and manipulating Markdown documents in .NET. Built on top of the Markdig Markdown parser, it provides an expressive API for searching and transforming Markdown nodes with CSS-like selectors and familiar LINQ-style chaining.


๐Ÿš€ Features

  • ๐Ÿ”Ž CSS-style Selectors: Query blocks and inlines with tags (h1, link, table), attributes, wildcards, and combinators.
  • ๐Ÿงฉ Chaining & Filtering: Use .Where(), .Select(), .NextUntil(), and more for precise control.
  • โšก Pseudo-Selectors: Supports first-child, last-child, even, odd, nth-child(n).
  • ๐Ÿ’ฌ Text & HTML Access: Easily get .InnerText, .InnerHtml, .ToMarkdown() from any node.
  • ๐Ÿ”ง Node Metadata: Use .Attr() to inspect node details like href, level, or isImage.
  • ๐Ÿงต Sibling & Linear Traversals: Navigate using NextUntil, PrevUntil, or Between.

๐Ÿ“ฆ Installation

Install from NuGet:

dotnet add package MarkdigExtensions.Query

๐Ÿ› ๏ธ Getting Started

using Markdig;
using MarkdigExtensions.Query;

// Parse a Markdown document
var markdown = """
# Welcome to the Test Suite

This document is **bold** and ![an image](img.png).

---

## Next Section
""";

var doc = Markdown.Parse(markdown);

// Query all heading blocks
var headings = doc.QueryBlocks("h1, h2");

// Get text from the first heading
var title = headings.First().InnerText; // "Welcome to the Test Suite"

// Find all paragraphs between H1 and HR
var section = doc.QueryBlock("h1")?.NextUntil("hr");

๐Ÿ” Selector Syntax

Selector Description
h1 Matches all level 1 headings
link[href] Matches links with an href attribute
heading > strong Matches strong text directly inside headings
image, link Matches either image or link elements
* Matches any block or inline node

Pseudo-classes:

  • first-child
  • last-child
  • even
  • odd
  • nth-child(n)

๐Ÿง  API Overview

Query Methods

document.QueryBlocks("selector")

Returns IEnumerable<MarkdownNode>


MarkdownNode Access

node.InnerText       // Clean text content
node.InnerHtml       // HTML rendering
node.ToMarkdown()    // Original markdown
node.Attr("href")    // e.g., link URL
node.Attr()          // Dictionary of attributes

Traversal

node.NextUntil("selector", includeStart: false, includeEnd: false, blockOnly: true)
node.PrevUntil("selector")
node.Between(startNode, endNode)

๐Ÿ”ง Advanced Examples

Group all paragraphs between two headings

var intro = doc
    .QueryBlock("h1")
    ?.NextUntil("h2", includeStart: false, includeEnd: false);

Select all emphasized text inside a paragraph

var emphasis = doc.QueryBlock("paragraph emphasis");

Wildcard + pseudo-class combo

var firstOfEach = doc.QueryBlock("*:first-child");

โœ… Use Cases

  • Build markdown content editors or analyzers
  • Wrap sections between headings
  • Validate document structure
  • Extract or transform specific content programmatically


Thanks for using MarkdigExtensions.Query! Enjoy writing powerful, expressive markdown transformations โ€” just like jQuery for documents.

Product Compatible and additional computed target framework versions.
.NET 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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MarkdigExtensions.Query:

Package Downloads
VeeFriends.WikiImporter

VeeFriends Wiki Importer - A .NET library for automating the import of character data from ClickUp, enhanced with AI and media integrations.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.7 295 7/14/2025
1.0.6 127 7/11/2025
1.0.5 140 7/8/2025
1.0.4 128 7/8/2025