Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Example

Basic Element Selection

Heading

.h

Extract table

.[1][]

Extract list

.[1]

Code Block Operations

Exclude code

select(!.code)

Extract js code

.code("js")

Extracts the language name from code blocks

.code.lang

Extract MDX

select(is_mdx())
.link.url

Advanced Markdown Processing

Markdown TOC

.h
| let link = to_link("#" + to_text(self), to_text(self), "")
| let level = .h.depth
| if (!is_none(level)): to_md_list(link, to_number(level))

Generate sitemap

def sitemap(item, base_url):
    let path = replace(to_text(item), ".md", ".html")
    | let loc = add(base_url, path)
    | s"<url>
    <loc>${loc}</loc>
    <priority>1.0</priority>
  </url>"
end

Custom Functions and Programming

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)))
      | s"${first_char}${rest_str}";
  | join("")
end
| snake_to_camel()

Map

map(arr, fn(x): x + 1;)

Filter

filter(arr, fn(x): x > 10;)

File Processing

CSV to markdown table

$ mq 'include "csv" | csv_parse(true) | csv_to_markdown_table()' example.csv

Merging Multiple Files

$ mq -S 's"\n${__FILE__}\n"' 'identity()' docs/books/**/**.md