jq like tool for markdown processing

View on GitHub

What is mq?

mq is a command-line tool that processes Markdown using a syntax similar to jq. It's written in Rust, allowing you to easily slice, filter, map, and transform structured data.

✨ Features

  • 🔍
    Slice and Filter: Extract specific parts of your Markdown documents with ease.
  • 🔄
    Map and Transform: Apply transformations to your Markdown content.
  • 💻
    Command-line Interface: Simple and intuitive CLI for quick operations.
  • 🔌
    Extensibility: Easily extendable with custom functions.
  • 🛠️
    Built-in support: Filter and transform content with many built-in functions and selectors.
  • 🎯
    REPL Support: Interactive command-line REPL for testing and experimenting.
  • 🎨
    IDE Support: VSCode Extension and Language Server Protocol (LSP) support for custom function development.
# 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)))
      | add(first_char, rest_str);
  | join("");
| snake_to_camel()