Skip to content
Yuval Shavit edited this page Aug 7, 2024 · 18 revisions

Tip

This page is a quick cheat-sheet for mdq's syntax.

Check out the tutorial or full user manual for more detail.

Piping

'# within some header | - look for lists | [with links]()'
                     ^^^                ^^^

Make sure to quote the selector string, so that your shell doesn't interpret the pipes and other special characters. I recommend using ' unless you have apostrophes you need to match against.

Selectors

# section title
[link text](url)
![img alt](url)
- unordered list item
1. ordered list item
- [ ] uncompleted task
- [x] completed task
- [?] any task
> block quotes
``` code-block
```language code-block
</> html
P: paragraph text
:-: table headers :-: table rows

String matching

An empty string matcher matches all elements; you can also use * to make that explicit

unquoted text when unambiguous (must start with a letter)
matches any substring; prefix and trailing whitespace is trimmed
cAsE iNsEnSiTiVe
^☚can anchor to the start of a string...
or to the end... ☛$
^☚ or to both, for full string matching ☛$
"quoted text with \" escapes, including \u{2603} unicode"
^"☚ also supports anchors ☛"$
'matches any substring; prefix and trailing whitespace is NOT trimmed'
"Case Sensitive"
/reg(ex|ular expressions)/
/^ *\(also match substring, unless anchored\)$/

String escapes

Mostly the usual, but two of note:

\u{2603} ⮕ ☃
\`       ⮕ '
  • unicode code points are \u{...}, with 1 - 6 hex digits
  • you can get a single quote (') by escaping a backtick. Note that this nonstandard: an escaped backtick translates to a straight single-quote. See the full manual for the rationale.

JSON

-o json
Clone this wiki locally