mq makes working with Markdown files as easy as jq makes working with JSON. It's especially useful for:
Efficiently manipulate and process Markdown used in LLM prompts and outputs
Extract, transform, and organize content across multiple documentation files
Quickly extract specific sections or patterns from Markdown documents
Apply consistent transformations across multiple Markdown files
Extract specific parts of your Markdown documents with ease
Apply transformations to your Markdown content
Simple and intuitive CLI for quick operations
Easily extendable with custom functions
Filter and transform content with many built-in functions and selectors
Interactive command-line REPL for testing and experimenting
VSCode Extension and Language Server Protocol (LSP) support
# Hello world
select(or(.[], .code, .h)) | upcase() | add(" Hello World")
# Exclude code
select(not(.code))
# Extract js code
.code("js")
# Extract table
.[1][]
# Extract list
.[1]
# Extract MDX
select(is_mdx())
# Custom function
def snake_to_camel(x):
let words = split(x, "_")
| foreach (word, words):
let first_char = upcase(first(word))
| let rest_str = downcase(slice(word, 1, len(word)))
| "${first_char}${rest_str}";
| join("");
| snake_to_camel()