DEV Community

Takahiro Sato
Takahiro Sato

Posted on

Compose Your Markdown Workflow: mq Subcommands + Unix Pipes

Piping mq Subcommands Together

mq is a jq-like CLI for Markdown. Beyond its query engine, mq comes with a set of external subcommands:

Subcommand What it does
mq conv Convert Excel, PDF, Word, HTML, etc. to Markdown
mq edit Terminal-based Markdown editor
mq view Markdown viewer
mq task Markdown-based task runner
mq tui Interactive TUI for trying queries

They all work with stdin/stdout, so you can pipe them together.

A Few Examples

Pull headers out of an Excel file:

mq conv report.xlsx | mq edit | mq '.h'
Enter fullscreen mode Exit fullscreen mode

Extract h2s from a Word doc and open them in the editor:

mq conv meeting-notes.docx | mq '.h2' | mq edit
Enter fullscreen mode Exit fullscreen mode

Grab headings from a web page and view them:

curl -s https://mqlang.org | mq -I html 'select(.h1 || .h2)' | mq view
Enter fullscreen mode Exit fullscreen mode

Merge multiple files with separators:

mq -A -S '"---"' 'identity' chapter1.md chapter2.md chapter3.md | mq view
Enter fullscreen mode Exit fullscreen mode

Each subcommand has a single job:

mq conv  → convert to Markdown
mq       → query and transform
mq edit  → edit
mq view  → display
Enter fullscreen mode Exit fullscreen mode

Custom Subcommands

Drop an executable named mq-* into ~/.mq/bin/ or your PATH, and it becomes a subcommand.

mq --list  # see all available subcommands
Enter fullscreen mode Exit fullscreen mode

Links

Top comments (0)