jq for markdown frontmatter.
Download the latest binary from GitHub Releases.
cargo install --path .fmq <expression> [file]- If
fileis omitted, reads from stdin - Queries output the result to stdout
- Mutations output the modified markdown to stdout
# Get a field
fmq '.title' post.md
# Hello World
# Get nested field
fmq '.author.name' post.md
# Alice
# Get array
fmq '.tags' post.md
# ["rust", "cli"]
# From stdin
cat post.md | fmq '.title'# Set a field
fmq '.title = "New Title"' post.md > updated.md
# Add to array
fmq '.tags += ["new-tag"]' post.md > updated.md
# Delete a field
fmq 'del(.draft)' post.md > updated.md
# Update nested field
fmq '.author.name = "Bob"' post.md > updated.md# Query then mutate
fmq '.tags' post.md | jq '.[0]'
# Chain mutations
fmq '.title = "New"' post.md | fmq '.draft = false' > updated.md