MQNet 0.5.34

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

MQNet

Tests CI NuGet

A .NET wrapper for mq — a jq-like query tool for Markdown. Query headings, code blocks, paragraphs, and more using a simple, composable query language.

How it works

MQNet is a thin managed wrapper around the native mq-ffi library, which is compiled from the mq Rust crate. At runtime, .NET's P/Invoke loads the platform-native binary (mq_ffi.dll / libmq_ffi.so / libmq_ffi.dylib) and marshals calls across the native boundary.

The package ships in two layers:

  • MQNet — the managed API you reference in your project.
  • MQNet.Runtime.<rid> — thin packages containing only the native binary for a specific platform (e.g. MQNet.Runtime.linux-x64). NuGet's runtime identifier graph selects the right one automatically at restore time.

You only need to install MQNet; the correct native binary is pulled in automatically.

Installation

dotnet add package MQNet

MQNet uses a split NuGet package model. The main package contains the managed library; native binaries are in separate runtime packages that NuGet resolves automatically based on your platform:

Platform Runtime Package
Windows x64 MQNet.Runtime.win-x64
Windows ARM64 MQNet.Runtime.win-arm64
Linux x64 MQNet.Runtime.linux-x64
Linux ARM64 MQNet.Runtime.linux-arm64
macOS x64 MQNet.Runtime.osx-x64
macOS ARM64 MQNet.Runtime.osx-arm64

Quick Start

using MQNet;

// Fluent API — quick one-shot queries
var result = Mq.Query(".h(1)")
    .On("# Hello\n\n## World\n\n# Another")
    .Run();

// result[0]  → "# Hello"
// result[1]  → "# Another"
// result.Text → "# Hello\n# Another"

Usage

Fluent API

// Extract all H2 headings
var headings = Mq.Query(".h(2)").On(markdown).Run();

// Filter headings containing a word
var filtered = Mq.Query(".h | select(contains(\"API\"))").On(markdown).Run();

// Extract code blocks by language
var rustBlocks = Mq.Query(".code(\"rust\")").On(markdown).Run();

// Query from HTML input
var result = Mq.Query(".h(1)")
    .On("<h1>Title</h1><p>Body</p>")
    .WithFormat(InputFormat.Html)
    .Run();

// Query plain text line by line
var matches = Mq.Query("select(contains(\"error\"))")
    .On(logOutput)
    .WithFormat(InputFormat.Text)
    .Run();

MqEngine (reuse across multiple queries)

using var engine = new MqEngine();

var h1 = engine.Eval(".h(1)", markdown);
var code = engine.Eval(".code", markdown);
var links = engine.Eval(".link", markdown);

HTML to Markdown conversion

// Basic conversion
string markdown = MqEngine.HtmlToMarkdown("<h1>Hello</h1><p>World</p>");

// With options
string markdown = MqEngine.HtmlToMarkdown(html, new ConversionOptions
{
    UseTitleAsH1 = true,
    GenerateFrontMatter = true,
    ExtractScriptsAsCodeBlocks = true
});

Working with results

MqResult result = Mq.Query(".h").On(markdown).Run();

result.Count       // number of matches
result[0]          // first match
result.Values      // IReadOnlyList<string>
result.Text        // all matches joined by "\n"

foreach (var item in result)
    Console.WriteLine(item);

Input Formats

Format Description
InputFormat.Markdown CommonMark / GFM Markdown (default)
InputFormat.Mdx Markdown with JSX (MDX)
InputFormat.Html HTML — auto-converted to Markdown before querying
InputFormat.Text Plain text, split by lines
InputFormat.Raw Raw string, no parsing

Requirements

  • .NET 8 or .NET 10
  • Supported platforms: Windows x64/ARM64, Linux x64/ARM64, macOS x64/ARM64

mq Query Language

MQNet wraps the mq Rust library. For the full query language reference, see the mq documentation.

Some common queries:

.h          # all headings
.h(1)       # H1 headings only
.h(2)       # H2 headings only
.code       # all code blocks
.code("go") # code blocks with language "go"
.p          # paragraphs
.link       # links
.image      # images
.list       # list items

# Combinators
.h | select(contains("API"))         # headings containing "API"
.h | map(ascii_downcase)             # lowercase all headings
.code | select(startswith("fn "))    # code blocks starting with "fn "

License

MIT — see LICENSE.

This project wraps mq by harehare, which is also MIT licensed.

Product 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 was computed.  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 is compatible.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.34 88 6/13/2026
0.5.32 94 6/8/2026
0.5.31 94 6/8/2026