Code Block Configuration
You can write Map of Content (MOC) queries manually in any markdown file by creating a code block with the language set to moc and adding a YAML configuration.
Syntax Overview
A basic moc code block looks like this:
```moc
folder: Diary
element: List
filter: contains("MOC")
recursive: true
```
Configuration Keys
folder (Required)
The folder path relative to the vault root where the plugin will search for markdown notes.
- Examples:
Diary,Projects/Marketing, or""(empty string to search the entire vault). - Supports dynamic parameters:
{{this.filename}},{{this.folder}},{{this.path}}(see Dynamic Parameters).
element (Required)
The specific markdown element to extract from matching notes. Must be one of the following:
List: Bulleted or numbered list items.Task: Checkbox task items.Heading: Note headers (H1 to H6). The entire section (heading + body until the next same-level heading) is extracted.Paragraph: Markdown paragraph blocks.Blockquote: Markdown blockquotes.
filter (Required)
The matching condition applied to each candidate element. Supports both primitive functions and complex logical expressions.
- Supports dynamic parameters:
{{this.filename}},{{this.folder}},{{this.path}}.
Primitive condition functions:
- String & text matches:
-
contains("term"): Evaluates if the element text contains the specified substring (case-sensitive). (has_wordandhas_textare backward-compatible aliases.)
-
- Regular expressions:
matches("regex_pattern"): Evaluates the element using a regular expression match. Supports optional slash-delimited format with flags, e.g.matches("/pattern/i").
- Tags:
has_tag("#tag"): Evaluates if the element contains the specified hashtag (fully tag-aware, case-insensitive, and matches subtags like#tag/subtag).
- Tasks (only when
elementisTaskorList):-
is_completed(): Matches completed tasks. -
is_incomplete(): Matches incomplete tasks.
-
- Frontmatter properties:
-
properties(key == value): Matches files where the frontmatter propertykeyequalsvalue. -
Supported operators:
==,!=,>,<,>=,<=. -
Numeric values are compared numerically; ISO date strings (
YYYY-MM-DD) are compared as dates; all other values are compared as strings. -
Examples:
properties(status == "active")properties(priority <= 2)properties(date >= "2024-01-01")

-
Complex logical expressions:
Combine primitive conditions using AND, OR, and NOT. Use parentheses to enforce precedence.
Example: filter: contains("MOC") AND NOT (is_completed() OR has_tag("#todo"))
recursive (Optional)
A boolean determining whether subfolders of the target folder should also be searched.
- Values:
trueorfalse(defaults tofalse).
groupBy (Optional)
Groups the extracted elements under subheadings.
- Values:
folder: Groups elements by their source note's folder.cday: Groups elements by their source note's creation date (YYYY-MM-DD).mday: Groups elements by their source note's modification date (YYYY-MM-DD).tag: Groups elements by the hashtag(s) found inside the element's text (elements with no tags fall under "Untagged").property(key): Groups elements by the value of the specified frontmatter property key. Elements from notes where the property is missing or empty are grouped under(none).- Example:
groupBy: property(status)
sort (Optional)
Sorts the matching source notes before processing and extracting elements.
- Format:
<field> <direction> - Fields:
name(filename),ctime(creation date),mtime(modification date) - Directions:
asc(ascending),desc(descending) - Example:
sort: mtime desc