468 functions

abs(number: number): number function

Returns the absolute value of the given number.

Example
abs(-10)
Result
10
add(value1: dynamic, value2: dynamic): dynamic function

Adds two values.

Example
add(1, 2)
Result
3
all_symbols(): array function

Returns an array of all interned symbols.

and(value1: bool, value2: bool): bool function

Performs a logical AND operation on two boolean values.

Example
and(true, false)
Result
false
array(values: dynamic): array function

Creates an array from the given values.

Example
array(1, 2, 3)
Result
[1, 2, 3]
ascii_downcase(input: string): string function

Converts ASCII uppercase letters (A-Z) in the given string to lowercase, leaving all other characters unchanged.

Example
ascii_downcase("ABC")
Result
abc
ascii_upcase(input: string): string function

Converts ASCII lowercase letters (a-z) in the given string to uppercase, leaving all other characters unchanged.

Example
ascii_upcase("abc")
Result
ABC
attr(markdown: markdown, attribute: string): dynamic function

Retrieves the value of the specified attribute from a markdown node.

band(bytes1: bytes, bytes2: bytes): bytes function

Computes the bitwise AND of two byte arrays of equal length.

base64(input: string): string function

Encodes the given string to base64.

Example
base64("hi")
Result
aGk=
base64d(input: string): string function

Decodes the given base64 string.

Example
base64d("aGk=")
Result
hi
base64url(input: string): string function

Encodes the given string to URL-safe base64.

Example
base64url("hi")
Result
aGk
base64urld(input: string): string function

Decodes the given URL-safe base64 string.

Example
base64urld(base64url("hi"))
Result
hi
basename(path: string): string function

Returns the final component of a path string (e.g. "file.txt" from "/a/b/file.txt").

Example
basename("/a/b/file.txt")
Result
file.txt
bnot(bytes: bytes): bytes function

Computes the bitwise NOT (complement) of a byte array.

bor(bytes1: bytes, bytes2: bytes): bytes function

Computes the bitwise OR of two byte arrays of equal length.

breakpoint(): dynamic function

Sets a breakpoint for debugging; execution will pause at this point if a debugger is attached.

capture(string: string, pattern: string): dict function

Captures named groups from the given string based on the specified regular expression pattern and returns them as a dictionary keyed by group names.

Example
capture("v1.2.3", "(?P<major>[0-9]+)")
Result
{"major": "1"}
ceil(number: number): number function

Rounds the given number up to the nearest integer.

Example
ceil(3.2)
Result
4
coalesce(value1: dynamic, value2: dynamic): dynamic function

Returns the first non-None value from the two provided arguments.

Example
coalesce(None, 5)
Result
5
collection(dir: string, respect_gitignore?: boolean): array functionrequires file-io

Recursively reads every Markdown file in the given directory (including subdirectories and symlinked files/directories) and returns an array of `{path, title, frontmatter, content}` dicts, sorted by path, so they can be filtered, sorted, or aggregated as a single dataset. `content` holds the file's Markdown nodes with frontmatter stripped. Symlink cycles are detected and only visited once. `respect_gitignore` is optional (default `false`); when `true`, dotfiles/dot-directories and any path matched by a `.gitignore` in `dir` or a subdirectory are skipped, with closer `.gitignore` files taking precedence, same as `git`. Requires the --allow-read CLI flag; otherwise returns a runtime error.

compact(array: array): array function

Removes None values from the given array.

Example
compact([1, None, 2])
Result
[1, 2]
convert(input: dynamic, format: string): dynamic function

Converts the input value to the specified format. Supported formats: base64, html, text, uri, heading (#, ##, etc.), blockquote (>), list item (-), or link (URL).

date_add(array: array, n: number, unit: string): array function

Adds n units to a broken-down time array and returns a new array. Units: "seconds", "minutes", "hours", "days", "weeks", "months", "years". Month/year arithmetic is calendar-aware.

date_diff(array1: array, array2: array, unit: string): number function

Returns the difference (array2 - array1) in the given unit. Units: "seconds", "minutes", "hours", "days", "weeks".

Example
date_diff(gmtime(0), gmtime(86400), "days")
Result
1
date_relative(base_timestamp: number, date_str: string): number function

Parses a natural-language relative date expression (e.g. "3 days ago", "yesterday", "tomorrow", "next monday", "in 2 weeks") relative to a base Unix timestamp and returns the resulting Unix timestamp (seconds, UTC).

del(array_or_string: dynamic, index: number): dynamic function

Deletes the element at the specified index in the array or string.

Example
del([1, 2, 3], 1)
Result
[1, 3]
dict(): dict function

Creates a new, empty dict.

Example
dict()
Result
{}
dirname(path: string): string function

Returns the parent directory of a path string (e.g. "/a/b" from "/a/b/file.txt"). Returns "." if the path has no parent.

Example
dirname("/a/b/file.txt")
Result
/a/b
div(value1: dynamic, value2: dynamic): dynamic function

Divides the first value by the second value.

Example
div(6, 2)
Result
3
downcase(input: string): string function

Converts the given string to lowercase.

Example
downcase("ABC")
Result
abc
embed_images(base_dir: string): markdown functionrequires file-io

Inlines an `.image` node's local file into its `url` as a base64 `data:` URI, resolving the path relative to the given base directory (default ".") and inferring the MIME type from the file extension. URLs that are already `data:` URIs or contain a `://` scheme (e.g. `https://`), and non-image nodes, are left unchanged. Requires the --allow-read CLI flag; otherwise returns a runtime error.

ends_with(value: dynamic, suffix: dynamic): bool function

Checks if the given string or byte array ends with the specified suffix.

Example
ends_with("hello", "lo")
Result
true
entries(dict: dict): array function

Returns an array of key-value pairs from the dict as arrays.

eq(value1: dynamic, value2: dynamic): bool function

Checks if two values are equal.

Example
eq(1, 1)
Result
true
error(message: string): dynamic function

Raises a user-defined error with the specified message.

exp(number: number): number function

Returns the exponential (e^x) of the given number.

Example
exp(0)
Result
1
explode(string: string): array function

Splits the given string into an array of characters.

Example
explode("ab")
Result
[97, 98]
extname(path: string): string function

Returns the extension of a file path including the leading dot (e.g. ".txt" from "file.txt"). Returns an empty string if there is no extension.

Example
extname("file.txt")
Result
.txt
extract_images(dir: string): markdown functionrequires file-io

Decodes an `.image` node's base64 `data:` URI and writes the bytes to a file under the given directory, named by the content's MD5 hash with an extension inferred from the MIME type, then replaces `url` with that file's path. Nodes whose `url` is not a base64 `data:` URI, including non-image nodes, are left unchanged. Requires the --allow-write CLI flag; otherwise returns a runtime error.

file_exists(path: string): bool functionrequires file-io

Checks if a file exists at the given path. Requires the --allow-read CLI flag; otherwise returns a runtime error.

file_size(path: string): number functionrequires file-io

Returns the size, in bytes, of the file at the given path. Requires the --allow-read CLI flag; otherwise returns a runtime error.

flatten(array: array): array function

Flattens a nested array into a single level array.

Example
flatten([[1, 2], [3]])
Result
[1, 2, 3]
floor(number: number): number function

Rounds the given number down to the nearest integer.

Example
floor(3.8)
Result
3
from_date(date_str: string): number function

Converts a date string to a timestamp.

Example
from_date("1970-01-01T00:00:00Z")
Result
0
from_hex(hex_string: string): bytes function

Parses a hex string into raw bytes.

from_html(html: string): array function

Converts the given HTML string to Markdown.

get(obj: dict, key: dynamic): dynamic function

Retrieves a value from a dict by its key. Returns None if the key is not found.

get_location(node: markdown): dict function

Returns the source position of a markdown node as a dict with start_line, start_column, end_line, and end_column, or None if the node has no position info.

get_title(node: markdown): string function

Returns the title of a markdown node.

get_url(node: markdown): string function

Returns the url of a markdown node.

Example
get_url(to_link("https://example.com", "Example", ""))
Result
https://example.com
get_variable(symbol_or_string: dynamic): dynamic function

Retrieves the value of a symbol or variable from the current environment.

glob_match(pattern: string, path: string): bool function

Checks whether the given path matches the glob pattern (e.g. "*.md", "docs/**/*.rs"), commonly used to filter file lists.

Example
glob_match("*.md", "readme.md")
Result
true
gmtime(timestamp: number): array function

Converts Unix timestamp (seconds since epoch) to broken-down UTC time array [year, mon (0-11), mday, hour, min, sec, wday (0=Sun), yday (0-365)].

Example
gmtime(0)
Result
[1970, 0, 1, 0, 0, 0, 4, 0]
gsub(from: string, pattern: string, to: string): string function

Replaces all occurrences matching a regular expression pattern with the replacement string.

Example
gsub("a1b2", "[0-9]", "#")
Result
a#b#
gt(value1: dynamic, value2: dynamic): bool function

Checks if the first value is greater than the second value.

Example
gt(2, 1)
Result
true
gte(value1: dynamic, value2: dynamic): bool function

Checks if the first value is greater than or equal to the second value.

Example
gte(1, 1)
Result
true
halt(exit_code: number): dynamic function

Terminates the program with the given exit code.

html_escape(string: string): string function

Escapes `&`, `<`, `>`, `"`, and `'` in the given string as HTML entities.

Example
html_escape("<a>")
Result
&lt;a&gt;
html_unescape(string: string): string function

Decodes named and numeric HTML entities in the given string into their corresponding characters.

Example
html_unescape("&lt;a&gt;")
Result
<a>
http(method: string, url: string, body: string, headers: dict): string functionrequires http

Performs an HTTPS request with the given method (a string or symbol, e.g. "post" or :post — get, post, put, delete, patch, head, ... are all supported) and returns the response body as a string. An optional body argument (string) sends a request body regardless of method, and an optional headers argument (a dict of string to string, e.g. {"Content-Type": "application/json"}) is applied to the request. Requires the --allow-net CLI flag; otherwise returns a runtime error. Only https:// URLs are allowed.

implode(array: array): string function

Joins an array of characters into a string.

Example
implode(explode("ab"))
Result
ab
index(value: dynamic, needle: dynamic): number function

Finds the first occurrence of a substring or byte subsequence. Returns -1 if not found.

Example
index("hello", "ll")
Result
2
infinite(): number function

Returns an infinite number value.

input(): string function

Reads a line from standard input and returns it as a string.

insert(target: dynamic, index_or_key: dynamic, value: dynamic): dynamic function

Inserts a value into an array or string at the specified index, or into a dict with the specified key.

Example
insert([1, 2, 3], 1, "x")
Result
[1, "x", 2, 3]
intern(string: string): string function

Interns the given string, returning a canonical reference for efficient comparison.

Example
intern("hi")
Result
hi
is_not_regex_match(string: string, pattern: string): bool function

Checks if the given pattern does not match the string.

Example
is_not_regex_match("abc", "x")
Result
true
is_regex_match(string: string, pattern: string): bool function

Checks if the given pattern matches the string.

Example
is_regex_match("abc", "a.c")
Result
true
join(array: array, separator: string): string function

Joins the elements of an array into a string with the given separator.

Example
join([1, 2, 3], ",")
Result
1,2,3
keys(dict: dict): array function

Returns an array of keys from the dict.

len(value: dynamic): number function

Returns the length of the given string or array.

Example
len("hello")
Result
5
ln(number: number): number function

Returns the natural logarithm (base e) of the given number.

Example
ln(1)
Result
0
localtime(timestamp: number): array function

Converts Unix timestamp (seconds since epoch) to broken-down local time array [year, mon (0-11), mday, hour, min, sec, wday (0=Sun), yday (0-365)].

log10(number: number): number function

Returns the base-10 logarithm of the given number.

Example
log10(100)
Result
2
lt(value1: dynamic, value2: dynamic): bool function

Checks if the first value is less than the second value.

Example
lt(1, 2)
Result
true
lte(value1: dynamic, value2: dynamic): bool function

Checks if the first value is less than or equal to the second value.

Example
lte(1, 1)
Result
true
ltrim(input: string): string function

Trims whitespace from the left end of the given string.

Example
ltrim("  hi  ")
Result
hi  
max(value1: dynamic, value2: dynamic): dynamic function

Returns the maximum of two values.

Example
max(1, 2)
Result
2
md5(input: dynamic): string function

Computes the MD5 hash of a string or bytes and returns a lowercase hex string.

min(value1: dynamic, value2: dynamic): dynamic function

Returns the minimum of two values.

Example
min(1, 2)
Result
1
mktime(time_array: array): number function

Converts broken-down UTC time array [year, mon (0-11), mday, hour, min, sec, wday, yday] to Unix timestamp (seconds since epoch).

Example
mktime(gmtime(0))
Result
0
mod(value1: dynamic, value2: dynamic): dynamic function

Calculates the remainder of the division of the first value by the second value.

Example
mod(7, 3)
Result
1
mul(value1: dynamic, value2: dynamic): dynamic function

Multiplies two values.

Example
mul(2, 3)
Result
6
nan(): number function

Returns a Not-a-Number (NaN) value.

ne(value1: dynamic, value2: dynamic): bool function

Checks if two values are not equal.

Example
ne(1, 2)
Result
true
negate(number: number): number function

Returns the negation of the given number.

Example
negate(5)
Result
-5
not(value: bool): bool function

Performs a logical NOT operation on a boolean value.

Example
not(true)
Result
false
now(): number function

Returns the current timestamp.

or(value1: bool, value2: bool): bool function

Performs a logical OR operation on two boolean values.

Example
or(true, false)
Result
true
pack(format: string, value: number): bytes function

Packs a number into bytes using the given format. Supported formats: u8, i8, u16be/le, i16be/le, u32be/le, i32be/le, u64be/le, i64be/le, f32be/le, f64be/le.

partial(function: function, arg1: dynamic, arg2: dynamic, ...: dynamic): function function

Creates a new function by partially applying the given arguments to the specified function.

path_join(base: string, component: string): string function

Joins a base path with a component path and returns the resulting path string (e.g. path_join("/a/b", "c.txt") → "/a/b/c.txt").

Example
path_join("/a/b", "c.txt")
Result
/a/b/c.txt
pow(base: number, exponent: number): number function

Raises the base to the power of the exponent.

Example
pow(2, 10)
Result
1024
print(message: string): dynamic function

Prints a message to standard output and returns the current value.

rand(): number function

Generates a pseudo-random number in the range [0, 1). Not cryptographically secure.

rand_int(min: number, max: number): number function

Generates a pseudo-random integer uniformly distributed in [min, max] (inclusive). Not cryptographically secure.

random_string(len: number, charset: string): string function

Generates a random string of `len` characters, each independently chosen (with replacement) from `charset`. Not cryptographically secure.

range(start: number, end: number, step: number): array function

Creates an array from start to end with an optional step.

Example
range(0, 5, 1)
Result
[0, 1, 2, 3, 4, 5]
read_file(path: string): string functionrequires file-io

Reads the contents of a file at the given path and returns it as a string. Requires the --allow-read CLI flag; otherwise returns a runtime error.

read_file_bytes(path: string): bytes functionrequires file-io

Reads the contents of a file at the given path and returns it as raw bytes. Requires the --allow-read CLI flag; otherwise returns a runtime error.

regex_match(string: string, pattern: string): array function

Finds all matches of the given pattern in the string.

Example
regex_match("abc123", "[0-9]+")
Result
["123"]
repeat(string: string, count: number): string function

Repeats the given string a specified number of times.

Example
repeat("ab", 3)
Result
ababab
replace(from: string, pattern: string, to: string): string function

Replaces all occurrences of a substring with another substring.

Example
replace("aXbXc", "X", "-")
Result
a-b-c
reverse(value: dynamic): dynamic function

Reverses the given string or array.

Example
reverse("abc")
Result
cba
rindex(value: dynamic, needle: dynamic): number function

Finds the last occurrence of a substring or byte subsequence. Returns -1 if not found.

Example
rindex("hello", "l")
Result
3
round(number: number): number function

Rounds the given number to the nearest integer.

Example
round(3.5)
Result
4
rtrim(input: string): string function

Trims whitespace from the right end of the given string.

Example
rtrim("  hi  ")
Result
  hi
sample(array: array, n: number): array function

Returns n elements sampled from the array without replacement, in random order. Errors if n exceeds the array length.

sanitize_html(html: string): string function

Sanitizes the given HTML string using an allowlist of safe tags and attributes, removing scripts and other XSS vectors.

scan(string: string, pattern: string): array function

Finds all matches of a regular expression pattern in the string. For each match, returns the captured groups as an array if the pattern has capture groups, otherwise returns the whole match as a string.

Example
scan("a1b2", "[0-9]")
Result
["1", "2"]
set(obj: dict, key: dynamic, value: dynamic): dict function

Sets a key-value pair in a dict. If the key exists, its value is updated. Returns the modified map.

set_attr(markdown: markdown, attribute: string, value: dynamic): markdown function

Sets the value of the specified attribute on a markdown node.

set_check(list: markdown, checked: bool): markdown function

Creates a markdown list node with the given checked state.

Example
set_check(to_md_list("Item", 0), true)
Result
- [x] Item
set_children(markdown: markdown, children: array): markdown function

Sets the children nodes of a markdown node. Nodes without children (e.g. text, code) are left unchanged.

set_code_block_lang(code_block: markdown, language: string): markdown function

Sets the language of a markdown code block node.

Example
set_code_block_lang(to_code("x", "python"), "rust")
Result
```rust
x
```
set_list_ordered(list: markdown, ordered: bool): markdown function

Sets the ordered property of a markdown list node.

Example
set_list_ordered(to_md_list("Item", 0), true)
Result
1. Item
set_ref(node: markdown, reference_id: string): markdown function

Sets the reference identifier for markdown nodes that support references (e.g., Definition, LinkRef, ImageRef, Footnote, FootnoteRef).

set_variable(symbol_or_string: dynamic, value: dynamic): dynamic function

Sets a symbol or variable in the current environment with the given value.

sha256(input: dynamic): string function

Computes the SHA-256 hash of a string or bytes and returns a lowercase hex string.

sha512(input: dynamic): string function

Computes the SHA-512 hash of a string or bytes and returns a lowercase hex string.

shift_left(value: dynamic, shift_amount: number): dynamic function

Performs a left shift operation on the given value: for numbers, this is a bitwise left shift by the specified number of positions; for strings, this removes characters from the start; for Markdown headings, this increases the heading level accordingly.

Example
shift_left(1, 2)
Result
4
shift_right(value: dynamic, shift_amount: number): dynamic function

Performs a bitwise right shift on numbers, slices characters from the end of strings, and adjusts Markdown heading levels when applied to headings, using the given shift amount.

Example
shift_right(8, 2)
Result
2
shuffle(array: array): array function

Returns a new array containing the same elements as the input, in a uniformly random order.

slice(string: string, start: number, end: number): string function

Extracts a substring from the given string.

Example
slice("hello", 1, 3)
Result
el
sort(array: array): array function

Sorts the elements of the given array.

Example
sort([3, 1, 2])
Result
[1, 2, 3]
split(string: string, separator: string): array function

Splits the given string by the specified separator.

Example
split("a,b,c", ",")
Result
["a", "b", "c"]
sqrt(number: number): number function

Returns the square root of the given number.

Example
sqrt(9)
Result
3
starts_with(value: dynamic, prefix: dynamic): bool function

Checks if the given string or byte array starts with the specified prefix.

Example
starts_with("hello", "he")
Result
true
stderr(message: string): dynamic function

Prints a message to standard error and returns the current value.

stem(path: string): string function

Returns the file name without the extension (e.g. "file" from "/a/b/file.txt").

Example
stem("/a/b/file.txt")
Result
file
strftime(timestamp: number, format: string): string function

Formats a Unix timestamp (seconds) as a date string using the given strftime format (e.g. "%Y-%m-%d").

Example
strftime(0, "%Y-%m-%d")
Result
1970-01-01
strip_tags(string: string): string function

Removes HTML tags from the given string, keeping the surrounding text content.

Example
strip_tags("<b>hi</b>")
Result
hi
strptime(date_str: string, format: string): number function

Parses a date string using the given strptime format (e.g. "%Y-%m-%d") and returns a Unix timestamp (seconds, UTC).

Example
strptime("1970-01-01", "%Y-%m-%d")
Result
0
sub(value1: dynamic, value2: dynamic): dynamic function

Subtracts the second value from the first value.

Example
sub(5, 2)
Result
3
to_array(value: dynamic): array function

Converts the given value to an array.

Example
to_array(1)
Result
[1]
to_blockquote(value: dynamic): markdown function

Creates a markdown blockquote node with the given value.

Example
to_blockquote("Quote")
Result
> Quote
to_boolean(value: dynamic): bool function

Converts the given value to a boolean. Booleans are returned unchanged, the strings "true" and "false" are converted to their boolean equivalent, and all other input results in an error.

Example
to_boolean("true")
Result
true
to_break(): markdown function

Creates a markdown hard line break node.

Example
to_break()
Result
\
to_bytes(value: dynamic): bytes function

Converts a string (UTF-8), array of numbers, or bytes to raw bytes.

to_callout(value: dynamic, kind: string, title: string): markdown function

Creates a markdown callout node with the given value, kind, and title.

Example
to_callout("Note text", "note", "")
Result
> [!NOTE]
> Note text
to_code(value: dynamic, language: string): markdown function

Creates a markdown code block with the given value and language.

Example
to_code("x = 1", "python")
Result
```python
x = 1
```
to_code_inline(value: dynamic): markdown function

Creates an inline markdown code node with the given value.

Example
to_code_inline("x")
Result
`x`
to_date(timestamp: number, format: string): string function

Converts a timestamp to a date string with the given format.

Example
to_date(0, "%Y-%m-%d")
Result
1970-01-01
to_definition(url: string, ident: string, title: string): markdown function

Creates a markdown link reference definition node with the given url, identifier, and title.

Example
to_definition("https://example.com", "ex", "")
Result
[ex]: https://example.com
to_delete(value: dynamic): markdown function

Creates a markdown delete (strikethrough) node with the given value.

Example
to_delete("Old")
Result
~~Old~~
to_em(value: dynamic): markdown function

Creates a markdown emphasis (italic) node with the given value.

Example
to_em("Italic")
Result
*Italic*
to_footnote(value: dynamic, ident: string): markdown function

Creates a markdown footnote definition node with the given value and identifier.

Example
to_footnote("Footnote text", "1")
Result
[^1]: Footnote text
to_footnote_ref(ident: string): markdown function

Creates a markdown footnote reference node with the given identifier.

Example
to_footnote_ref("1")
Result
[^1]
to_h(value: dynamic, depth: number): markdown function

Creates a markdown heading node with the given value and depth.

Example
to_h("Title", 1)
Result
# Title
to_hex(bytes: bytes): string function

Encodes raw bytes as a lowercase hex string.

Example
to_hex(from_hex("6869"))
Result
6869
to_hr(): markdown function

Creates a markdown horizontal rule node.

Example
to_hr()
Result
***
to_html(markdown: string): string function

Converts the given markdown string to HTML.

to_image(url: string, alt: string, title: string): markdown function

Creates a markdown image node with the given URL, alt text, and title.

Example
to_image("https://example.com/a.png", "Alt", "")
Result
![Alt](https://example.com/a.png "")
to_link(url: string, value: dynamic, title: string): markdown function

Creates a markdown link node with the given url and title.

Example
to_link("https://example.com", "Example", "")
Result
[Example](https://example.com)
to_markdown(markdown_string: string): array function

Parses a markdown string and returns an array of markdown nodes.

Example
to_markdown("# Hi")
Result
[# Hi]
to_markdown_string(value: dynamic): string function

Converts the given value(s) to a markdown string representation.

to_math(value: dynamic): markdown function

Creates a markdown math block with the given value.

Example
to_math("x^2")
Result
$$
x^2
$$
to_math_inline(value: dynamic): markdown function

Creates an inline markdown math node with the given value.

Example
to_math_inline("x^2")
Result
$x^2$
to_md_fragment(values: array): markdown function

Creates a markdown fragment node that groups an array of markdown nodes into a single value.

to_md_html(value: dynamic): markdown function

Creates a raw markdown HTML node with the given value.

Example
to_md_html("<br>")
Result
<br>
to_md_list(value: dynamic, indent: number): markdown function

Creates a markdown list node with the given value and indent level.

Example
to_md_list("Item", 0)
Result
- Item
to_md_name(markdown: markdown): string function

Returns the name of the given markdown node.

Example
to_md_name(to_h("t", 1))
Result
h1
to_md_table_align(aligns: array): markdown function

Creates a markdown table alignment row node from an array of alignments ("left", "right", "center", "none").

Example
to_md_table_align(["left", "right"])
Result
|:---|---:|
to_md_table_cell(value: dynamic, row: number, column: number): markdown function

Creates a markdown table cell node with the given value at the specified row and column.

Example
to_md_table_cell("A1", 0, 0)
Result
A1
to_md_table_row(cells: array): markdown function

Creates a markdown table row node with the given values.

to_md_text(value: dynamic): markdown function

Creates a markdown text node with the given value.

Example
to_md_text("hi")
Result
hi
to_mdx(mdx_string: string): array function

Parses an MDX string and returns an array of MDX nodes.

to_number(value: dynamic): number function

Converts the given value to a number.

Example
to_number("42")
Result
42
to_string(value: dynamic): string function

Converts the given value to a string.

Example
to_string(1)
Result
1
to_strong(value: dynamic): markdown function

Creates a markdown strong (bold) node with the given value.

Example
to_strong("Bold")
Result
**Bold**
to_text(markdown: markdown): string function

Converts the given markdown node to plain text.

Example
to_text(to_strong("hi"))
Result
hi
token_compress(nodes: array, budget: number, model?: string): array function

Reduces an array of Markdown nodes to fit within `budget` LLM tokens, preserving structure as much as possible: paragraphs are cut to their first sentence, then lists/tables/code blocks are collapsed to a summary, and only as a last resort is the remaining text hard-truncated. Uses a lightweight chars-per-token heuristic by default; built with the `tiktoken` Cargo feature, counts exactly via tiktoken-rs instead when `model` (e.g. "gpt-5") is given. `model` is optional; without it, the heuristic estimate is always used.

token_count(text: string, model?: string): number function

Estimates how many LLM tokens the given text would consume, for context-window budgeting. Uses a lightweight chars-per-token heuristic by default; built with the `tiktoken` Cargo feature, counts exactly via tiktoken-rs instead when `model` (e.g. "gpt-5") is given. `model` is optional; without it, the heuristic estimate is always used.

Example
token_count("Hello, world!")
Result
4
trim(input: string): string function

Trims whitespace from both ends of the given string.

Example
trim("  hi  ")
Result
hi
trunc(number: number): number function

Truncates the given number to an integer by removing the fractional part.

Example
trunc(3.9)
Result
3
truncate(string: string, width: number, ellipsis: string): string function

Truncates the given string to the specified display width, appending the ellipsis string when truncated (CJK and other wide characters count as two columns).

Example
truncate("hello world", 5, "...")
Result
he...
type(value: dynamic): string function

Returns the type of the given value.

Example
type(1)
Result
number
uniq(array: array): array function

Removes duplicate elements from the given array.

Example
uniq([1, 1, 2])
Result
[1, 2]
unpack(format: string, bytes: bytes): number function

Unpacks a number from bytes using the given format. Supported formats: u8, i8, u16be/le, i16be/le, u32be/le, i32be/le, u64be/le, i64be/le, f32be/le, f64be/le.

upcase(input: string): string function

Converts the given string to uppercase.

Example
upcase("abc")
Result
ABC
update(target_value: dynamic, source_value: dynamic): dynamic function

Update the value with specified value.

url_decode(input: string): string function

URL-decodes the given string.

Example
url_decode("a%20b")
Result
a b
url_encode(input: string): string function

URL-encodes the given string.

Example
url_encode("a b")
Result
a%20b
utf8(bytes: bytes): string function

Decodes bytes as a UTF-8 string, returning an error if the bytes are not valid UTF-8.

Example
utf8(to_bytes("hi"))
Result
hi
uuid(): string function

Generates a random (version 4, RFC 4122) UUID string.

uuid_v4(): string function

Generates a random (version 4, RFC 4122) UUID string. Alias of `uuid`.

uuid_v7(): string function

Generates a time-ordered (version 7, RFC 9562) UUID string: a millisecond Unix timestamp followed by random bits, so values sort by creation time. The timestamp is plaintext, so prefer uuid/uuid_v4 for unguessable IDs.

values(dict: dict): array function

Returns an array of values from the dict.

word_wrap(string: string, width: number): string function

Wraps the given string into lines no wider than the specified display width, breaking on word boundaries (CJK and other wide characters count as two columns).

Example
word_wrap("hello world", 5)
Result
hello
world
write_file(path: string, content: dynamic): dynamic functionrequires file-io

Writes content (string or bytes) to the file at the given path, creating or truncating it. Requires the --allow-write CLI flag; otherwise returns a runtime error.

xor(bytes1: bytes, bytes2: bytes): bytes function

Computes the bitwise XOR of two byte arrays of equal length.

halt_error(): dynamic function

Halts execution with error code 5

is_array(a: dynamic): bool function

Checks if input is an array

Example
is_array([1, 2])
Result
true
is_markdown(m: dynamic): bool function

Checks if input is markdown

Example
is_markdown(to_h("t", 1))
Result
true
is_bool(b: dynamic): bool function

Checks if input is a boolean

Example
is_bool(true)
Result
true
is_number(n: dynamic): bool function

Checks if input is a number

Example
is_number(1)
Result
true
is_string(s: dynamic): bool function

Checks if input is a string

Example
is_string("hi")
Result
true
is_none(n: dynamic): bool function

Checks if input is None

Example
is_none(None)
Result
true
is_dict(d: dynamic): bool function

Checks if input is a dictionary

Example
is_dict({"a": 1})
Result
true
is_bytes(b: dynamic): bool function

Checks if input is bytes

Example
is_bytes(to_bytes("hi"))
Result
true
contains(haystack: dynamic, needle: dynamic): bool function

Checks if string contains a substring

Example
contains("hello world", "world")
Result
true
ltrimstr(s: dynamic, left: dynamic): string function

Removes prefix string from input if it exists

Example
ltrimstr("prefix_value", "prefix_")
Result
value
rtrimstr(s: dynamic, right: dynamic): string function

Removes suffix string from input if it exists

Example
rtrimstr("value_suffix", "_suffix")
Result
value
is_empty(s: dynamic): bool function

Checks if string, array or dict is empty

Example
is_empty([])
Result
true
test(s: dynamic, pattern: dynamic): bool function

Tests if string matches a pattern

Example
test("abc", "a.c")
Result
true
select(v: dynamic, f: dynamic): dynamic function

Returns value if condition is true, None otherwise

Example
select(5, true)
Result
5
arrays(a: dynamic): dynamic function

Returns array if input is array, None otherwise

Example
arrays([1, 2])
Result
[1, 2]
markdowns(m: dynamic): dynamic function

Returns markdown if input is markdown, None otherwise

Example
markdowns(to_h("t", 1))
Result
# t
booleans(b: dynamic): dynamic function

Returns boolean if input is boolean, None otherwise

Example
booleans(true)
Result
true
numbers(n: dynamic): dynamic function

Returns number if input is number, None otherwise

Example
numbers(1)
Result
1
strings(s: dynamic): dynamic function

Returns string if input is string, None otherwise

Example
strings("hi")
Result
hi
dicts(d: dynamic): dynamic function

Returns dict if input is dict, None otherwise

Example
dicts({"a": 1})
Result
{"a": 1}
nones(n: dynamic): dynamic function

Returns the value if it is None, None otherwise

Example
nones(None)
Result
bytes(b: dynamic): dynamic function

Returns bytes if input is bytes, None otherwise

Example
bytes(to_bytes("hi"))
Result
6869
iterables(v: dynamic): dynamic function

Returns the value if it is an array or dict (i.e. a container that can be iterated over), None otherwise

Example
iterables([1, 2])
Result
[1, 2]
scalars(v: dynamic): dynamic function

Returns the value if it is not an array or dict (i.e. a leaf/scalar value), None otherwise

Example
scalars(1)
Result
1
to_date_iso8601(d: dynamic): string function

Formats a date to ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)

Example
to_date_iso8601(0)
Result
1970-01-01T00:00:00Z
map(v: dynamic, f: dynamic): array function

Applies a given function to each element of the provided array and returns a new array with the results.

Example
map([1, 2, 3], fn(x): mul(x, 2);)
Result
[2, 4, 6]
flat_map(v: dynamic, f: dynamic): array function

Applies a function to each element and flattens the result into a single array

Example
flat_map([1, 2], fn(x): [x, x];)
Result
[1, 1, 2, 2]
filter(v: dynamic, f: dynamic): array function

Filters the elements of an array based on a provided callback function.

Example
filter([1, 2, 3, 4], fn(x): x > 2;)
Result
[3, 4]
each(v: dynamic, f: dynamic): dynamic function

Executes a provided function once for each element in an array or each key-value pair in a dictionary.

first(arr: dynamic): dynamic function

Returns the first element of an array

Example
first([1, 2, 3])
Result
1
last(arr: dynamic): dynamic function

Returns the last element of an array

Example
last([1, 2, 3])
Result
3
second(arr: dynamic): dynamic function

Returns the second element of an array

Example
second([1, 2, 3])
Result
2
is_h1(md: dynamic): bool function

Checks if markdown is h1 heading

Example
is_h1(to_h("t", 1))
Result
true
is_h2(md: dynamic): bool function

Checks if markdown is h2 heading

Example
is_h2(to_h("t", 2))
Result
true
is_h3(md: dynamic): bool function

Checks if markdown is h3 heading

Example
is_h3(to_h("t", 3))
Result
true
is_h4(md: dynamic): bool function

Checks if markdown is h4 heading

Example
is_h4(to_h("t", 4))
Result
true
is_h5(md: dynamic): bool function

Checks if markdown is h5 heading

Example
is_h5(to_h("t", 5))
Result
true
is_h6(md: dynamic): bool function

Checks if markdown is h6 heading

Example
is_h6(to_h("t", 6))
Result
true
is_h(md: dynamic): bool function

Checks if markdown is heading

Example
is_h(to_h("t", 2))
Result
true
is_h_level(md: dynamic, level: dynamic): bool function

Checks if markdown is a heading of the specified level (1-6)

Example
is_h_level(to_h("t", 2), 2)
Result
true
is_table_align(md: dynamic): bool function

Checks if markdown is table align

Example
is_table_align(to_md_table_align(["left"]))
Result
true
is_table_cell(md: dynamic): bool function

Checks if markdown is table cell

Example
is_table_cell(to_md_table_cell("A1", 0, 0))
Result
true
is_em(md: dynamic): bool function

Checks if markdown is emphasis

Example
is_em(to_em("hi"))
Result
true
is_html(md: dynamic): bool function

Checks if markdown is html

is_yaml(md: dynamic): bool function

Checks if markdown is yaml

is_toml(md: dynamic): bool function

Checks if markdown is toml

is_code(md: dynamic): bool function

Checks if markdown is code block

Example
is_code(to_code("x", "python"))
Result
true
is_text(text: dynamic): bool function

Checks if markdown is text

Example
is_text(to_md_text("hi"))
Result
true
is_list(list: dynamic): bool function

Checks if markdown is list

Example
is_list(to_md_list("Item", 0))
Result
true
matches_url(node: dynamic, url: dynamic): bool functionDeprecated

Checks if markdown node's URL matches a specified URL deprecated: use select(.link.url == url) instead

Example
matches_url(to_link("https://example.com", "x", ""), "https://example.com")
Result
true
is_mdx_flow_expression(mdx: dynamic): bool function

Checks if markdown is MDX Flow Expression

is_mdx_jsx_flow_element(mdx: dynamic): bool function

Checks if markdown is MDX Jsx Flow Element

is_mdx_jsx_text_element(mdx: dynamic): bool function

Checks if markdown is MDX Jsx Text Element

is_mdx_text_expression(mdx: dynamic): bool function

Checks if markdown is MDX Text Expression

is_mdx_js_esm(mdx: dynamic): bool function

Checks if markdown is MDX Js Esm

is_mdx(mdx: dynamic): bool function

Checks if markdown is MDX

is_callout(md: dynamic): bool function

Checks if markdown is a callout block

Example
is_callout(to_callout("Note", "note", ""))
Result
true
fill(value: dynamic, n: dynamic): array function

Returns an array of length n filled with the given value.

Example
fill("x", 3)
Result
["x", "x", "x"]
sort_by(arr: dynamic, f: dynamic): array function

Sorts an array using a key function that extracts a comparable value for each element.

Example
sort_by([3, 1, 2], identity)
Result
[1, 2, 3]
sort_natural(arr: dynamic): array function

Sorts an array in natural order (numeric-aware), so runs of digits embedded in a string are compared as numbers rather than character-by-character, e.g. "file2" sorts before "file10" (unlike a plain lexicographic `sort`).

Example
sort_natural(["file10", "file2"])
Result
["file2", "file10"]
count_by(arr: dynamic, f: dynamic): number function

Returns the count of elements in the array that satisfy the provided function.

Example
count_by([1, 2, 3, 4], fn(x): x > 2;)
Result
2
skip(arr: dynamic, n: dynamic): array function

Skips the first n elements of an array and returns the rest

Example
skip([1, 2, 3, 4], 2)
Result
[3, 4]
take(arr: dynamic, n: dynamic): array function

Takes the first n elements of an array

Example
take([1, 2, 3, 4], 2)
Result
[1, 2]
find_index(arr: dynamic, f: dynamic): number function

Returns the index of the first element in an array that satisfies the provided function.

Example
find_index([1, 2, 3], fn(x): x == 2;)
Result
1
skip_while(arr: dynamic, f: dynamic): array function

Skips elements from the beginning of an array while the provided function returns true

Example
skip_while([1, 2, 3, 4], fn(x): x < 3;)
Result
[3, 4]
take_while(arr: dynamic, f: dynamic): array function

Takes elements from the beginning of an array while the provided function returns true

Example
take_while([1, 2, 3, 4], fn(x): x < 3;)
Result
[1, 2]
group_by(arr: dynamic, f: dynamic): dict function

Groups elements of an array by the result of applying a function to each element

Example
group_by([1, 2, 3, 4], fn(x): mod(x, 2);)
Result
{"1": [1, 3], "0": [2, 4]}
frequencies_by(arr: dynamic, f: dynamic): dict function

Counts occurrences of each key extracted from the elements of an array, returning a dict of `{key: count}`.

Example
frequencies_by(["a", "b", "a"], identity)
Result
{"a": 2, "b": 1}
tally(arr: dynamic): dict function

Counts occurrences of each element in an array, returning a dict of `{value: count}`.

Example
tally(["a", "b", "a"])
Result
{"a": 2, "b": 1}
any(v: dynamic, f: dynamic): bool function

Returns true if any element in the array satisfies the provided function.

Example
any([1, 2, 3], fn(x): x > 2;)
Result
true
all(v: dynamic, f: dynamic): bool function

Returns true if all element in the array satisfies the provided function.

Example
all([1, 2, 3], fn(x): x > 0;)
Result
true
in(v: dynamic, elem: dynamic): bool function

Returns true if the element is in the array.

Example
in([1, 2, 3], 2)
Result
true
fold(arr: dynamic, init: dynamic, f: dynamic): dynamic function

Reduces an array to a single value by applying a function, starting from an initial value.

Example
fold([1, 2, 3], 0, fn(acc, x): acc + x;)
Result
6
unique_by(arr: dynamic, f: dynamic): array function

Returns a new array with duplicate elements removed, comparing by the result of the provided function.

Example
unique_by([1, 2, 1, 3], identity)
Result
[1, 2, 3]
identity(x: dynamic): dynamic function

Returns the input value unchanged.

Example
identity(1)
Result
1
transpose(matrix: dynamic): array function

Transposes a 2D array (matrix), swapping rows and columns.

Example
transpose([[1, 2], [3, 4]])
Result
[[1, 3], [2, 4]]
tap(value: dynamic, expr: dynamic): dynamic function

Applies a function to a value and returns the value (useful for debugging or side effects).

Example
tap(1, 2)
Result
1
pluck(pluck_obj: dynamic, selector: dynamic): dynamic function

Extracts values from an array of objects based on a specified selector.

compact_map(arr: dynamic, f: dynamic): array function

Maps over an array and removes None values from the result.

Example
compact_map([1, 2, 3], fn(x): if (x > 1): x;)
Result
[2, 3]
reject(arr: dynamic, f: dynamic): array function

Filters out elements that match the condition (opposite of filter).

Example
reject([1, 2, 3, 4], fn(x): x > 2;)
Result
[1, 2]
partition(arr: dynamic, f: dynamic): array function

Splits an array into two arrays: [matching, not_matching] based on a condition.

Example
partition([1, 2, 3, 4], fn(x): x > 2;)
Result
[[3, 4], [1, 2]]
get_or(dict: dynamic, key: dynamic, default: dynamic): dynamic function

Safely gets a value from a dict with a default if the key doesn't exist.

Example
get_or({"a": 1}, "b", 0)
Result
0
times(n: dynamic, value: dynamic): array functionDeprecated

Executes an expression n times and returns an array of results. Note: `value` is evaluated once (eagerly) and repeated, not re-evaluated per iteration. Deprecated: use `repeat` instead

Example
times(3, 1)
Result
[1, 1, 1]
between(value: dynamic, min: dynamic, max: dynamic): bool function

Checks if a value is between min and max (inclusive).

Example
between(5, 1, 10)
Result
true
sum_by(arr: dynamic, f: dynamic): number function

Sums elements of an array after applying a transformation function.

Example
sum_by([1, 2, 3], fn(x): mul(x, 2);)
Result
12
index_by(arr: dynamic, f: dynamic): dict function

Creates a dictionary indexed by a key extracted from each element.

Example
index_by([1, 2, 3], to_string)
Result
{"1": 1, "2": 2, "3": 3}
join_by(left: dynamic, right: dynamic, left_key: dynamic, right_key: dynamic, kind: dynamic): array function

Joins two arrays of dict records on `left_key`/`right_key`, similar to a SQL join. Matching records are merged with `+` (right's fields win on collision). `kind` is one of "inner" (default), "left", "right", or "full"; unmatched records in outer joins are filled with `None` for the other side's fields (inferred from that side's full key set). Records with a missing or `None` join key never match, and duplicate keys on either side expand as a cross product.

Example
join_by([{"id": 2, "name": "bob"}], [{"uid": 2, "age": 30}], "id", "uid")
Result
[{"id": 2, "name": "bob", "uid": 2, "age": 30}]
inspect(value: dynamic): dynamic function

Inspects a value by printing its string representation and returning the value.

lpad(s: dynamic, length: dynamic, pad_str: dynamic): string function

Left-pads a string to a specified length using a given padding string.

Example
lpad("7", 3, "0")
Result
007
rpad(s: dynamic, length: dynamic, pad_str: dynamic): string function

Right-pads a string to a specified length using a given padding string.

Example
rpad("7", 3, "0")
Result
700
load_markdown(path: dynamic): array function

Loads a markdown file from the specified path

http_get(url: dynamic, headers: dynamic): string function

Performs an HTTPS GET request, optionally with the given headers (a dict of string to string), and returns the response body as a string

http_post(url: dynamic, body: dynamic, headers: dynamic): string function

Performs an HTTPS POST request with the given body, optionally with the given headers (a dict of string to string), and returns the response body as a string

http_put(url: dynamic, body: dynamic, headers: dynamic): string function

Performs an HTTPS PUT request with the given body, optionally with the given headers (a dict of string to string), and returns the response body as a string

http_patch(url: dynamic, body: dynamic, headers: dynamic): string function

Performs an HTTPS PATCH request with the given body, optionally with the given headers (a dict of string to string), and returns the response body as a string

http_delete(url: dynamic, headers: dynamic): string function

Performs an HTTPS DELETE request, optionally with the given headers (a dict of string to string), and returns the response body as a string

http_head(url: dynamic, headers: dynamic): string function

Performs an HTTPS HEAD request, optionally with the given headers (a dict of string to string), and returns the response body as a string

http_get_json(url: dynamic, headers: dynamic): dynamic function

Performs an HTTPS GET request, optionally with the given headers (a dict of string to string), and parses the response body as JSON, returning the resulting data structure

http_post_json(url: dynamic, body: dynamic, headers: dynamic): dynamic function

Performs an HTTPS POST request with the given body, optionally with the given headers (a dict of string to string), and parses the response body as JSON, returning the resulting data structure

http_put_json(url: dynamic, body: dynamic, headers: dynamic): dynamic function

Performs an HTTPS PUT request with the given body, optionally with the given headers (a dict of string to string), and parses the response body as JSON, returning the resulting data structure

http_patch_json(url: dynamic, body: dynamic, headers: dynamic): dynamic function

Performs an HTTPS PATCH request with the given body, optionally with the given headers (a dict of string to string), and parses the response body as JSON, returning the resulting data structure

http_delete_json(url: dynamic, headers: dynamic): dynamic function

Performs an HTTPS DELETE request, optionally with the given headers (a dict of string to string), and parses the response body as JSON, returning the resulting data structure

debug(args: dynamic): dynamic function

Prints the debug information of the given value(s).

increase_header_depth(node: dynamic): markdown function

Increases the depth (numeric level) of a markdown heading node by one, effectively demoting the heading (e.g. h1 -> h2), up to a maximum of 6.

Example
increase_header_depth(to_h("t", 1))
Result
## t
decrease_header_depth(node: dynamic): markdown function

Decreases the depth (numeric level) of a markdown heading node by one, effectively promoting the heading (e.g. h2 -> h1), down to a minimum of 1.

Example
decrease_header_depth(to_h("t", 2))
Result
# t
demote_heading(node: dynamic): markdown function

Demotes a markdown heading by increasing its depth (numeric level) by one. This is an alias for `increase_header_depth`.

Example
demote_heading(to_h("t", 1))
Result
## t
promote_heading(node: dynamic): markdown function

Promotes a markdown heading by decreasing its depth (numeric level) by one. This is an alias for `decrease_header_depth`.

Example
promote_heading(to_h("t", 2))
Result
# t
increase_header_level(node: dynamic): markdown functionDeprecated

Deprecated: use `increase_header_depth` or `demote_heading` instead. Kept for backward compatibility; behavior unchanged.

Example
increase_header_level(to_h("t", 1))
Result
## t
decrease_header_level(node: dynamic): markdown functionDeprecated

Deprecated: use `decrease_header_depth` or `promote_heading` instead. Kept for backward compatibility; behavior unchanged.

Example
decrease_header_level(to_h("t", 2))
Result
# t
bsearch(arr: dynamic, target: dynamic): number function

Performs a binary search on a sorted array to find the index of the target value.

Example
bsearch([1, 3, 5, 7, 9], 5)
Result
2
slugify(s: dynamic, separator: dynamic): string function

Converts a string into a URL-friendly slug by lowercasing, replacing non-alphanumeric characters with hyphens, and trimming hyphens from the ends.

Example
slugify("Hello, World!")
Result
hello-world
percentile(arr: dynamic, p: dynamic): number function

Calculates the p-th percentile of an array of numbers using linear interpolation between closest ranks.

Example
percentile([1, 2, 3, 4, 5], 0.5)
Result
3
chunks(v: dynamic, size: dynamic): array function

Splits an array into chunks of a specified size, returning an array of arrays.

Example
chunks([1, 2, 3, 4, 5], 2)
Result
[[1, 2], [3, 4], [5]]
chunk_by(v: dynamic, f: dynamic): array function

Splits an array into chunks based on the result of applying a function to each element, grouping consecutive elements with the same key together.

Example
chunk_by([1, 1, 2, 2, 3], identity)
Result
[[1, 1], [2, 2], [3]]
flip(f: dynamic, a: dynamic, b: dynamic): dynamic function

Returns a new function that takes the same arguments as the original function but with the first two arguments flipped.

Example
flip(sub, 2, 10)
Result
8
complement(f: dynamic): bool function

Returns a new predicate function that negates the result of the given function.

Example
let f = complement(is_none) | f(1)
Result
true
comp(fns: dynamic): dynamic function

Composes functions into one function, applying them right-to-left. `comp(f, g, h)(x)` is equivalent to `f(g(h(x)))`.

Example
let f = comp(fn(x): x + 1;, fn(x): x * 2;) | f(3)
Result
7
juxt(fns: dynamic): array function

Returns a function that applies each given function to its argument and collects the results into an array. `juxt(f, g, h)(x)` is equivalent to `[f(x), g(x), h(x)]`.

Example
let f = juxt(first, last) | f([1, 2, 3])
Result
[1, 3]
sum(arr: dynamic): number function

Returns the sum of the elements in an array after applying a transformation function to each element.

Example
sum([1, 2, 3])
Result
6
mean(arr: dynamic): number function

Returns the average (mean) of an array of numbers, or None if the array is empty.

Example
mean([1, 2, 3])
Result
2
geomean(arr: dynamic): number function

Returns the geometric mean of an array of numbers, or None if the array is empty.

Example
geomean([1, 4])
Result
2
variance(arr: dynamic): number function

Returns the population variance of an array of numbers, or None if the array is empty.

Example
variance([2, 4, 4, 4, 5, 5, 7, 9])
Result
4
stddev(arr: dynamic): number function

Returns the population standard deviation of an array of numbers, or None if the array is empty.

Example
stddev([2, 4, 4, 4, 5, 5, 7, 9])
Result
2
mode(arr: dynamic): array function

Returns the mode(s) of an array, i.e. the most frequently occurring value(s). Multiple values are returned if there is a tie for the highest frequency. Returns None if the array is empty.

Example
mode([1, 2, 2, 3])
Result
[2]
describe(arr: dynamic): dict function

Returns a dict of summary statistics for an array of numbers: `{min, max, mean, median, stddev, variance, count}`. Returns None if the array is empty.

Example
describe([1, 2, 3, 4, 5])
Result
{"count": 5, "min": 1, "max": 5, "mean": 3, "variance": 2, "stddev": 1.414214, "median": 3}
ngram(s: dynamic, n: dynamic): array function

Returns the n-grams of an array or string, which are overlapping contiguous subarrays (or substrings) of length n, sliding one element at a time.

Example
ngram("abcd", 2)
Result
["ab", "bc", "cd"]
zip(arr1: dynamic, arr2: dynamic): array function

Combines two arrays into an array of pairs, where each pair contains elements from the same index in both arrays.

Example
zip([1, 2], ["a", "b"])
Result
[[1, "a"], [2, "b"]]
min_by(arr: dynamic, f: dynamic): dynamic function

Returns the minimum element in an array based on a provided function that extracts a comparable value from each element.

Example
min_by([3, 1, 2], identity)
Result
1
max_by(arr: dynamic, f: dynamic): dynamic function

Returns the maximum element in an array based on a provided function that extracts a comparable value from each element.

Example
max_by([3, 1, 2], identity)
Result
3
lines(s: dynamic): array function

Returns the lines of a string as an array by splitting on newline characters.

Example
lines("a\nb\nc")
Result
["a", "b", "c"]
unlines(arr: dynamic): string function

Joins an array of strings into a single string with newline characters between them.

Example
unlines(["a", "b", "c"]) == "a\nb\nc"
Result
true
pick(d: dynamic, keys: dynamic): dict function

Returns a new dictionary containing only the specified keys from the original dictionary, if they exist.

Example
pick({"a": 1, "b": 2}, ["a"])
Result
{"a": 1}
omit(d: dynamic, keys: dynamic): dict function

Returns a new dictionary excluding the specified keys from the original dictionary.

Example
omit({"a": 1, "b": 2}, ["a"])
Result
{"b": 2}
has(v: dynamic, key: dynamic): bool function

Checks if a dict has the given key, or an array has an element at the given index.

Example
has({"a": 1}, "a")
Result
true
get_path(value: dynamic, path: dynamic): dynamic function

Retrieves a nested value by following an array of keys/indices, e.g. `get_path(d, ["a", "b", 0])`. Returns None as soon as any intermediate step is missing.

Example
get_path({"a": {"b": 1}}, ["a", "b"])
Result
1
set_path(value: dynamic, path: dynamic, new_value: dynamic): dynamic function

Sets a nested value by following an array of keys/indices, e.g. `set_path(d, ["a", "b", 0], 1)`. Missing intermediate dicts/arrays are created automatically, choosing an array when the corresponding path element is a number and a dict otherwise.

Example
set_path({"a": {"b": 1}}, ["a", "b"], 2)
Result
{"a": {"b": 2}}
del_path(value: dynamic, path: dynamic): dynamic function

Deletes the value at a nested path, following an array of keys/indices, e.g. `del_path(d, ["a", "b", 0])`. An empty path deletes the whole value, mirroring jq's `delpaths([[]])`. A path through a missing intermediate container, or ending in a missing key/out-of-range index, leaves `value` unchanged.

Example
del_path({"a": {"b": 1, "c": 2}}, ["a", "b"])
Result
{"a": {"c": 2}}
del_paths(value: dynamic, paths: dynamic): dynamic function

Deletes the values at multiple nested paths, e.g. `del_paths(d, [["a"], ["b", 0]])`. Paths are applied deepest-first (via `sort`/`reverse`) so that deleting one array element doesn't shift the indices used by the remaining paths, mirroring jq's `delpaths`.

Example
del_paths({"a": 1, "b": 2, "c": 3}, [["a"], ["c"]])
Result
{"b": 2}
paths(value: dynamic): array function

Returns an array of leaf-path arrays for a value, e.g. `paths({"a": {"b": 1}})` returns `[["a", "b"]]`. Each returned path can be passed to `get_path`/`set_path`. Containers with no leaves (e.g. `{}`, `[]`) contribute no paths.

Example
paths({"a": {"b": 1}})
Result
[["a", "b"]]
from_entries(arr: dynamic): dict function

Builds a dict from an array of [key, value] pairs, as produced by `entries`. If the same key appears more than once, the last occurrence wins.

Example
from_entries([["a", 1], ["b", 2]])
Result
{"a": 1, "b": 2}
with_entries(d: dynamic, f: dynamic): dict function

Transforms each [key, value] pair of a dict by applying the given function, then rebuilds a dict from the resulting pairs.

Example
with_entries({"a": 1}, fn(e): [e[0], e[1] + 1];)
Result
{"a": 2}
merge_with(a: dynamic, b: dynamic, policy: dynamic): dynamic function

Deep merges two values, recursing into dicts key by key. Neither input is mutated. When both sides provide a leaf/array value for the same key, the conflict is resolved according to `policy`, one of: - `"replace"`: the second value (`b`) wins. - `"append"`: arrays are concatenated; other conflicting values are collected into `[a, b]`. - `"error"`: raises an error describing the conflict.

Example
merge_with({"a": 1, "b": {"x": 1}}, {"b": {"y": 2}, "c": 3}, "replace")
Result
{"a": 1, "b": {"x": 1, "y": 2}, "c": 3}
merge_defaults(d: dynamic, defaults: dynamic): dynamic function

Deep merges `d` over `defaults`, similar to Jsonnet's object inheritance: values present in `d` win (recursively for nested dicts), while keys missing from `d` fall back to the corresponding value in `defaults`. Arrays and scalar conflicts are resolved by letting `d` replace `defaults`. Neither input is mutated.

Example
merge_defaults({"a": {"x": 1}}, {"a": {"x": 0, "y": 2}, "b": 3})
Result
{"a": {"x": 1, "y": 2}, "b": 3}
frontmatter(v: dynamic): dynamic function

Parses frontmatter from a markdown node, supporting both YAML and TOML formats.

walk(v: dynamic, f: dynamic): dynamic function

Walks through a value (which can be a markdown node, array, or dict) and applies a function to each element, returning a new structure with the results.

Example
walk([1, [2, 3]], fn(x): if (is_number(x)): x * 2 else: x;)
Result
[2, [4, 6]]
human_bytes(n: dynamic): string function

Formats a byte count as a human-readable decimal (SI, 1000-based) string, e.g. `human_bytes(1500)` => "1.5KB". Negative numbers keep their sign.

Example
human_bytes(1500)
Result
1.5KB
human_size(n: dynamic): string function

Formats a byte count as a human-readable binary (IEC, 1024-based) string without the "i" suffix, matching `numfmt --to=iec`, e.g. `human_size(1536)` => "1.5K". Negative numbers keep their sign.

Example
human_size(1536)
Result
1.5K
cbor_parse(input: dynamic): dynamic function

Parses a base64-encoded CBOR string (or raw bytes) and returns the corresponding data structure.

Module: import "cbor" | cbor::cbor_parse(...)

Example
import "cbor" | cbor::cbor_parse(cbor::cbor_stringify({"a": 1}))
Result
{"a": 1}
cbor_stringify(data: dynamic): bytes function

Serializes a value to CBOR bytes.

Module: import "cbor" | cbor::cbor_stringify(...)

Example
import "cbor" | cbor::cbor_stringify(1)
Result
f93c00
csv_needs_quote(field: dynamic, delimiter: dynamic): bool function

Checks whether a field's string form needs quoting for the given delimiter (RFC 4180): it contains a quote, newline, carriage return, the delimiter itself, or leading/trailing whitespace.

Module: import "csv" | csv::csv_needs_quote(...)

Example
import "csv" | csv::csv_needs_quote("a,b", ",")
Result
true
csv_parse_with_delimiter(input: dynamic, delimiter: dynamic, has_header: dynamic): array function

Parses CSV content with a specified delimiter and optional header row.

Module: import "csv" | csv::csv_parse_with_delimiter(...)

Example
import "csv" | csv::csv_parse_with_delimiter("a;b\n1;2", ";", true)
Result
[{"a": "1", "b": "2"}]
csv_parse(input: dynamic, has_header: dynamic): array function

Parses CSV content using a comma as the delimiter.

Module: import "csv" | csv::csv_parse(...)

Example
import "csv" | csv::csv_parse("name,age\nAlice,30", true)
Result
[{"name": "Alice", "age": "30"}]
tsv_parse(input: dynamic, has_header: dynamic): array function

Parses TSV (Tab-Separated Values) content.

Module: import "csv" | csv::tsv_parse(...)

Example
import "csv" | csv::tsv_parse("name\tage\nAlice\t30", true)
Result
[{"name": "Alice", "age": "30"}]
psv_parse(input: dynamic, has_header: dynamic): array function

Parses PSV (Pipe-Separated Values) content.

Module: import "csv" | csv::psv_parse(...)

Example
import "csv" | csv::psv_parse("name|age\nAlice|30", true)
Result
[{"name": "Alice", "age": "30"}]
csv_stringify(data: dynamic, delimiter: dynamic): string function

Converts data to a CSV string with a specified delimiter.

Module: import "csv" | csv::csv_stringify(...)

Example
import "csv" | csv::csv_stringify([{"name": "Alice", "age": 30}], ",")
Result
name,age
Alice,30
csv_to_markdown_table(data: dynamic): string function

Converts CSV data to a Markdown table format.

Module: import "csv" | csv::csv_to_markdown_table(...)

Example
import "csv" | csv::csv_to_markdown_table([{"name": "Alice", "age": 30}])
Result
| name | age |
| --- | --- |
| Alice | 30 |
csv_to_json(data: dynamic): string function

Converts CSV data to a JSON string.

Module: import "csv" | csv::csv_to_json(...)

Example
import "csv" | csv::csv_to_json([{"name": "Alice", "age": 30}])
Result
[{"name":"Alice","age":30}]
levenshtein(s1: dynamic, s2: dynamic): number function

Calculates the Levenshtein distance between two strings.

Module: import "fuzzy" | fuzzy::levenshtein(...)

Example
import "fuzzy" | fuzzy::levenshtein("kitten", "sitting")
Result
3
jaro(s1: dynamic, s2: dynamic): number function

Calculates the Jaro distance between two strings (0.0 to 1.0, where 1.0 is exact match).

Module: import "fuzzy" | fuzzy::jaro(...)

Example
import "fuzzy" | fuzzy::jaro("martha", "marhta")
Result
0.944444
jaro_winkler(s1: dynamic, s2: dynamic): number function

Calculates the Jaro-Winkler distance between two strings.

Module: import "fuzzy" | fuzzy::jaro_winkler(...)

Example
import "fuzzy" | fuzzy::jaro_winkler("martha", "marhta")
Result
0.961111
fuzzy_match(candidates: dynamic, query: dynamic): array function

Performs fuzzy matching on an array of strings using Jaro-Winkler distance.

Module: import "fuzzy" | fuzzy::fuzzy_match(...)

Example
import "fuzzy" | fuzzy::fuzzy_match(["apple", "aple", "banana"], "aple")
Result
[{"text": "aple", "score": 1}, {"text": "apple", "score": 0.946667}, {"text": "banana", "score": 0.472222}]
fuzzy_match_levenshtein(candidates: dynamic, query: dynamic): array function

Performs fuzzy matching using Levenshtein distance.

Module: import "fuzzy" | fuzzy::fuzzy_match_levenshtein(...)

Example
import "fuzzy" | fuzzy::fuzzy_match_levenshtein(["apple", "aple", "banana"], "aple")
Result
[{"text": "aple", "score": 0}, {"text": "apple", "score": 1}, {"text": "banana", "score": 5}]
fuzzy_match_jaro(candidates: dynamic, query: dynamic): array function

Performs fuzzy matching using Jaro distance.

Module: import "fuzzy" | fuzzy::fuzzy_match_jaro(...)

Example
import "fuzzy" | fuzzy::fuzzy_match_jaro(["apple", "aple", "banana"], "aple")
Result
[{"text": "aple", "score": 1}, {"text": "apple", "score": 0.933333}, {"text": "banana", "score": 0.472222}]
fuzzy_filter(candidates: dynamic, query: dynamic, threshold: dynamic): array function

Filters candidates by minimum fuzzy match score using Jaro-Winkler.

Module: import "fuzzy" | fuzzy::fuzzy_filter(...)

Example
import "fuzzy" | fuzzy::fuzzy_filter(["apple", "aple", "banana"], "aple", 0.8)
Result
[{"text": "aple", "score": 1}, {"text": "apple", "score": 0.946667}]
fuzzy_best_match(candidates: dynamic, query: dynamic): dict function

Finds the best fuzzy match from candidates.

Module: import "fuzzy" | fuzzy::fuzzy_best_match(...)

Example
import "fuzzy" | fuzzy::fuzzy_best_match(["apple", "aple", "banana"], "aple")
Result
{"text": "aple", "score": 1}
gron_parse(input: dynamic): dynamic function

Parses gron-style `path = value;` assignment statements (as produced by `mq -F gron`) and returns the corresponding data structure.

Module: import "gron" | gron::gron_parse(...)

Example
import "gron" | gron::gron_parse("json.a = 1;\njson.b = 2;")
Result
{"a": 1, "b": 2}
json_parse(input: dynamic): dynamic function

Parses a JSON string and returns the corresponding data structure.

Module: import "json" | json::json_parse(...)

Example
import "json" | json::json_parse("{\"a\": 1}")
Result
{"a": 1}
json_stringify(data: dynamic): string function

Serializes a value to a JSON string.

Module: import "json" | json::json_stringify(...)

Example
import "json" | json::json_stringify({"a": 1})
Result
{"a": 1}
json_to_markdown_table(data: dynamic): string function

Converts a JSON data structure to a Markdown table.

Module: import "json" | json::json_to_markdown_table(...)

Example
import "json" | json::json_to_markdown_table([{"a": 1, "b": 2}])
Result
| a | b |
| --- | --- |
| 1 | 2 |
h(value: dynamic, depth: dynamic): markdown function

Wraps `value` in a heading node at the given `depth` (1-6).

Module: import "md" | md::h(...)

Example
import "md" | md::h("Title", 1)
Result
# Title
code(value: dynamic, lang: dynamic): markdown function

Wraps `value` in a fenced code block with the given `lang`.

Module: import "md" | md::code(...)

code_inline(value: dynamic): markdown function

Wraps `value` in an inline code span.

Module: import "md" | md::code_inline(...)

Example
import "md" | md::code_inline("x")
Result
`x`
text(value: dynamic): markdown function

Creates a plain text node from `value`.

Module: import "md" | md::text(...)

Example
import "md" | md::text("hi")
Result
hi
strong(value: dynamic): markdown function

Wraps `value` in a strong (bold) node.

Module: import "md" | md::strong(...)

Example
import "md" | md::strong("Bold")
Result
**Bold**
em(value: dynamic): markdown function

Wraps `value` in an emphasis (italic) node.

Module: import "md" | md::em(...)

Example
import "md" | md::em("Italic")
Result
*Italic*
delete(value: dynamic): markdown function

Wraps `value` in a delete (strikethrough) node.

Module: import "md" | md::delete(...)

Example
import "md" | md::delete("Old")
Result
~~Old~~
blockquote(value: dynamic): markdown function

Wraps `value` in a blockquote node.

Module: import "md" | md::blockquote(...)

Example
import "md" | md::blockquote("Quote")
Result
> Quote
callout(value: dynamic, kind: dynamic, title: dynamic): markdown function

Wraps `value` in a callout node of the given `kind` (e.g. "note", "warning"), with an optional custom `title`.

Module: import "md" | md::callout(...)

Example
import "md" | md::callout("Note text", "note", "")
Result
> [!NOTE]
> Note text
hr(): markdown function

Creates a horizontal rule node.

Module: import "md" | md::hr(...)

Example
import "md" | md::hr()
Result
***
br(): markdown function

Creates a blank line between the surrounding elements in a `doc()`/`to_md_fragment()` call.

Module: import "md" | md::br(...)

math(value: dynamic): markdown function

Wraps `value` in a math block node.

Module: import "md" | md::math(...)

Example
import "md" | md::math("x^2")
Result
$$
x^2
$$
math_inline(value: dynamic): markdown function

Wraps `value` in an inline math node.

Module: import "md" | md::math_inline(...)

Example
import "md" | md::math_inline("x^2")
Result
$x^2$
link(url: dynamic, value: dynamic, title: dynamic): markdown function

Creates a link node pointing to `url` with link text `value` and an optional `title`.

Module: import "md" | md::link(...)

Example
import "md" | md::link("https://example.com", "Example", "")
Result
[Example](https://example.com)
image(url: dynamic, alt: dynamic, title: dynamic): markdown function

Creates an image node pointing to `url` with `alt` text and an optional `title`.

Module: import "md" | md::image(...)

Example
import "md" | md::image("https://example.com/a.png", "Alt", "")
Result
![Alt](https://example.com/a.png "")
footnote(value: dynamic, ident: dynamic): markdown function

Wraps `value` in a footnote definition node identified by `ident`.

Module: import "md" | md::footnote(...)

Example
import "md" | md::footnote("Footnote text", "1")
Result
[^1]: Footnote text
footnote_ref(ident: dynamic): markdown function

Creates a footnote reference node pointing at `ident`.

Module: import "md" | md::footnote_ref(...)

Example
import "md" | md::footnote_ref("1")
Result
[^1]
definition(url: dynamic, ident: dynamic, title: dynamic): markdown function

Creates a link reference definition node (`[ident]: url "title"`) for `ident`, with an optional `title`.

Module: import "md" | md::definition(...)

Example
import "md" | md::definition("https://example.com", "ex", "")
Result
[ex]: https://example.com
html(value: dynamic): markdown function

Wraps `value` in a raw HTML node, emitted as-is.

Module: import "md" | md::html(...)

Example
import "md" | md::html("<br>")
Result
<br>
linebreak(): markdown function

Creates a hard line break node.

Module: import "md" | md::linebreak(...)

list(value: dynamic, level: dynamic, ordered: dynamic, checked: dynamic): markdown function

Wraps `value` in a list item node at the given `level` (0-indexed nesting), optionally `ordered` (numbered) and/or `checked` (checkbox); pass `checked = None` for a plain item.

Module: import "md" | md::list(...)

Example
import "md" | md::list("Item", 0)
Result
- Item
table_row(cells: dynamic): markdown function

Creates a table row node from an array of cell values.

Module: import "md" | md::table_row(...)

Example
import "md" | md::table_row(["a", "b"])
Result
|a|b|
table_cell(value: dynamic, row: dynamic, column: dynamic): markdown function

Creates a single table cell node at the given `row`/`column`.

Module: import "md" | md::table_cell(...)

Example
import "md" | md::table_cell("A1", 0, 0)
Result
A1
table_align(aligns: dynamic): markdown function

Creates a table alignment (header separator) row node from an array of alignments (e.g. ["left", "right", "center"]).

Module: import "md" | md::table_align(...)

Example
import "md" | md::table_align(["left", "right"])
Result
|:---|---:|
table(header: dynamic, rows: dynamic, aligns: dynamic): array function

Builds a full table from a `header` array of cell values and a `rows` array of row arrays. `aligns` is an array of alignment strings (e.g. ["left", "right", "center"]) matching `header`'s length; defaults to no alignment. Returns an array of row/align nodes ready to splice into `doc()`.

Module: import "md" | md::table(...)

Example
import "md" | md::doc(md::table(["A", "B"], [["1", "2"], ["3", "4"]]))
Result
|A|B|
|---|---|
|1|2|
|3|4|
doc(values: dynamic): markdown function

Combines markdown nodes into a single markdown value. Accepts either a variable number of arguments (`doc(a, b, c)`) or a single array (`doc([a, b, c])`). Nested arrays (e.g. from `map()`) are flattened automatically, so components can return plain arrays of nodes and be spliced in as children.

Module: import "md" | md::doc(...)

Example
import "md" | md::doc(md::h("T", 1), md::text("hi"))
Result
# T
hi
section(md_nodes: dynamic, pattern: dynamic, depth: dynamic): array function

Returns sections whose title contains the specified pattern. If depth is true, each section spans until the next header at the same or higher level (delegates to section::sections(md_nodes, depth), see its doc for details).

Module: import "section" | section::section(...)

Example
import "section" | len(section::section(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"), "A"))
Result
2
sections(md_nodes: dynamic, depth: dynamic): array function

Splits markdown nodes into sections based on headers. If depth is true, each section's body extends to the next heading at the same or higher level as that section's own heading, so nested subheadings' content is included in their parent's body. If depth is false (default), every heading of any level is a boundary, so a heading's body only extends to the very next heading regardless of level.

Module: import "section" | section::sections(...)

Example 1
import "section" | len(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")))
Result
3
Example 2
import "section" | len(section::body(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"), true))))
Result
3
filter_sections(md_nodes: dynamic, predicate: dynamic): array function

Filters sections based on a given predicate function.

Module: import "section" | section::filter_sections(...)

Example
import "section" | len(section::filter_sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"), fn(s): true;))
Result
3
map_sections(md_nodes: dynamic, mapper: dynamic): array function

Maps sections using a given mapper function.

Module: import "section" | section::map_sections(...)

Example
import "section" | section::map_sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"), fn(header, children): to_text(header);)
Result
["A", "A1", "B"]
split(md_nodes: dynamic, level: dynamic): array function

Returns an array of sections, each section is an array of markdown nodes between the specified header and the next header of the same level.

Module: import "section" | section::split(...)

Example
import "section" | len(section::split(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"), 1))
Result
2
title_contains(sections: dynamic, text: dynamic): array function

Filters the given list of sections, returning only those whose title contains the specified text.

Module: import "section" | section::title_contains(...)

Example
import "section" | len(section::title_contains(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")), "A"))
Result
2
title_match(sections: dynamic, pattern: dynamic): array function

Filters sections by a pattern match in the title text.

Module: import "section" | section::title_match(...)

Example
import "section" | len(section::title_match(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")), "^A"))
Result
2
title(section: dynamic): string function

Returns the title text of a section (header text without the # symbols).

Module: import "section" | section::title(...)

Example
import "section" | section::title(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"))))
Result
A
content(section: dynamic): array functionDeprecated

Returns the content of a section (all nodes except the header). Deprecated: Use body() instead, as content()

Module: import "section" | section::content(...)

Example
import "section" | len(section::content(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")))))
Result
1
body(section: dynamic): array function

Returns the body of a section (all nodes except the header).

Module: import "section" | section::body(...)

Example
import "section" | len(section::body(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")))))
Result
1
all_nodes(section: dynamic): array function

Returns all nodes of a section, including both the header and content.

Module: import "section" | section::all_nodes(...)

Example
import "section" | len(section::all_nodes(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")))))
Result
2
by_level(sections: dynamic, l: dynamic): array function

Filters sections by heading level. l can be a number (exact level) or a range array (e.g. 1..2).

Module: import "section" | section::by_level(...)

Example
import "section" | len(section::by_level(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")), 1))
Result
2
level(section: dynamic): number function

Returns the header level (1-6) of a section.

Module: import "section" | section::level(...)

Example
import "section" | section::level(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"))))
Result
1
nth(sections: dynamic, n: dynamic): dynamic function

Returns the nth section from an array of sections (0-indexed).

Module: import "section" | section::nth(...)

Example
import "section" | section::title(section::nth(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")), 0))
Result
A
titles(sections: dynamic): array function

Extracts titles from all sections.

Module: import "section" | section::titles(...)

Example
import "section" | section::titles(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")))
Result
["A", "A1", "B"]
bodies(sections: dynamic): array function

Extracts body from all sections.

Module: import "section" | section::bodies(...)

Example
import "section" | len(section::bodies(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"))))
Result
3
toc(sections: dynamic): array function

Generates a table of contents from sections.

Module: import "section" | section::toc(...)

Example
import "section" | section::toc(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")))
Result
["  - A", "    - A1", "  - B"]
has_content(section: dynamic): bool function

Checks if a section has any content beyond the header.

Module: import "section" | section::has_content(...)

Example
import "section" | section::has_content(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"))))
Result
true
collect(sections: dynamic): array function

Flattens sections back to markdown nodes for output. This converts section objects back to their original markdown node arrays.

Module: import "section" | section::collect(...)

Example
import "section" | len(section::collect(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"))))
Result
6
semver_parse(s: dynamic): dict function

Parses a SemVer string into a dict with major, minor, patch, pre, and build fields.

Module: import "semver" | semver::semver_parse(...)

Example
import "semver" | semver::semver_to_string(semver::semver_parse("1.2.3-beta.1"))
Result
1.2.3-beta.1
semver_to_string(v: dynamic): string function

Converts a parsed SemVer dict back to a version string.

Module: import "semver" | semver::semver_to_string(...)

Example
import "semver" | semver::semver_to_string(semver::semver_parse("1.2.3-beta"))
Result
1.2.3-beta
semver_compare(a: dynamic, b: dynamic): number function

Compares two parsed SemVer dicts. Returns -1 if a < b, 0 if a == b, 1 if a > b.

Module: import "semver" | semver::semver_compare(...)

Example
import "semver" | semver::semver_compare(semver::semver_parse("1.0.0"), semver::semver_parse("2.0.0"))
Result
-1
semver_gt(a: dynamic, b: dynamic): bool function

Returns true if version a is greater than version b.

Module: import "semver" | semver::semver_gt(...)

Example
import "semver" | semver::semver_gt(semver::semver_parse("2.0.0"), semver::semver_parse("1.0.0"))
Result
true
semver_lt(a: dynamic, b: dynamic): bool function

Returns true if version a is less than version b.

Module: import "semver" | semver::semver_lt(...)

Example
import "semver" | semver::semver_lt(semver::semver_parse("1.0.0"), semver::semver_parse("2.0.0"))
Result
true
semver_eq(a: dynamic, b: dynamic): bool function

Returns true if version a equals version b (ignoring build metadata).

Module: import "semver" | semver::semver_eq(...)

Example
import "semver" | semver::semver_eq(semver::semver_parse("1.0.0"), semver::semver_parse("1.0.0"))
Result
true
semver_gte(a: dynamic, b: dynamic): bool function

Returns true if version a is greater than or equal to version b.

Module: import "semver" | semver::semver_gte(...)

Example
import "semver" | semver::semver_gte(semver::semver_parse("1.0.0"), semver::semver_parse("1.0.0"))
Result
true
semver_lte(a: dynamic, b: dynamic): bool function

Returns true if version a is less than or equal to version b.

Module: import "semver" | semver::semver_lte(...)

Example
import "semver" | semver::semver_lte(semver::semver_parse("1.0.0"), semver::semver_parse("1.0.0"))
Result
true
semver_bump_major(v: dynamic): dict function

Increments the major version and resets minor, patch, and pre-release.

Module: import "semver" | semver::semver_bump_major(...)

Example
import "semver" | semver::semver_to_string(semver::semver_bump_major(semver::semver_parse("1.2.3")))
Result
2.0.0
semver_bump_minor(v: dynamic): dict function

Increments the minor version and resets patch and pre-release.

Module: import "semver" | semver::semver_bump_minor(...)

Example
import "semver" | semver::semver_to_string(semver::semver_bump_minor(semver::semver_parse("1.2.3")))
Result
1.3.0
semver_bump_patch(v: dynamic): dict function

Increments the patch version and clears pre-release.

Module: import "semver" | semver::semver_bump_patch(...)

Example
import "semver" | semver::semver_to_string(semver::semver_bump_patch(semver::semver_parse("1.2.3")))
Result
1.2.4
semver_sort(versions: dynamic): array function

Sorts an array of parsed SemVer dicts in ascending order.

Module: import "semver" | semver::semver_sort(...)

Example
import "semver" | map(semver::semver_sort([semver::semver_parse("2.0.0"), semver::semver_parse("1.0.0")]), semver::semver_to_string)
Result
["1.0.0", "2.0.0"]
semver_max(versions: dynamic): dict function

Returns the maximum version from an array of parsed SemVer dicts.

Module: import "semver" | semver::semver_max(...)

Example
import "semver" | semver::semver_to_string(semver::semver_max([semver::semver_parse("1.0.0"), semver::semver_parse("2.0.0")]))
Result
2.0.0
semver_min(versions: dynamic): dict function

Returns the minimum version from an array of parsed SemVer dicts.

Module: import "semver" | semver::semver_min(...)

Example
import "semver" | semver::semver_to_string(semver::semver_min([semver::semver_parse("1.0.0"), semver::semver_parse("2.0.0")]))
Result
1.0.0
semver_satisfies(version: dynamic, range: dynamic): bool function

Returns true if the given version string satisfies every comma-separated comparator in `range`. Supported comparators: "=", "==", "!=", ">", ">=", "<", "<=". A bare version (no operator) requires an exact match. Example: semver_satisfies("1.5.0", ">=1.0.0,<2.0.0") == true

Module: import "semver" | semver::semver_satisfies(...)

Example
import "semver" | semver::semver_satisfies("1.5.0", ">=1.0.0,<2.0.0")
Result
true
tables(md_nodes: dynamic): array function

Extract table structures from a list of markdown nodes.

Module: import "table" | table::tables(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | len(self)
Result
1
set_align(table: dynamic, align: dynamic): dict function

Set the alignment for a table.

Module: import "table" | table::set_align(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::set_align(self, ["left", "right"]) | table::to_csv(self)
Result
a,b
1,2
3,4
add_row(table: dynamic, row: dynamic): dict function

Add a new row to a table.

Module: import "table" | table::add_row(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::add_row(self, ["5", "6"]) | table::to_csv(self)
Result
a,b
1,2
3,4
5,6
add_column(table: dynamic, col: dynamic): dict function

Add a new column to a table.

Module: import "table" | table::add_column(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::add_column(self, ["c", "9", "10"]) | table::to_csv(self)
Result
a,b,c
1,2,9
3,4,10
remove_row(table: dynamic, row_index: dynamic): dict function

Remove a row from a table at the specified index.

Module: import "table" | table::remove_row(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::remove_row(self, 0) | table::to_csv(self)
Result
a,b
3,4
remove_column(table: dynamic, col_index: dynamic): dict function

Remove a column from a table at the specified index.

Module: import "table" | table::remove_column(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::remove_column(self, 0) | len(self[:rows][0])
Result
1
map_rows(table: dynamic, f: dynamic): dict function

Map a function over each row in the table.

Module: import "table" | table::map_rows(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::map_rows(self, fn(row): row;) | table::to_csv(self)
Result
a,b
1,2
3,4
filter_tables(tables: dynamic, f: dynamic): array function

Filter tables from markdown nodes based on a predicate function.

Module: import "table" | table::filter_tables(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | table::filter_tables(self, fn(h, r): true;) | len(self)
Result
1
filter_rows(table: dynamic, f: dynamic): dict function

Filter rows in the table based on a predicate function.

Module: import "table" | table::filter_rows(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::filter_rows(self, fn(row): true;) | table::to_csv(self)
Result
a,b
1,2
3,4
sort_rows(table: dynamic, column_index: dynamic): dict function

Sort rows in the table by a specified column index or default sorting.

Module: import "table" | table::sort_rows(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::sort_rows(self) | table::to_csv(self)
Result
a,b
1,2
3,4
to_markdown(table: dynamic): array function

Convert a table structure back into a list of markdown nodes.

Module: import "table" | table::to_markdown(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::to_markdown(self) | len(self)
Result
7
to_csv(table: dynamic, delimiter: dynamic): string function

Convert a table structure into a CSV string with the specified delimiter.

Module: import "table" | table::to_csv(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::to_csv(self)
Result
a,b
1,2
3,4
to_array(table: dynamic): array function

Convert a table structure into an array of dict records keyed by header text. The resulting shape matches `csv::csv_parse`'s output, so it composes with `join_by` and other record-array builtins.

Module: import "table" | table::to_array(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::to_array(self)
Result
[{"a": "1", "b": "2"}, {"a": "3", "b": "4"}]
pivot_longer(table: dynamic, value_columns: dynamic, names_to: dynamic, values_to: dynamic): dict function

Reshape a table from wide format to long format (a.k.a. melt/unpivot). `value_columns` is an array of column indices to unpivot; each one becomes a row holding its header name (in the `names_to` column) and its cell value (in the `values_to` column). Columns not listed in `value_columns` are treated as identifier columns and repeated for every unpivoted value.

Module: import "table" | table::pivot_longer(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::pivot_longer(self, [1]) | table::to_csv(self)
Result
a,name,value
1,b,2
3,b,4
pivot_wider(table: dynamic, names_from: dynamic, values_from: dynamic): dict function

Reshape a table from long format to wide format (a.k.a. pivot/cast). `names_from` is the column index whose distinct values become the headers of new columns; `values_from` is the column index supplying the values for those new columns. Columns other than `names_from` and `values_from` are treated as identifier columns and used to group rows together.

Module: import "table" | table::pivot_wider(...)

Example
import "table" | table::tables(to_markdown("| id | name | value |\n| --- | --- | --- |\n| 1 | x | 10 |\n| 1 | y | 20 |")) | first(self) | table::pivot_wider(self, 1, 2) | table::to_csv(self)
Result
id,x,y
1,10,20
assert(cond: dynamic): dynamic function

Verifies that a condition is true and raises an error if it's false.

Module: import "test" | test::assert(...)

Example
true | include "test" | assert(true)
Result
true
assert_eq(actual: dynamic, expected: dynamic): dynamic function

Verifies that two values are equal

Module: import "test" | test::assert_eq(...)

Example
1 | include "test" | assert_eq(1, 1)
Result
1
assert_ne(actual: dynamic, expected: dynamic): dynamic function

Verifies that two values are not equal

Module: import "test" | test::assert_ne(...)

Example
1 | include "test" | assert_ne(1, 2)
Result
1
assert_true(value: dynamic): dynamic function

Verifies that a value is true

Module: import "test" | test::assert_true(...)

Example
true | include "test" | assert_true(true)
Result
true
assert_false(value: dynamic): dynamic function

Verifies that a value is false

Module: import "test" | test::assert_false(...)

Example
false | include "test" | assert_false(false)
Result
false
assert_none(value: dynamic): dynamic function

Verifies that a value is None

Module: import "test" | test::assert_none(...)

Example
None | include "test" | assert_none(None)
Result
assert_not_none(value: dynamic): dynamic function

Verifies that a value is not None

Module: import "test" | test::assert_not_none(...)

Example
1 | include "test" | assert_not_none(1)
Result
1
assert_contains(array: dynamic, value: dynamic): dynamic function

Verifies that an array contains a specific value

Module: import "test" | test::assert_contains(...)

Example
[1, 2] | include "test" | assert_contains([1, 2], 1)
Result
[1, 2]
assert_len(array: dynamic, expected_length: dynamic): dynamic function

Verifies that an array has a specific length

Module: import "test" | test::assert_len(...)

Example
[1, 2] | include "test" | assert_len([1, 2], 2)
Result
[1, 2]
assert_empty(array: dynamic): dynamic function

Verifies that an array is empty

Module: import "test" | test::assert_empty(...)

Example
[] | include "test" | assert_empty([])
Result
[]
assert_not_empty(array: dynamic): dynamic function

Verifies that an array is not empty

Module: import "test" | test::assert_not_empty(...)

Example
[1] | include "test" | assert_not_empty([1])
Result
[1]
assert_type(value: dynamic, expected_type: dynamic): dynamic function

Verifies that a value has the given type. For markdown nodes this checks the node kind (e.g. "h1", "code", "list"), matching `to_md_name`. For every other value it checks the runtime type returned by `type`. On failure the source range of `value` is included so callers (e.g. content-lint rules) can point at the offending node.

Module: import "test" | test::assert_type(...)

Example
1 | include "test" | assert_type(1, "number")
Result
1
assert_field(value: dynamic, field: dynamic): dynamic function

Verifies that a dict has the given field.

Module: import "test" | test::assert_field(...)

Example
{"a": 1} | include "test" | assert_field({"a": 1}, "a")
Result
{"a": 1}
assert_matches(value: dynamic, pattern: dynamic): dynamic function

Verifies that a value's string representation matches the given regular expression pattern.

Module: import "test" | test::assert_matches(...)

Example
"abc" | include "test" | assert_matches("abc", "a.c")
Result
abc
run_tests(tests: dynamic): bool function

Executes multiple test functions. The whole report is built as a single string and printed with one `print` call, so concurrently running test files (the Rust runner may evaluate several files in parallel) can never interleave their output mid-line. Returns `true` if every test passed, so the caller can aggregate pass/fail across files itself instead of this function terminating the process.

Module: import "test" | test::run_tests(...)

test_case(name: dynamic, func: dynamic): dict function

Helper function to create a test case

Module: import "test" | test::test_case(...)

Example
include "test" | test_case("my test", fn(): true;)["name"]
Result
my test
toml_parse(input: dynamic): dynamic function

Parses a TOML string and returns the parsed data structure.

Module: import "toml" | toml::toml_parse(...)

Example
import "toml" | toml::toml_parse("key = 1")
Result
{"key": 1}
toml_stringify(data: dynamic): string function

Converts a data structure to a TOML string representation.

Module: import "toml" | toml::toml_stringify(...)

Example
import "toml" | toml::toml_stringify({"key": 1})
Result
key = 1
toml_to_json(data: dynamic): string function

Converts a data structure to a JSON string representation.

Module: import "toml" | toml::toml_to_json(...)

Example
import "toml" | toml::toml_to_json({"key": 1})
Result
{"key":1}
toml_to_markdown_table(data: dynamic): string function

Converts a TOML data structure to a Markdown table.

Module: import "toml" | toml::toml_to_markdown_table(...)

Example
import "toml" | toml::toml_to_markdown_table([{"a": 1}])
Result
| a |
| --- |
| 1 |
toon_stringify(data: dynamic): string function

To convert a data structure into a TOON string

Module: import "toon" | toon::toon_stringify(...)

Example
import "toon" | toon::toon_stringify({"a": 1})
Result
a: 1
toon_parse(input: dynamic): dynamic function

To parse a TOON string into a data structure

Module: import "toon" | toon::toon_parse(...)

Example
import "toon" | toon::toon_parse(toon::toon_stringify({"a": 1}))
Result
{"a": 1}
xml_parse(input: dynamic): dynamic function

Parses an XML string and returns the corresponding data structure.

Module: import "xml" | xml::xml_parse(...)

Example
import "xml" | xml::xml_parse("<a>hi</a>")["tag"]
Result
a
xml_stringify(data: dynamic): string function

Serializes a value to an XML string.

Module: import "xml" | xml::xml_stringify(...)

Example
import "xml" | xml::xml_stringify({"tag": "a", "attributes": {}, "children": [], "text": "hi"})
Result
<?xml version="1.0" encoding="UTF-8"?>
<a>hi</a>
xml_to_markdown_table(data: dynamic): string function

Converts an XML data structure to a Markdown table.

Module: import "xml" | xml::xml_to_markdown_table(...)

Example
import "xml" | xml::xml_to_markdown_table({"tag": "a", "attributes": {}, "children": [], "text": "hi"})
Result
| Tag | Attributes | Text | Children |
| --- | --- | --- | --- |
| a |  | hi | 0 |
yaml_parse(input: dynamic): dynamic function

Parses a YAML string and returns the parsed data structure. A single `---`-separated document is returned as-is; if the input contains multiple `---`-separated documents, an array of the parsed documents is returned.

Module: import "yaml" | yaml::yaml_parse(...)

Example
import "yaml" | yaml::yaml_parse("key: 1")
Result
{"key": 1}
yaml_stringify(data: dynamic): string function

Converts a data structure to a YAML string representation.

Module: import "yaml" | yaml::yaml_stringify(...)

Example
import "yaml" | yaml::yaml_stringify({"key": 1})
Result
key: 1
yaml_to_markdown_table(data: dynamic): string function

Converts a YAML data structure to a Markdown table.

Module: import "yaml" | yaml::yaml_to_markdown_table(...)

Example
import "yaml" | yaml::yaml_to_markdown_table([{"a": 1}])
Result
| a |
| --- |
| 1 |
yaml_to_json(data: dynamic): string function

Converts a data structure to a JSON string representation.

Module: import "yaml" | yaml::yaml_to_json(...)

Example
import "yaml" | yaml::yaml_to_json({"key": 1})
Result
{"key": 1}
to_front_matter(data: dynamic): string functionDeprecated

Converts a data structure to a YAML front matter string. deprecated: use to_frontmatter instead

Module: import "yaml" | yaml::to_front_matter(...)

Example
import "yaml" | yaml::to_front_matter({"key": 1})
Result
---
key: 1
---
to_frontmatter(data: dynamic): string function

Converts a data structure to a YAML front matter string.

Module: import "yaml" | yaml::to_frontmatter(...)

Example
import "yaml" | yaml::to_frontmatter({"key": 1})
Result
---
key: 1
---

340 functions

abs(number: number): number function

Returns the absolute value of the given number.

Example
abs(-10)
Result
10
add(value1: dynamic, value2: dynamic): dynamic function

Adds two values.

Example
add(1, 2)
Result
3
all_symbols(): array function

Returns an array of all interned symbols.

and(value1: bool, value2: bool): bool function

Performs a logical AND operation on two boolean values.

Example
and(true, false)
Result
false
array(values: dynamic): array function

Creates an array from the given values.

Example
array(1, 2, 3)
Result
[1, 2, 3]
ascii_downcase(input: string): string function

Converts ASCII uppercase letters (A-Z) in the given string to lowercase, leaving all other characters unchanged.

Example
ascii_downcase("ABC")
Result
abc
ascii_upcase(input: string): string function

Converts ASCII lowercase letters (a-z) in the given string to uppercase, leaving all other characters unchanged.

Example
ascii_upcase("abc")
Result
ABC
attr(markdown: markdown, attribute: string): dynamic function

Retrieves the value of the specified attribute from a markdown node.

band(bytes1: bytes, bytes2: bytes): bytes function

Computes the bitwise AND of two byte arrays of equal length.

base64(input: string): string function

Encodes the given string to base64.

Example
base64("hi")
Result
aGk=
base64d(input: string): string function

Decodes the given base64 string.

Example
base64d("aGk=")
Result
hi
base64url(input: string): string function

Encodes the given string to URL-safe base64.

Example
base64url("hi")
Result
aGk
base64urld(input: string): string function

Decodes the given URL-safe base64 string.

Example
base64urld(base64url("hi"))
Result
hi
basename(path: string): string function

Returns the final component of a path string (e.g. "file.txt" from "/a/b/file.txt").

Example
basename("/a/b/file.txt")
Result
file.txt
bnot(bytes: bytes): bytes function

Computes the bitwise NOT (complement) of a byte array.

bor(bytes1: bytes, bytes2: bytes): bytes function

Computes the bitwise OR of two byte arrays of equal length.

breakpoint(): dynamic function

Sets a breakpoint for debugging; execution will pause at this point if a debugger is attached.

capture(string: string, pattern: string): dict function

Captures named groups from the given string based on the specified regular expression pattern and returns them as a dictionary keyed by group names.

Example
capture("v1.2.3", "(?P<major>[0-9]+)")
Result
{"major": "1"}
ceil(number: number): number function

Rounds the given number up to the nearest integer.

Example
ceil(3.2)
Result
4
coalesce(value1: dynamic, value2: dynamic): dynamic function

Returns the first non-None value from the two provided arguments.

Example
coalesce(None, 5)
Result
5
collection(dir: string, respect_gitignore?: boolean): array functionrequires file-io

Recursively reads every Markdown file in the given directory (including subdirectories and symlinked files/directories) and returns an array of `{path, title, frontmatter, content}` dicts, sorted by path, so they can be filtered, sorted, or aggregated as a single dataset. `content` holds the file's Markdown nodes with frontmatter stripped. Symlink cycles are detected and only visited once. `respect_gitignore` is optional (default `false`); when `true`, dotfiles/dot-directories and any path matched by a `.gitignore` in `dir` or a subdirectory are skipped, with closer `.gitignore` files taking precedence, same as `git`. Requires the --allow-read CLI flag; otherwise returns a runtime error.

compact(array: array): array function

Removes None values from the given array.

Example
compact([1, None, 2])
Result
[1, 2]
convert(input: dynamic, format: string): dynamic function

Converts the input value to the specified format. Supported formats: base64, html, text, uri, heading (#, ##, etc.), blockquote (>), list item (-), or link (URL).

date_add(array: array, n: number, unit: string): array function

Adds n units to a broken-down time array and returns a new array. Units: "seconds", "minutes", "hours", "days", "weeks", "months", "years". Month/year arithmetic is calendar-aware.

date_diff(array1: array, array2: array, unit: string): number function

Returns the difference (array2 - array1) in the given unit. Units: "seconds", "minutes", "hours", "days", "weeks".

Example
date_diff(gmtime(0), gmtime(86400), "days")
Result
1
date_relative(base_timestamp: number, date_str: string): number function

Parses a natural-language relative date expression (e.g. "3 days ago", "yesterday", "tomorrow", "next monday", "in 2 weeks") relative to a base Unix timestamp and returns the resulting Unix timestamp (seconds, UTC).

del(array_or_string: dynamic, index: number): dynamic function

Deletes the element at the specified index in the array or string.

Example
del([1, 2, 3], 1)
Result
[1, 3]
dict(): dict function

Creates a new, empty dict.

Example
dict()
Result
{}
dirname(path: string): string function

Returns the parent directory of a path string (e.g. "/a/b" from "/a/b/file.txt"). Returns "." if the path has no parent.

Example
dirname("/a/b/file.txt")
Result
/a/b
div(value1: dynamic, value2: dynamic): dynamic function

Divides the first value by the second value.

Example
div(6, 2)
Result
3
downcase(input: string): string function

Converts the given string to lowercase.

Example
downcase("ABC")
Result
abc
embed_images(base_dir: string): markdown functionrequires file-io

Inlines an `.image` node's local file into its `url` as a base64 `data:` URI, resolving the path relative to the given base directory (default ".") and inferring the MIME type from the file extension. URLs that are already `data:` URIs or contain a `://` scheme (e.g. `https://`), and non-image nodes, are left unchanged. Requires the --allow-read CLI flag; otherwise returns a runtime error.

ends_with(value: dynamic, suffix: dynamic): bool function

Checks if the given string or byte array ends with the specified suffix.

Example
ends_with("hello", "lo")
Result
true
entries(dict: dict): array function

Returns an array of key-value pairs from the dict as arrays.

eq(value1: dynamic, value2: dynamic): bool function

Checks if two values are equal.

Example
eq(1, 1)
Result
true
error(message: string): dynamic function

Raises a user-defined error with the specified message.

exp(number: number): number function

Returns the exponential (e^x) of the given number.

Example
exp(0)
Result
1
explode(string: string): array function

Splits the given string into an array of characters.

Example
explode("ab")
Result
[97, 98]
extname(path: string): string function

Returns the extension of a file path including the leading dot (e.g. ".txt" from "file.txt"). Returns an empty string if there is no extension.

Example
extname("file.txt")
Result
.txt
extract_images(dir: string): markdown functionrequires file-io

Decodes an `.image` node's base64 `data:` URI and writes the bytes to a file under the given directory, named by the content's MD5 hash with an extension inferred from the MIME type, then replaces `url` with that file's path. Nodes whose `url` is not a base64 `data:` URI, including non-image nodes, are left unchanged. Requires the --allow-write CLI flag; otherwise returns a runtime error.

file_exists(path: string): bool functionrequires file-io

Checks if a file exists at the given path. Requires the --allow-read CLI flag; otherwise returns a runtime error.

file_size(path: string): number functionrequires file-io

Returns the size, in bytes, of the file at the given path. Requires the --allow-read CLI flag; otherwise returns a runtime error.

flatten(array: array): array function

Flattens a nested array into a single level array.

Example
flatten([[1, 2], [3]])
Result
[1, 2, 3]
floor(number: number): number function

Rounds the given number down to the nearest integer.

Example
floor(3.8)
Result
3
from_date(date_str: string): number function

Converts a date string to a timestamp.

Example
from_date("1970-01-01T00:00:00Z")
Result
0
from_hex(hex_string: string): bytes function

Parses a hex string into raw bytes.

from_html(html: string): array function

Converts the given HTML string to Markdown.

get(obj: dict, key: dynamic): dynamic function

Retrieves a value from a dict by its key. Returns None if the key is not found.

get_location(node: markdown): dict function

Returns the source position of a markdown node as a dict with start_line, start_column, end_line, and end_column, or None if the node has no position info.

get_title(node: markdown): string function

Returns the title of a markdown node.

get_url(node: markdown): string function

Returns the url of a markdown node.

Example
get_url(to_link("https://example.com", "Example", ""))
Result
https://example.com
get_variable(symbol_or_string: dynamic): dynamic function

Retrieves the value of a symbol or variable from the current environment.

glob_match(pattern: string, path: string): bool function

Checks whether the given path matches the glob pattern (e.g. "*.md", "docs/**/*.rs"), commonly used to filter file lists.

Example
glob_match("*.md", "readme.md")
Result
true
gmtime(timestamp: number): array function

Converts Unix timestamp (seconds since epoch) to broken-down UTC time array [year, mon (0-11), mday, hour, min, sec, wday (0=Sun), yday (0-365)].

Example
gmtime(0)
Result
[1970, 0, 1, 0, 0, 0, 4, 0]
gsub(from: string, pattern: string, to: string): string function

Replaces all occurrences matching a regular expression pattern with the replacement string.

Example
gsub("a1b2", "[0-9]", "#")
Result
a#b#
gt(value1: dynamic, value2: dynamic): bool function

Checks if the first value is greater than the second value.

Example
gt(2, 1)
Result
true
gte(value1: dynamic, value2: dynamic): bool function

Checks if the first value is greater than or equal to the second value.

Example
gte(1, 1)
Result
true
halt(exit_code: number): dynamic function

Terminates the program with the given exit code.

html_escape(string: string): string function

Escapes `&`, `<`, `>`, `"`, and `'` in the given string as HTML entities.

Example
html_escape("<a>")
Result
&lt;a&gt;
html_unescape(string: string): string function

Decodes named and numeric HTML entities in the given string into their corresponding characters.

Example
html_unescape("&lt;a&gt;")
Result
<a>
http(method: string, url: string, body: string, headers: dict): string functionrequires http

Performs an HTTPS request with the given method (a string or symbol, e.g. "post" or :post — get, post, put, delete, patch, head, ... are all supported) and returns the response body as a string. An optional body argument (string) sends a request body regardless of method, and an optional headers argument (a dict of string to string, e.g. {"Content-Type": "application/json"}) is applied to the request. Requires the --allow-net CLI flag; otherwise returns a runtime error. Only https:// URLs are allowed.

implode(array: array): string function

Joins an array of characters into a string.

Example
implode(explode("ab"))
Result
ab
index(value: dynamic, needle: dynamic): number function

Finds the first occurrence of a substring or byte subsequence. Returns -1 if not found.

Example
index("hello", "ll")
Result
2
infinite(): number function

Returns an infinite number value.

input(): string function

Reads a line from standard input and returns it as a string.

insert(target: dynamic, index_or_key: dynamic, value: dynamic): dynamic function

Inserts a value into an array or string at the specified index, or into a dict with the specified key.

Example
insert([1, 2, 3], 1, "x")
Result
[1, "x", 2, 3]
intern(string: string): string function

Interns the given string, returning a canonical reference for efficient comparison.

Example
intern("hi")
Result
hi
is_not_regex_match(string: string, pattern: string): bool function

Checks if the given pattern does not match the string.

Example
is_not_regex_match("abc", "x")
Result
true
is_regex_match(string: string, pattern: string): bool function

Checks if the given pattern matches the string.

Example
is_regex_match("abc", "a.c")
Result
true
join(array: array, separator: string): string function

Joins the elements of an array into a string with the given separator.

Example
join([1, 2, 3], ",")
Result
1,2,3
keys(dict: dict): array function

Returns an array of keys from the dict.

len(value: dynamic): number function

Returns the length of the given string or array.

Example
len("hello")
Result
5
ln(number: number): number function

Returns the natural logarithm (base e) of the given number.

Example
ln(1)
Result
0
localtime(timestamp: number): array function

Converts Unix timestamp (seconds since epoch) to broken-down local time array [year, mon (0-11), mday, hour, min, sec, wday (0=Sun), yday (0-365)].

log10(number: number): number function

Returns the base-10 logarithm of the given number.

Example
log10(100)
Result
2
lt(value1: dynamic, value2: dynamic): bool function

Checks if the first value is less than the second value.

Example
lt(1, 2)
Result
true
lte(value1: dynamic, value2: dynamic): bool function

Checks if the first value is less than or equal to the second value.

Example
lte(1, 1)
Result
true
ltrim(input: string): string function

Trims whitespace from the left end of the given string.

Example
ltrim("  hi  ")
Result
hi  
max(value1: dynamic, value2: dynamic): dynamic function

Returns the maximum of two values.

Example
max(1, 2)
Result
2
md5(input: dynamic): string function

Computes the MD5 hash of a string or bytes and returns a lowercase hex string.

min(value1: dynamic, value2: dynamic): dynamic function

Returns the minimum of two values.

Example
min(1, 2)
Result
1
mktime(time_array: array): number function

Converts broken-down UTC time array [year, mon (0-11), mday, hour, min, sec, wday, yday] to Unix timestamp (seconds since epoch).

Example
mktime(gmtime(0))
Result
0
mod(value1: dynamic, value2: dynamic): dynamic function

Calculates the remainder of the division of the first value by the second value.

Example
mod(7, 3)
Result
1
mul(value1: dynamic, value2: dynamic): dynamic function

Multiplies two values.

Example
mul(2, 3)
Result
6
nan(): number function

Returns a Not-a-Number (NaN) value.

ne(value1: dynamic, value2: dynamic): bool function

Checks if two values are not equal.

Example
ne(1, 2)
Result
true
negate(number: number): number function

Returns the negation of the given number.

Example
negate(5)
Result
-5
not(value: bool): bool function

Performs a logical NOT operation on a boolean value.

Example
not(true)
Result
false
now(): number function

Returns the current timestamp.

or(value1: bool, value2: bool): bool function

Performs a logical OR operation on two boolean values.

Example
or(true, false)
Result
true
pack(format: string, value: number): bytes function

Packs a number into bytes using the given format. Supported formats: u8, i8, u16be/le, i16be/le, u32be/le, i32be/le, u64be/le, i64be/le, f32be/le, f64be/le.

partial(function: function, arg1: dynamic, arg2: dynamic, ...: dynamic): function function

Creates a new function by partially applying the given arguments to the specified function.

path_join(base: string, component: string): string function

Joins a base path with a component path and returns the resulting path string (e.g. path_join("/a/b", "c.txt") → "/a/b/c.txt").

Example
path_join("/a/b", "c.txt")
Result
/a/b/c.txt
pow(base: number, exponent: number): number function

Raises the base to the power of the exponent.

Example
pow(2, 10)
Result
1024
print(message: string): dynamic function

Prints a message to standard output and returns the current value.

rand(): number function

Generates a pseudo-random number in the range [0, 1). Not cryptographically secure.

rand_int(min: number, max: number): number function

Generates a pseudo-random integer uniformly distributed in [min, max] (inclusive). Not cryptographically secure.

random_string(len: number, charset: string): string function

Generates a random string of `len` characters, each independently chosen (with replacement) from `charset`. Not cryptographically secure.

range(start: number, end: number, step: number): array function

Creates an array from start to end with an optional step.

Example
range(0, 5, 1)
Result
[0, 1, 2, 3, 4, 5]
read_file(path: string): string functionrequires file-io

Reads the contents of a file at the given path and returns it as a string. Requires the --allow-read CLI flag; otherwise returns a runtime error.

read_file_bytes(path: string): bytes functionrequires file-io

Reads the contents of a file at the given path and returns it as raw bytes. Requires the --allow-read CLI flag; otherwise returns a runtime error.

regex_match(string: string, pattern: string): array function

Finds all matches of the given pattern in the string.

Example
regex_match("abc123", "[0-9]+")
Result
["123"]
repeat(string: string, count: number): string function

Repeats the given string a specified number of times.

Example
repeat("ab", 3)
Result
ababab
replace(from: string, pattern: string, to: string): string function

Replaces all occurrences of a substring with another substring.

Example
replace("aXbXc", "X", "-")
Result
a-b-c
reverse(value: dynamic): dynamic function

Reverses the given string or array.

Example
reverse("abc")
Result
cba
rindex(value: dynamic, needle: dynamic): number function

Finds the last occurrence of a substring or byte subsequence. Returns -1 if not found.

Example
rindex("hello", "l")
Result
3
round(number: number): number function

Rounds the given number to the nearest integer.

Example
round(3.5)
Result
4
rtrim(input: string): string function

Trims whitespace from the right end of the given string.

Example
rtrim("  hi  ")
Result
  hi
sample(array: array, n: number): array function

Returns n elements sampled from the array without replacement, in random order. Errors if n exceeds the array length.

sanitize_html(html: string): string function

Sanitizes the given HTML string using an allowlist of safe tags and attributes, removing scripts and other XSS vectors.

scan(string: string, pattern: string): array function

Finds all matches of a regular expression pattern in the string. For each match, returns the captured groups as an array if the pattern has capture groups, otherwise returns the whole match as a string.

Example
scan("a1b2", "[0-9]")
Result
["1", "2"]
set(obj: dict, key: dynamic, value: dynamic): dict function

Sets a key-value pair in a dict. If the key exists, its value is updated. Returns the modified map.

set_attr(markdown: markdown, attribute: string, value: dynamic): markdown function

Sets the value of the specified attribute on a markdown node.

set_check(list: markdown, checked: bool): markdown function

Creates a markdown list node with the given checked state.

Example
set_check(to_md_list("Item", 0), true)
Result
- [x] Item
set_children(markdown: markdown, children: array): markdown function

Sets the children nodes of a markdown node. Nodes without children (e.g. text, code) are left unchanged.

set_code_block_lang(code_block: markdown, language: string): markdown function

Sets the language of a markdown code block node.

Example
set_code_block_lang(to_code("x", "python"), "rust")
Result
```rust
x
```
set_list_ordered(list: markdown, ordered: bool): markdown function

Sets the ordered property of a markdown list node.

Example
set_list_ordered(to_md_list("Item", 0), true)
Result
1. Item
set_ref(node: markdown, reference_id: string): markdown function

Sets the reference identifier for markdown nodes that support references (e.g., Definition, LinkRef, ImageRef, Footnote, FootnoteRef).

set_variable(symbol_or_string: dynamic, value: dynamic): dynamic function

Sets a symbol or variable in the current environment with the given value.

sha256(input: dynamic): string function

Computes the SHA-256 hash of a string or bytes and returns a lowercase hex string.

sha512(input: dynamic): string function

Computes the SHA-512 hash of a string or bytes and returns a lowercase hex string.

shift_left(value: dynamic, shift_amount: number): dynamic function

Performs a left shift operation on the given value: for numbers, this is a bitwise left shift by the specified number of positions; for strings, this removes characters from the start; for Markdown headings, this increases the heading level accordingly.

Example
shift_left(1, 2)
Result
4
shift_right(value: dynamic, shift_amount: number): dynamic function

Performs a bitwise right shift on numbers, slices characters from the end of strings, and adjusts Markdown heading levels when applied to headings, using the given shift amount.

Example
shift_right(8, 2)
Result
2
shuffle(array: array): array function

Returns a new array containing the same elements as the input, in a uniformly random order.

slice(string: string, start: number, end: number): string function

Extracts a substring from the given string.

Example
slice("hello", 1, 3)
Result
el
sort(array: array): array function

Sorts the elements of the given array.

Example
sort([3, 1, 2])
Result
[1, 2, 3]
split(string: string, separator: string): array function

Splits the given string by the specified separator.

Example
split("a,b,c", ",")
Result
["a", "b", "c"]
sqrt(number: number): number function

Returns the square root of the given number.

Example
sqrt(9)
Result
3
starts_with(value: dynamic, prefix: dynamic): bool function

Checks if the given string or byte array starts with the specified prefix.

Example
starts_with("hello", "he")
Result
true
stderr(message: string): dynamic function

Prints a message to standard error and returns the current value.

stem(path: string): string function

Returns the file name without the extension (e.g. "file" from "/a/b/file.txt").

Example
stem("/a/b/file.txt")
Result
file
strftime(timestamp: number, format: string): string function

Formats a Unix timestamp (seconds) as a date string using the given strftime format (e.g. "%Y-%m-%d").

Example
strftime(0, "%Y-%m-%d")
Result
1970-01-01
strip_tags(string: string): string function

Removes HTML tags from the given string, keeping the surrounding text content.

Example
strip_tags("<b>hi</b>")
Result
hi
strptime(date_str: string, format: string): number function

Parses a date string using the given strptime format (e.g. "%Y-%m-%d") and returns a Unix timestamp (seconds, UTC).

Example
strptime("1970-01-01", "%Y-%m-%d")
Result
0
sub(value1: dynamic, value2: dynamic): dynamic function

Subtracts the second value from the first value.

Example
sub(5, 2)
Result
3
to_array(value: dynamic): array function

Converts the given value to an array.

Example
to_array(1)
Result
[1]
to_blockquote(value: dynamic): markdown function

Creates a markdown blockquote node with the given value.

Example
to_blockquote("Quote")
Result
> Quote
to_boolean(value: dynamic): bool function

Converts the given value to a boolean. Booleans are returned unchanged, the strings "true" and "false" are converted to their boolean equivalent, and all other input results in an error.

Example
to_boolean("true")
Result
true
to_break(): markdown function

Creates a markdown hard line break node.

Example
to_break()
Result
\
to_bytes(value: dynamic): bytes function

Converts a string (UTF-8), array of numbers, or bytes to raw bytes.

to_callout(value: dynamic, kind: string, title: string): markdown function

Creates a markdown callout node with the given value, kind, and title.

Example
to_callout("Note text", "note", "")
Result
> [!NOTE]
> Note text
to_code(value: dynamic, language: string): markdown function

Creates a markdown code block with the given value and language.

Example
to_code("x = 1", "python")
Result
```python
x = 1
```
to_code_inline(value: dynamic): markdown function

Creates an inline markdown code node with the given value.

Example
to_code_inline("x")
Result
`x`
to_date(timestamp: number, format: string): string function

Converts a timestamp to a date string with the given format.

Example
to_date(0, "%Y-%m-%d")
Result
1970-01-01
to_definition(url: string, ident: string, title: string): markdown function

Creates a markdown link reference definition node with the given url, identifier, and title.

Example
to_definition("https://example.com", "ex", "")
Result
[ex]: https://example.com
to_delete(value: dynamic): markdown function

Creates a markdown delete (strikethrough) node with the given value.

Example
to_delete("Old")
Result
~~Old~~
to_em(value: dynamic): markdown function

Creates a markdown emphasis (italic) node with the given value.

Example
to_em("Italic")
Result
*Italic*
to_footnote(value: dynamic, ident: string): markdown function

Creates a markdown footnote definition node with the given value and identifier.

Example
to_footnote("Footnote text", "1")
Result
[^1]: Footnote text
to_footnote_ref(ident: string): markdown function

Creates a markdown footnote reference node with the given identifier.

Example
to_footnote_ref("1")
Result
[^1]
to_h(value: dynamic, depth: number): markdown function

Creates a markdown heading node with the given value and depth.

Example
to_h("Title", 1)
Result
# Title
to_hex(bytes: bytes): string function

Encodes raw bytes as a lowercase hex string.

Example
to_hex(from_hex("6869"))
Result
6869
to_hr(): markdown function

Creates a markdown horizontal rule node.

Example
to_hr()
Result
***
to_html(markdown: string): string function

Converts the given markdown string to HTML.

to_image(url: string, alt: string, title: string): markdown function

Creates a markdown image node with the given URL, alt text, and title.

Example
to_image("https://example.com/a.png", "Alt", "")
Result
![Alt](https://example.com/a.png "")
to_link(url: string, value: dynamic, title: string): markdown function

Creates a markdown link node with the given url and title.

Example
to_link("https://example.com", "Example", "")
Result
[Example](https://example.com)
to_markdown(markdown_string: string): array function

Parses a markdown string and returns an array of markdown nodes.

Example
to_markdown("# Hi")
Result
[# Hi]
to_markdown_string(value: dynamic): string function

Converts the given value(s) to a markdown string representation.

to_math(value: dynamic): markdown function

Creates a markdown math block with the given value.

Example
to_math("x^2")
Result
$$
x^2
$$
to_math_inline(value: dynamic): markdown function

Creates an inline markdown math node with the given value.

Example
to_math_inline("x^2")
Result
$x^2$
to_md_fragment(values: array): markdown function

Creates a markdown fragment node that groups an array of markdown nodes into a single value.

to_md_html(value: dynamic): markdown function

Creates a raw markdown HTML node with the given value.

Example
to_md_html("<br>")
Result
<br>
to_md_list(value: dynamic, indent: number): markdown function

Creates a markdown list node with the given value and indent level.

Example
to_md_list("Item", 0)
Result
- Item
to_md_name(markdown: markdown): string function

Returns the name of the given markdown node.

Example
to_md_name(to_h("t", 1))
Result
h1
to_md_table_align(aligns: array): markdown function

Creates a markdown table alignment row node from an array of alignments ("left", "right", "center", "none").

Example
to_md_table_align(["left", "right"])
Result
|:---|---:|
to_md_table_cell(value: dynamic, row: number, column: number): markdown function

Creates a markdown table cell node with the given value at the specified row and column.

Example
to_md_table_cell("A1", 0, 0)
Result
A1
to_md_table_row(cells: array): markdown function

Creates a markdown table row node with the given values.

to_md_text(value: dynamic): markdown function

Creates a markdown text node with the given value.

Example
to_md_text("hi")
Result
hi
to_mdx(mdx_string: string): array function

Parses an MDX string and returns an array of MDX nodes.

to_number(value: dynamic): number function

Converts the given value to a number.

Example
to_number("42")
Result
42
to_string(value: dynamic): string function

Converts the given value to a string.

Example
to_string(1)
Result
1
to_strong(value: dynamic): markdown function

Creates a markdown strong (bold) node with the given value.

Example
to_strong("Bold")
Result
**Bold**
to_text(markdown: markdown): string function

Converts the given markdown node to plain text.

Example
to_text(to_strong("hi"))
Result
hi
token_compress(nodes: array, budget: number, model?: string): array function

Reduces an array of Markdown nodes to fit within `budget` LLM tokens, preserving structure as much as possible: paragraphs are cut to their first sentence, then lists/tables/code blocks are collapsed to a summary, and only as a last resort is the remaining text hard-truncated. Uses a lightweight chars-per-token heuristic by default; built with the `tiktoken` Cargo feature, counts exactly via tiktoken-rs instead when `model` (e.g. "gpt-5") is given. `model` is optional; without it, the heuristic estimate is always used.

token_count(text: string, model?: string): number function

Estimates how many LLM tokens the given text would consume, for context-window budgeting. Uses a lightweight chars-per-token heuristic by default; built with the `tiktoken` Cargo feature, counts exactly via tiktoken-rs instead when `model` (e.g. "gpt-5") is given. `model` is optional; without it, the heuristic estimate is always used.

Example
token_count("Hello, world!")
Result
4
trim(input: string): string function

Trims whitespace from both ends of the given string.

Example
trim("  hi  ")
Result
hi
trunc(number: number): number function

Truncates the given number to an integer by removing the fractional part.

Example
trunc(3.9)
Result
3
truncate(string: string, width: number, ellipsis: string): string function

Truncates the given string to the specified display width, appending the ellipsis string when truncated (CJK and other wide characters count as two columns).

Example
truncate("hello world", 5, "...")
Result
he...
type(value: dynamic): string function

Returns the type of the given value.

Example
type(1)
Result
number
uniq(array: array): array function

Removes duplicate elements from the given array.

Example
uniq([1, 1, 2])
Result
[1, 2]
unpack(format: string, bytes: bytes): number function

Unpacks a number from bytes using the given format. Supported formats: u8, i8, u16be/le, i16be/le, u32be/le, i32be/le, u64be/le, i64be/le, f32be/le, f64be/le.

upcase(input: string): string function

Converts the given string to uppercase.

Example
upcase("abc")
Result
ABC
update(target_value: dynamic, source_value: dynamic): dynamic function

Update the value with specified value.

url_decode(input: string): string function

URL-decodes the given string.

Example
url_decode("a%20b")
Result
a b
url_encode(input: string): string function

URL-encodes the given string.

Example
url_encode("a b")
Result
a%20b
utf8(bytes: bytes): string function

Decodes bytes as a UTF-8 string, returning an error if the bytes are not valid UTF-8.

Example
utf8(to_bytes("hi"))
Result
hi
uuid(): string function

Generates a random (version 4, RFC 4122) UUID string.

uuid_v4(): string function

Generates a random (version 4, RFC 4122) UUID string. Alias of `uuid`.

uuid_v7(): string function

Generates a time-ordered (version 7, RFC 9562) UUID string: a millisecond Unix timestamp followed by random bits, so values sort by creation time. The timestamp is plaintext, so prefer uuid/uuid_v4 for unguessable IDs.

values(dict: dict): array function

Returns an array of values from the dict.

word_wrap(string: string, width: number): string function

Wraps the given string into lines no wider than the specified display width, breaking on word boundaries (CJK and other wide characters count as two columns).

Example
word_wrap("hello world", 5)
Result
hello
world
write_file(path: string, content: dynamic): dynamic functionrequires file-io

Writes content (string or bytes) to the file at the given path, creating or truncating it. Requires the --allow-write CLI flag; otherwise returns a runtime error.

xor(bytes1: bytes, bytes2: bytes): bytes function

Computes the bitwise XOR of two byte arrays of equal length.

halt_error(): dynamic function

Halts execution with error code 5

is_array(a: dynamic): bool function

Checks if input is an array

Example
is_array([1, 2])
Result
true
is_markdown(m: dynamic): bool function

Checks if input is markdown

Example
is_markdown(to_h("t", 1))
Result
true
is_bool(b: dynamic): bool function

Checks if input is a boolean

Example
is_bool(true)
Result
true
is_number(n: dynamic): bool function

Checks if input is a number

Example
is_number(1)
Result
true
is_string(s: dynamic): bool function

Checks if input is a string

Example
is_string("hi")
Result
true
is_none(n: dynamic): bool function

Checks if input is None

Example
is_none(None)
Result
true
is_dict(d: dynamic): bool function

Checks if input is a dictionary

Example
is_dict({"a": 1})
Result
true
is_bytes(b: dynamic): bool function

Checks if input is bytes

Example
is_bytes(to_bytes("hi"))
Result
true
contains(haystack: dynamic, needle: dynamic): bool function

Checks if string contains a substring

Example
contains("hello world", "world")
Result
true
ltrimstr(s: dynamic, left: dynamic): string function

Removes prefix string from input if it exists

Example
ltrimstr("prefix_value", "prefix_")
Result
value
rtrimstr(s: dynamic, right: dynamic): string function

Removes suffix string from input if it exists

Example
rtrimstr("value_suffix", "_suffix")
Result
value
is_empty(s: dynamic): bool function

Checks if string, array or dict is empty

Example
is_empty([])
Result
true
test(s: dynamic, pattern: dynamic): bool function

Tests if string matches a pattern

Example
test("abc", "a.c")
Result
true
select(v: dynamic, f: dynamic): dynamic function

Returns value if condition is true, None otherwise

Example
select(5, true)
Result
5
arrays(a: dynamic): dynamic function

Returns array if input is array, None otherwise

Example
arrays([1, 2])
Result
[1, 2]
markdowns(m: dynamic): dynamic function

Returns markdown if input is markdown, None otherwise

Example
markdowns(to_h("t", 1))
Result
# t
booleans(b: dynamic): dynamic function

Returns boolean if input is boolean, None otherwise

Example
booleans(true)
Result
true
numbers(n: dynamic): dynamic function

Returns number if input is number, None otherwise

Example
numbers(1)
Result
1
strings(s: dynamic): dynamic function

Returns string if input is string, None otherwise

Example
strings("hi")
Result
hi
dicts(d: dynamic): dynamic function

Returns dict if input is dict, None otherwise

Example
dicts({"a": 1})
Result
{"a": 1}
nones(n: dynamic): dynamic function

Returns the value if it is None, None otherwise

Example
nones(None)
Result
bytes(b: dynamic): dynamic function

Returns bytes if input is bytes, None otherwise

Example
bytes(to_bytes("hi"))
Result
6869
iterables(v: dynamic): dynamic function

Returns the value if it is an array or dict (i.e. a container that can be iterated over), None otherwise

Example
iterables([1, 2])
Result
[1, 2]
scalars(v: dynamic): dynamic function

Returns the value if it is not an array or dict (i.e. a leaf/scalar value), None otherwise

Example
scalars(1)
Result
1
to_date_iso8601(d: dynamic): string function

Formats a date to ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)

Example
to_date_iso8601(0)
Result
1970-01-01T00:00:00Z
map(v: dynamic, f: dynamic): array function

Applies a given function to each element of the provided array and returns a new array with the results.

Example
map([1, 2, 3], fn(x): mul(x, 2);)
Result
[2, 4, 6]
flat_map(v: dynamic, f: dynamic): array function

Applies a function to each element and flattens the result into a single array

Example
flat_map([1, 2], fn(x): [x, x];)
Result
[1, 1, 2, 2]
filter(v: dynamic, f: dynamic): array function

Filters the elements of an array based on a provided callback function.

Example
filter([1, 2, 3, 4], fn(x): x > 2;)
Result
[3, 4]
each(v: dynamic, f: dynamic): dynamic function

Executes a provided function once for each element in an array or each key-value pair in a dictionary.

first(arr: dynamic): dynamic function

Returns the first element of an array

Example
first([1, 2, 3])
Result
1
last(arr: dynamic): dynamic function

Returns the last element of an array

Example
last([1, 2, 3])
Result
3
second(arr: dynamic): dynamic function

Returns the second element of an array

Example
second([1, 2, 3])
Result
2
is_h1(md: dynamic): bool function

Checks if markdown is h1 heading

Example
is_h1(to_h("t", 1))
Result
true
is_h2(md: dynamic): bool function

Checks if markdown is h2 heading

Example
is_h2(to_h("t", 2))
Result
true
is_h3(md: dynamic): bool function

Checks if markdown is h3 heading

Example
is_h3(to_h("t", 3))
Result
true
is_h4(md: dynamic): bool function

Checks if markdown is h4 heading

Example
is_h4(to_h("t", 4))
Result
true
is_h5(md: dynamic): bool function

Checks if markdown is h5 heading

Example
is_h5(to_h("t", 5))
Result
true
is_h6(md: dynamic): bool function

Checks if markdown is h6 heading

Example
is_h6(to_h("t", 6))
Result
true
is_h(md: dynamic): bool function

Checks if markdown is heading

Example
is_h(to_h("t", 2))
Result
true
is_h_level(md: dynamic, level: dynamic): bool function

Checks if markdown is a heading of the specified level (1-6)

Example
is_h_level(to_h("t", 2), 2)
Result
true
is_table_align(md: dynamic): bool function

Checks if markdown is table align

Example
is_table_align(to_md_table_align(["left"]))
Result
true
is_table_cell(md: dynamic): bool function

Checks if markdown is table cell

Example
is_table_cell(to_md_table_cell("A1", 0, 0))
Result
true
is_em(md: dynamic): bool function

Checks if markdown is emphasis

Example
is_em(to_em("hi"))
Result
true
is_html(md: dynamic): bool function

Checks if markdown is html

is_yaml(md: dynamic): bool function

Checks if markdown is yaml

is_toml(md: dynamic): bool function

Checks if markdown is toml

is_code(md: dynamic): bool function

Checks if markdown is code block

Example
is_code(to_code("x", "python"))
Result
true
is_text(text: dynamic): bool function

Checks if markdown is text

Example
is_text(to_md_text("hi"))
Result
true
is_list(list: dynamic): bool function

Checks if markdown is list

Example
is_list(to_md_list("Item", 0))
Result
true
matches_url(node: dynamic, url: dynamic): bool functionDeprecated

Checks if markdown node's URL matches a specified URL deprecated: use select(.link.url == url) instead

Example
matches_url(to_link("https://example.com", "x", ""), "https://example.com")
Result
true
is_mdx_flow_expression(mdx: dynamic): bool function

Checks if markdown is MDX Flow Expression

is_mdx_jsx_flow_element(mdx: dynamic): bool function

Checks if markdown is MDX Jsx Flow Element

is_mdx_jsx_text_element(mdx: dynamic): bool function

Checks if markdown is MDX Jsx Text Element

is_mdx_text_expression(mdx: dynamic): bool function

Checks if markdown is MDX Text Expression

is_mdx_js_esm(mdx: dynamic): bool function

Checks if markdown is MDX Js Esm

is_mdx(mdx: dynamic): bool function

Checks if markdown is MDX

is_callout(md: dynamic): bool function

Checks if markdown is a callout block

Example
is_callout(to_callout("Note", "note", ""))
Result
true
fill(value: dynamic, n: dynamic): array function

Returns an array of length n filled with the given value.

Example
fill("x", 3)
Result
["x", "x", "x"]
sort_by(arr: dynamic, f: dynamic): array function

Sorts an array using a key function that extracts a comparable value for each element.

Example
sort_by([3, 1, 2], identity)
Result
[1, 2, 3]
sort_natural(arr: dynamic): array function

Sorts an array in natural order (numeric-aware), so runs of digits embedded in a string are compared as numbers rather than character-by-character, e.g. "file2" sorts before "file10" (unlike a plain lexicographic `sort`).

Example
sort_natural(["file10", "file2"])
Result
["file2", "file10"]
count_by(arr: dynamic, f: dynamic): number function

Returns the count of elements in the array that satisfy the provided function.

Example
count_by([1, 2, 3, 4], fn(x): x > 2;)
Result
2
skip(arr: dynamic, n: dynamic): array function

Skips the first n elements of an array and returns the rest

Example
skip([1, 2, 3, 4], 2)
Result
[3, 4]
take(arr: dynamic, n: dynamic): array function

Takes the first n elements of an array

Example
take([1, 2, 3, 4], 2)
Result
[1, 2]
find_index(arr: dynamic, f: dynamic): number function

Returns the index of the first element in an array that satisfies the provided function.

Example
find_index([1, 2, 3], fn(x): x == 2;)
Result
1
skip_while(arr: dynamic, f: dynamic): array function

Skips elements from the beginning of an array while the provided function returns true

Example
skip_while([1, 2, 3, 4], fn(x): x < 3;)
Result
[3, 4]
take_while(arr: dynamic, f: dynamic): array function

Takes elements from the beginning of an array while the provided function returns true

Example
take_while([1, 2, 3, 4], fn(x): x < 3;)
Result
[1, 2]
group_by(arr: dynamic, f: dynamic): dict function

Groups elements of an array by the result of applying a function to each element

Example
group_by([1, 2, 3, 4], fn(x): mod(x, 2);)
Result
{"1": [1, 3], "0": [2, 4]}
frequencies_by(arr: dynamic, f: dynamic): dict function

Counts occurrences of each key extracted from the elements of an array, returning a dict of `{key: count}`.

Example
frequencies_by(["a", "b", "a"], identity)
Result
{"a": 2, "b": 1}
tally(arr: dynamic): dict function

Counts occurrences of each element in an array, returning a dict of `{value: count}`.

Example
tally(["a", "b", "a"])
Result
{"a": 2, "b": 1}
any(v: dynamic, f: dynamic): bool function

Returns true if any element in the array satisfies the provided function.

Example
any([1, 2, 3], fn(x): x > 2;)
Result
true
all(v: dynamic, f: dynamic): bool function

Returns true if all element in the array satisfies the provided function.

Example
all([1, 2, 3], fn(x): x > 0;)
Result
true
in(v: dynamic, elem: dynamic): bool function

Returns true if the element is in the array.

Example
in([1, 2, 3], 2)
Result
true
fold(arr: dynamic, init: dynamic, f: dynamic): dynamic function

Reduces an array to a single value by applying a function, starting from an initial value.

Example
fold([1, 2, 3], 0, fn(acc, x): acc + x;)
Result
6
unique_by(arr: dynamic, f: dynamic): array function

Returns a new array with duplicate elements removed, comparing by the result of the provided function.

Example
unique_by([1, 2, 1, 3], identity)
Result
[1, 2, 3]
identity(x: dynamic): dynamic function

Returns the input value unchanged.

Example
identity(1)
Result
1
transpose(matrix: dynamic): array function

Transposes a 2D array (matrix), swapping rows and columns.

Example
transpose([[1, 2], [3, 4]])
Result
[[1, 3], [2, 4]]
tap(value: dynamic, expr: dynamic): dynamic function

Applies a function to a value and returns the value (useful for debugging or side effects).

Example
tap(1, 2)
Result
1
pluck(pluck_obj: dynamic, selector: dynamic): dynamic function

Extracts values from an array of objects based on a specified selector.

compact_map(arr: dynamic, f: dynamic): array function

Maps over an array and removes None values from the result.

Example
compact_map([1, 2, 3], fn(x): if (x > 1): x;)
Result
[2, 3]
reject(arr: dynamic, f: dynamic): array function

Filters out elements that match the condition (opposite of filter).

Example
reject([1, 2, 3, 4], fn(x): x > 2;)
Result
[1, 2]
partition(arr: dynamic, f: dynamic): array function

Splits an array into two arrays: [matching, not_matching] based on a condition.

Example
partition([1, 2, 3, 4], fn(x): x > 2;)
Result
[[3, 4], [1, 2]]
get_or(dict: dynamic, key: dynamic, default: dynamic): dynamic function

Safely gets a value from a dict with a default if the key doesn't exist.

Example
get_or({"a": 1}, "b", 0)
Result
0
times(n: dynamic, value: dynamic): array functionDeprecated

Executes an expression n times and returns an array of results. Note: `value` is evaluated once (eagerly) and repeated, not re-evaluated per iteration. Deprecated: use `repeat` instead

Example
times(3, 1)
Result
[1, 1, 1]
between(value: dynamic, min: dynamic, max: dynamic): bool function

Checks if a value is between min and max (inclusive).

Example
between(5, 1, 10)
Result
true
sum_by(arr: dynamic, f: dynamic): number function

Sums elements of an array after applying a transformation function.

Example
sum_by([1, 2, 3], fn(x): mul(x, 2);)
Result
12
index_by(arr: dynamic, f: dynamic): dict function

Creates a dictionary indexed by a key extracted from each element.

Example
index_by([1, 2, 3], to_string)
Result
{"1": 1, "2": 2, "3": 3}
join_by(left: dynamic, right: dynamic, left_key: dynamic, right_key: dynamic, kind: dynamic): array function

Joins two arrays of dict records on `left_key`/`right_key`, similar to a SQL join. Matching records are merged with `+` (right's fields win on collision). `kind` is one of "inner" (default), "left", "right", or "full"; unmatched records in outer joins are filled with `None` for the other side's fields (inferred from that side's full key set). Records with a missing or `None` join key never match, and duplicate keys on either side expand as a cross product.

Example
join_by([{"id": 2, "name": "bob"}], [{"uid": 2, "age": 30}], "id", "uid")
Result
[{"id": 2, "name": "bob", "uid": 2, "age": 30}]
inspect(value: dynamic): dynamic function

Inspects a value by printing its string representation and returning the value.

lpad(s: dynamic, length: dynamic, pad_str: dynamic): string function

Left-pads a string to a specified length using a given padding string.

Example
lpad("7", 3, "0")
Result
007
rpad(s: dynamic, length: dynamic, pad_str: dynamic): string function

Right-pads a string to a specified length using a given padding string.

Example
rpad("7", 3, "0")
Result
700
load_markdown(path: dynamic): array function

Loads a markdown file from the specified path

http_get(url: dynamic, headers: dynamic): string function

Performs an HTTPS GET request, optionally with the given headers (a dict of string to string), and returns the response body as a string

http_post(url: dynamic, body: dynamic, headers: dynamic): string function

Performs an HTTPS POST request with the given body, optionally with the given headers (a dict of string to string), and returns the response body as a string

http_put(url: dynamic, body: dynamic, headers: dynamic): string function

Performs an HTTPS PUT request with the given body, optionally with the given headers (a dict of string to string), and returns the response body as a string

http_patch(url: dynamic, body: dynamic, headers: dynamic): string function

Performs an HTTPS PATCH request with the given body, optionally with the given headers (a dict of string to string), and returns the response body as a string

http_delete(url: dynamic, headers: dynamic): string function

Performs an HTTPS DELETE request, optionally with the given headers (a dict of string to string), and returns the response body as a string

http_head(url: dynamic, headers: dynamic): string function

Performs an HTTPS HEAD request, optionally with the given headers (a dict of string to string), and returns the response body as a string

http_get_json(url: dynamic, headers: dynamic): dynamic function

Performs an HTTPS GET request, optionally with the given headers (a dict of string to string), and parses the response body as JSON, returning the resulting data structure

http_post_json(url: dynamic, body: dynamic, headers: dynamic): dynamic function

Performs an HTTPS POST request with the given body, optionally with the given headers (a dict of string to string), and parses the response body as JSON, returning the resulting data structure

http_put_json(url: dynamic, body: dynamic, headers: dynamic): dynamic function

Performs an HTTPS PUT request with the given body, optionally with the given headers (a dict of string to string), and parses the response body as JSON, returning the resulting data structure

http_patch_json(url: dynamic, body: dynamic, headers: dynamic): dynamic function

Performs an HTTPS PATCH request with the given body, optionally with the given headers (a dict of string to string), and parses the response body as JSON, returning the resulting data structure

http_delete_json(url: dynamic, headers: dynamic): dynamic function

Performs an HTTPS DELETE request, optionally with the given headers (a dict of string to string), and parses the response body as JSON, returning the resulting data structure

debug(args: dynamic): dynamic function

Prints the debug information of the given value(s).

increase_header_depth(node: dynamic): markdown function

Increases the depth (numeric level) of a markdown heading node by one, effectively demoting the heading (e.g. h1 -> h2), up to a maximum of 6.

Example
increase_header_depth(to_h("t", 1))
Result
## t
decrease_header_depth(node: dynamic): markdown function

Decreases the depth (numeric level) of a markdown heading node by one, effectively promoting the heading (e.g. h2 -> h1), down to a minimum of 1.

Example
decrease_header_depth(to_h("t", 2))
Result
# t
demote_heading(node: dynamic): markdown function

Demotes a markdown heading by increasing its depth (numeric level) by one. This is an alias for `increase_header_depth`.

Example
demote_heading(to_h("t", 1))
Result
## t
promote_heading(node: dynamic): markdown function

Promotes a markdown heading by decreasing its depth (numeric level) by one. This is an alias for `decrease_header_depth`.

Example
promote_heading(to_h("t", 2))
Result
# t
increase_header_level(node: dynamic): markdown functionDeprecated

Deprecated: use `increase_header_depth` or `demote_heading` instead. Kept for backward compatibility; behavior unchanged.

Example
increase_header_level(to_h("t", 1))
Result
## t
decrease_header_level(node: dynamic): markdown functionDeprecated

Deprecated: use `decrease_header_depth` or `promote_heading` instead. Kept for backward compatibility; behavior unchanged.

Example
decrease_header_level(to_h("t", 2))
Result
# t
bsearch(arr: dynamic, target: dynamic): number function

Performs a binary search on a sorted array to find the index of the target value.

Example
bsearch([1, 3, 5, 7, 9], 5)
Result
2
slugify(s: dynamic, separator: dynamic): string function

Converts a string into a URL-friendly slug by lowercasing, replacing non-alphanumeric characters with hyphens, and trimming hyphens from the ends.

Example
slugify("Hello, World!")
Result
hello-world
percentile(arr: dynamic, p: dynamic): number function

Calculates the p-th percentile of an array of numbers using linear interpolation between closest ranks.

Example
percentile([1, 2, 3, 4, 5], 0.5)
Result
3
chunks(v: dynamic, size: dynamic): array function

Splits an array into chunks of a specified size, returning an array of arrays.

Example
chunks([1, 2, 3, 4, 5], 2)
Result
[[1, 2], [3, 4], [5]]
chunk_by(v: dynamic, f: dynamic): array function

Splits an array into chunks based on the result of applying a function to each element, grouping consecutive elements with the same key together.

Example
chunk_by([1, 1, 2, 2, 3], identity)
Result
[[1, 1], [2, 2], [3]]
flip(f: dynamic, a: dynamic, b: dynamic): dynamic function

Returns a new function that takes the same arguments as the original function but with the first two arguments flipped.

Example
flip(sub, 2, 10)
Result
8
complement(f: dynamic): bool function

Returns a new predicate function that negates the result of the given function.

Example
let f = complement(is_none) | f(1)
Result
true
comp(fns: dynamic): dynamic function

Composes functions into one function, applying them right-to-left. `comp(f, g, h)(x)` is equivalent to `f(g(h(x)))`.

Example
let f = comp(fn(x): x + 1;, fn(x): x * 2;) | f(3)
Result
7
juxt(fns: dynamic): array function

Returns a function that applies each given function to its argument and collects the results into an array. `juxt(f, g, h)(x)` is equivalent to `[f(x), g(x), h(x)]`.

Example
let f = juxt(first, last) | f([1, 2, 3])
Result
[1, 3]
sum(arr: dynamic): number function

Returns the sum of the elements in an array after applying a transformation function to each element.

Example
sum([1, 2, 3])
Result
6
mean(arr: dynamic): number function

Returns the average (mean) of an array of numbers, or None if the array is empty.

Example
mean([1, 2, 3])
Result
2
geomean(arr: dynamic): number function

Returns the geometric mean of an array of numbers, or None if the array is empty.

Example
geomean([1, 4])
Result
2
variance(arr: dynamic): number function

Returns the population variance of an array of numbers, or None if the array is empty.

Example
variance([2, 4, 4, 4, 5, 5, 7, 9])
Result
4
stddev(arr: dynamic): number function

Returns the population standard deviation of an array of numbers, or None if the array is empty.

Example
stddev([2, 4, 4, 4, 5, 5, 7, 9])
Result
2
mode(arr: dynamic): array function

Returns the mode(s) of an array, i.e. the most frequently occurring value(s). Multiple values are returned if there is a tie for the highest frequency. Returns None if the array is empty.

Example
mode([1, 2, 2, 3])
Result
[2]
describe(arr: dynamic): dict function

Returns a dict of summary statistics for an array of numbers: `{min, max, mean, median, stddev, variance, count}`. Returns None if the array is empty.

Example
describe([1, 2, 3, 4, 5])
Result
{"count": 5, "min": 1, "max": 5, "mean": 3, "variance": 2, "stddev": 1.414214, "median": 3}
ngram(s: dynamic, n: dynamic): array function

Returns the n-grams of an array or string, which are overlapping contiguous subarrays (or substrings) of length n, sliding one element at a time.

Example
ngram("abcd", 2)
Result
["ab", "bc", "cd"]
zip(arr1: dynamic, arr2: dynamic): array function

Combines two arrays into an array of pairs, where each pair contains elements from the same index in both arrays.

Example
zip([1, 2], ["a", "b"])
Result
[[1, "a"], [2, "b"]]
min_by(arr: dynamic, f: dynamic): dynamic function

Returns the minimum element in an array based on a provided function that extracts a comparable value from each element.

Example
min_by([3, 1, 2], identity)
Result
1
max_by(arr: dynamic, f: dynamic): dynamic function

Returns the maximum element in an array based on a provided function that extracts a comparable value from each element.

Example
max_by([3, 1, 2], identity)
Result
3
lines(s: dynamic): array function

Returns the lines of a string as an array by splitting on newline characters.

Example
lines("a\nb\nc")
Result
["a", "b", "c"]
unlines(arr: dynamic): string function

Joins an array of strings into a single string with newline characters between them.

Example
unlines(["a", "b", "c"]) == "a\nb\nc"
Result
true
pick(d: dynamic, keys: dynamic): dict function

Returns a new dictionary containing only the specified keys from the original dictionary, if they exist.

Example
pick({"a": 1, "b": 2}, ["a"])
Result
{"a": 1}
omit(d: dynamic, keys: dynamic): dict function

Returns a new dictionary excluding the specified keys from the original dictionary.

Example
omit({"a": 1, "b": 2}, ["a"])
Result
{"b": 2}
has(v: dynamic, key: dynamic): bool function

Checks if a dict has the given key, or an array has an element at the given index.

Example
has({"a": 1}, "a")
Result
true
get_path(value: dynamic, path: dynamic): dynamic function

Retrieves a nested value by following an array of keys/indices, e.g. `get_path(d, ["a", "b", 0])`. Returns None as soon as any intermediate step is missing.

Example
get_path({"a": {"b": 1}}, ["a", "b"])
Result
1
set_path(value: dynamic, path: dynamic, new_value: dynamic): dynamic function

Sets a nested value by following an array of keys/indices, e.g. `set_path(d, ["a", "b", 0], 1)`. Missing intermediate dicts/arrays are created automatically, choosing an array when the corresponding path element is a number and a dict otherwise.

Example
set_path({"a": {"b": 1}}, ["a", "b"], 2)
Result
{"a": {"b": 2}}
del_path(value: dynamic, path: dynamic): dynamic function

Deletes the value at a nested path, following an array of keys/indices, e.g. `del_path(d, ["a", "b", 0])`. An empty path deletes the whole value, mirroring jq's `delpaths([[]])`. A path through a missing intermediate container, or ending in a missing key/out-of-range index, leaves `value` unchanged.

Example
del_path({"a": {"b": 1, "c": 2}}, ["a", "b"])
Result
{"a": {"c": 2}}
del_paths(value: dynamic, paths: dynamic): dynamic function

Deletes the values at multiple nested paths, e.g. `del_paths(d, [["a"], ["b", 0]])`. Paths are applied deepest-first (via `sort`/`reverse`) so that deleting one array element doesn't shift the indices used by the remaining paths, mirroring jq's `delpaths`.

Example
del_paths({"a": 1, "b": 2, "c": 3}, [["a"], ["c"]])
Result
{"b": 2}
paths(value: dynamic): array function

Returns an array of leaf-path arrays for a value, e.g. `paths({"a": {"b": 1}})` returns `[["a", "b"]]`. Each returned path can be passed to `get_path`/`set_path`. Containers with no leaves (e.g. `{}`, `[]`) contribute no paths.

Example
paths({"a": {"b": 1}})
Result
[["a", "b"]]
from_entries(arr: dynamic): dict function

Builds a dict from an array of [key, value] pairs, as produced by `entries`. If the same key appears more than once, the last occurrence wins.

Example
from_entries([["a", 1], ["b", 2]])
Result
{"a": 1, "b": 2}
with_entries(d: dynamic, f: dynamic): dict function

Transforms each [key, value] pair of a dict by applying the given function, then rebuilds a dict from the resulting pairs.

Example
with_entries({"a": 1}, fn(e): [e[0], e[1] + 1];)
Result
{"a": 2}
merge_with(a: dynamic, b: dynamic, policy: dynamic): dynamic function

Deep merges two values, recursing into dicts key by key. Neither input is mutated. When both sides provide a leaf/array value for the same key, the conflict is resolved according to `policy`, one of: - `"replace"`: the second value (`b`) wins. - `"append"`: arrays are concatenated; other conflicting values are collected into `[a, b]`. - `"error"`: raises an error describing the conflict.

Example
merge_with({"a": 1, "b": {"x": 1}}, {"b": {"y": 2}, "c": 3}, "replace")
Result
{"a": 1, "b": {"x": 1, "y": 2}, "c": 3}
merge_defaults(d: dynamic, defaults: dynamic): dynamic function

Deep merges `d` over `defaults`, similar to Jsonnet's object inheritance: values present in `d` win (recursively for nested dicts), while keys missing from `d` fall back to the corresponding value in `defaults`. Arrays and scalar conflicts are resolved by letting `d` replace `defaults`. Neither input is mutated.

Example
merge_defaults({"a": {"x": 1}}, {"a": {"x": 0, "y": 2}, "b": 3})
Result
{"a": {"x": 1, "y": 2}, "b": 3}
frontmatter(v: dynamic): dynamic function

Parses frontmatter from a markdown node, supporting both YAML and TOML formats.

walk(v: dynamic, f: dynamic): dynamic function

Walks through a value (which can be a markdown node, array, or dict) and applies a function to each element, returning a new structure with the results.

Example
walk([1, [2, 3]], fn(x): if (is_number(x)): x * 2 else: x;)
Result
[2, [4, 6]]
human_bytes(n: dynamic): string function

Formats a byte count as a human-readable decimal (SI, 1000-based) string, e.g. `human_bytes(1500)` => "1.5KB". Negative numbers keep their sign.

Example
human_bytes(1500)
Result
1.5KB
human_size(n: dynamic): string function

Formats a byte count as a human-readable binary (IEC, 1024-based) string without the "i" suffix, matching `numfmt --to=iec`, e.g. `human_size(1536)` => "1.5K". Negative numbers keep their sign.

Example
human_size(1536)
Result
1.5K

CBOR Implementation in mq.

2 functions

cbor_parse(input: dynamic): dynamic function

Parses a base64-encoded CBOR string (or raw bytes) and returns the corresponding data structure.

Module: import "cbor" | cbor::cbor_parse(...)

Example
import "cbor" | cbor::cbor_parse(cbor::cbor_stringify({"a": 1}))
Result
{"a": 1}
cbor_stringify(data: dynamic): bytes function

Serializes a value to CBOR bytes.

Module: import "cbor" | cbor::cbor_stringify(...)

Example
import "cbor" | cbor::cbor_stringify(1)
Result
f93c00

CSV/TSV Implementation in mq. Based on RFC 4180 for CSV format.

8 functions

csv_needs_quote(field: dynamic, delimiter: dynamic): bool function

Checks whether a field's string form needs quoting for the given delimiter (RFC 4180): it contains a quote, newline, carriage return, the delimiter itself, or leading/trailing whitespace.

Module: import "csv" | csv::csv_needs_quote(...)

Example
import "csv" | csv::csv_needs_quote("a,b", ",")
Result
true
csv_parse_with_delimiter(input: dynamic, delimiter: dynamic, has_header: dynamic): array function

Parses CSV content with a specified delimiter and optional header row.

Module: import "csv" | csv::csv_parse_with_delimiter(...)

Example
import "csv" | csv::csv_parse_with_delimiter("a;b\n1;2", ";", true)
Result
[{"a": "1", "b": "2"}]
csv_parse(input: dynamic, has_header: dynamic): array function

Parses CSV content using a comma as the delimiter.

Module: import "csv" | csv::csv_parse(...)

Example
import "csv" | csv::csv_parse("name,age\nAlice,30", true)
Result
[{"name": "Alice", "age": "30"}]
tsv_parse(input: dynamic, has_header: dynamic): array function

Parses TSV (Tab-Separated Values) content.

Module: import "csv" | csv::tsv_parse(...)

Example
import "csv" | csv::tsv_parse("name\tage\nAlice\t30", true)
Result
[{"name": "Alice", "age": "30"}]
psv_parse(input: dynamic, has_header: dynamic): array function

Parses PSV (Pipe-Separated Values) content.

Module: import "csv" | csv::psv_parse(...)

Example
import "csv" | csv::psv_parse("name|age\nAlice|30", true)
Result
[{"name": "Alice", "age": "30"}]
csv_stringify(data: dynamic, delimiter: dynamic): string function

Converts data to a CSV string with a specified delimiter.

Module: import "csv" | csv::csv_stringify(...)

Example
import "csv" | csv::csv_stringify([{"name": "Alice", "age": 30}], ",")
Result
name,age
Alice,30
csv_to_markdown_table(data: dynamic): string function

Converts CSV data to a Markdown table format.

Module: import "csv" | csv::csv_to_markdown_table(...)

Example
import "csv" | csv::csv_to_markdown_table([{"name": "Alice", "age": 30}])
Result
| name | age |
| --- | --- |
| Alice | 30 |
csv_to_json(data: dynamic): string function

Converts CSV data to a JSON string.

Module: import "csv" | csv::csv_to_json(...)

Example
import "csv" | csv::csv_to_json([{"name": "Alice", "age": 30}])
Result
[{"name":"Alice","age":30}]

Fuzzy Match Implementation in mq Distance calculations (Levenshtein, Jaro, Jaro-Winkler) are implemented natively in Rust for performance; this module wraps them with matching, filtering, and sorting utilities.

8 functions

levenshtein(s1: dynamic, s2: dynamic): number function

Calculates the Levenshtein distance between two strings.

Module: import "fuzzy" | fuzzy::levenshtein(...)

Example
import "fuzzy" | fuzzy::levenshtein("kitten", "sitting")
Result
3
jaro(s1: dynamic, s2: dynamic): number function

Calculates the Jaro distance between two strings (0.0 to 1.0, where 1.0 is exact match).

Module: import "fuzzy" | fuzzy::jaro(...)

Example
import "fuzzy" | fuzzy::jaro("martha", "marhta")
Result
0.944444
jaro_winkler(s1: dynamic, s2: dynamic): number function

Calculates the Jaro-Winkler distance between two strings.

Module: import "fuzzy" | fuzzy::jaro_winkler(...)

Example
import "fuzzy" | fuzzy::jaro_winkler("martha", "marhta")
Result
0.961111
fuzzy_match(candidates: dynamic, query: dynamic): array function

Performs fuzzy matching on an array of strings using Jaro-Winkler distance.

Module: import "fuzzy" | fuzzy::fuzzy_match(...)

Example
import "fuzzy" | fuzzy::fuzzy_match(["apple", "aple", "banana"], "aple")
Result
[{"text": "aple", "score": 1}, {"text": "apple", "score": 0.946667}, {"text": "banana", "score": 0.472222}]
fuzzy_match_levenshtein(candidates: dynamic, query: dynamic): array function

Performs fuzzy matching using Levenshtein distance.

Module: import "fuzzy" | fuzzy::fuzzy_match_levenshtein(...)

Example
import "fuzzy" | fuzzy::fuzzy_match_levenshtein(["apple", "aple", "banana"], "aple")
Result
[{"text": "aple", "score": 0}, {"text": "apple", "score": 1}, {"text": "banana", "score": 5}]
fuzzy_match_jaro(candidates: dynamic, query: dynamic): array function

Performs fuzzy matching using Jaro distance.

Module: import "fuzzy" | fuzzy::fuzzy_match_jaro(...)

Example
import "fuzzy" | fuzzy::fuzzy_match_jaro(["apple", "aple", "banana"], "aple")
Result
[{"text": "aple", "score": 1}, {"text": "apple", "score": 0.933333}, {"text": "banana", "score": 0.472222}]
fuzzy_filter(candidates: dynamic, query: dynamic, threshold: dynamic): array function

Filters candidates by minimum fuzzy match score using Jaro-Winkler.

Module: import "fuzzy" | fuzzy::fuzzy_filter(...)

Example
import "fuzzy" | fuzzy::fuzzy_filter(["apple", "aple", "banana"], "aple", 0.8)
Result
[{"text": "aple", "score": 1}, {"text": "apple", "score": 0.946667}]
fuzzy_best_match(candidates: dynamic, query: dynamic): dict function

Finds the best fuzzy match from candidates.

Module: import "fuzzy" | fuzzy::fuzzy_best_match(...)

Example
import "fuzzy" | fuzzy::fuzzy_best_match(["apple", "aple", "banana"], "aple")
Result
{"text": "aple", "score": 1}

gron Implementation in mq.

1 functions

gron_parse(input: dynamic): dynamic function

Parses gron-style `path = value;` assignment statements (as produced by `mq -F gron`) and returns the corresponding data structure.

Module: import "gron" | gron::gron_parse(...)

Example
import "gron" | gron::gron_parse("json.a = 1;\njson.b = 2;")
Result
{"a": 1, "b": 2}

JSON Implementation in mq

3 functions

json_parse(input: dynamic): dynamic function

Parses a JSON string and returns the corresponding data structure.

Module: import "json" | json::json_parse(...)

Example
import "json" | json::json_parse("{\"a\": 1}")
Result
{"a": 1}
json_stringify(data: dynamic): string function

Serializes a value to a JSON string.

Module: import "json" | json::json_stringify(...)

Example
import "json" | json::json_stringify({"a": 1})
Result
{"a": 1}
json_to_markdown_table(data: dynamic): string function

Converts a JSON data structure to a Markdown table.

Module: import "json" | json::json_to_markdown_table(...)

Example
import "json" | json::json_to_markdown_table([{"a": 1, "b": 2}])
Result
| a | b |
| --- | --- |
| 1 | 2 |

Builder functions for constructing markdown nodes from scratch. This module is under development. APIs and behavior may change without notice.

26 functions

h(value: dynamic, depth: dynamic): markdown function

Wraps `value` in a heading node at the given `depth` (1-6).

Module: import "md" | md::h(...)

Example
import "md" | md::h("Title", 1)
Result
# Title
code(value: dynamic, lang: dynamic): markdown function

Wraps `value` in a fenced code block with the given `lang`.

Module: import "md" | md::code(...)

code_inline(value: dynamic): markdown function

Wraps `value` in an inline code span.

Module: import "md" | md::code_inline(...)

Example
import "md" | md::code_inline("x")
Result
`x`
text(value: dynamic): markdown function

Creates a plain text node from `value`.

Module: import "md" | md::text(...)

Example
import "md" | md::text("hi")
Result
hi
strong(value: dynamic): markdown function

Wraps `value` in a strong (bold) node.

Module: import "md" | md::strong(...)

Example
import "md" | md::strong("Bold")
Result
**Bold**
em(value: dynamic): markdown function

Wraps `value` in an emphasis (italic) node.

Module: import "md" | md::em(...)

Example
import "md" | md::em("Italic")
Result
*Italic*
delete(value: dynamic): markdown function

Wraps `value` in a delete (strikethrough) node.

Module: import "md" | md::delete(...)

Example
import "md" | md::delete("Old")
Result
~~Old~~
blockquote(value: dynamic): markdown function

Wraps `value` in a blockquote node.

Module: import "md" | md::blockquote(...)

Example
import "md" | md::blockquote("Quote")
Result
> Quote
callout(value: dynamic, kind: dynamic, title: dynamic): markdown function

Wraps `value` in a callout node of the given `kind` (e.g. "note", "warning"), with an optional custom `title`.

Module: import "md" | md::callout(...)

Example
import "md" | md::callout("Note text", "note", "")
Result
> [!NOTE]
> Note text
hr(): markdown function

Creates a horizontal rule node.

Module: import "md" | md::hr(...)

Example
import "md" | md::hr()
Result
***
br(): markdown function

Creates a blank line between the surrounding elements in a `doc()`/`to_md_fragment()` call.

Module: import "md" | md::br(...)

math(value: dynamic): markdown function

Wraps `value` in a math block node.

Module: import "md" | md::math(...)

Example
import "md" | md::math("x^2")
Result
$$
x^2
$$
math_inline(value: dynamic): markdown function

Wraps `value` in an inline math node.

Module: import "md" | md::math_inline(...)

Example
import "md" | md::math_inline("x^2")
Result
$x^2$
link(url: dynamic, value: dynamic, title: dynamic): markdown function

Creates a link node pointing to `url` with link text `value` and an optional `title`.

Module: import "md" | md::link(...)

Example
import "md" | md::link("https://example.com", "Example", "")
Result
[Example](https://example.com)
image(url: dynamic, alt: dynamic, title: dynamic): markdown function

Creates an image node pointing to `url` with `alt` text and an optional `title`.

Module: import "md" | md::image(...)

Example
import "md" | md::image("https://example.com/a.png", "Alt", "")
Result
![Alt](https://example.com/a.png "")
footnote(value: dynamic, ident: dynamic): markdown function

Wraps `value` in a footnote definition node identified by `ident`.

Module: import "md" | md::footnote(...)

Example
import "md" | md::footnote("Footnote text", "1")
Result
[^1]: Footnote text
footnote_ref(ident: dynamic): markdown function

Creates a footnote reference node pointing at `ident`.

Module: import "md" | md::footnote_ref(...)

Example
import "md" | md::footnote_ref("1")
Result
[^1]
definition(url: dynamic, ident: dynamic, title: dynamic): markdown function

Creates a link reference definition node (`[ident]: url "title"`) for `ident`, with an optional `title`.

Module: import "md" | md::definition(...)

Example
import "md" | md::definition("https://example.com", "ex", "")
Result
[ex]: https://example.com
html(value: dynamic): markdown function

Wraps `value` in a raw HTML node, emitted as-is.

Module: import "md" | md::html(...)

Example
import "md" | md::html("<br>")
Result
<br>
linebreak(): markdown function

Creates a hard line break node.

Module: import "md" | md::linebreak(...)

list(value: dynamic, level: dynamic, ordered: dynamic, checked: dynamic): markdown function

Wraps `value` in a list item node at the given `level` (0-indexed nesting), optionally `ordered` (numbered) and/or `checked` (checkbox); pass `checked = None` for a plain item.

Module: import "md" | md::list(...)

Example
import "md" | md::list("Item", 0)
Result
- Item
table_row(cells: dynamic): markdown function

Creates a table row node from an array of cell values.

Module: import "md" | md::table_row(...)

Example
import "md" | md::table_row(["a", "b"])
Result
|a|b|
table_cell(value: dynamic, row: dynamic, column: dynamic): markdown function

Creates a single table cell node at the given `row`/`column`.

Module: import "md" | md::table_cell(...)

Example
import "md" | md::table_cell("A1", 0, 0)
Result
A1
table_align(aligns: dynamic): markdown function

Creates a table alignment (header separator) row node from an array of alignments (e.g. ["left", "right", "center"]).

Module: import "md" | md::table_align(...)

Example
import "md" | md::table_align(["left", "right"])
Result
|:---|---:|
table(header: dynamic, rows: dynamic, aligns: dynamic): array function

Builds a full table from a `header` array of cell values and a `rows` array of row arrays. `aligns` is an array of alignment strings (e.g. ["left", "right", "center"]) matching `header`'s length; defaults to no alignment. Returns an array of row/align nodes ready to splice into `doc()`.

Module: import "md" | md::table(...)

Example
import "md" | md::doc(md::table(["A", "B"], [["1", "2"], ["3", "4"]]))
Result
|A|B|
|---|---|
|1|2|
|3|4|
doc(values: dynamic): markdown function

Combines markdown nodes into a single markdown value. Accepts either a variable number of arguments (`doc(a, b, c)`) or a single array (`doc([a, b, c])`). Nested arrays (e.g. from `map()`) are flattened automatically, so components can return plain arrays of nodes and be spliced in as children.

Module: import "md" | md::doc(...)

Example
import "md" | md::doc(md::h("T", 1), md::text("hi"))
Result
# T
hi

The section module splits and filters Markdown documents by heading section. Call it via `import "section"` then `section::fn()` (recommended, namespaced), `include "section"` then `fn()` (no namespace prefix), or `mq -A 'section::fn()'` on the command line. Section functions need every document node at once — pass `-A` on the CLI, or pipe through `nodes` in an inline query/script; a single node instead prints a stderr warning and is treated as a one-element array.

Example
import "section" | len(section::section(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"), "A"))
Result
2

19 functions

section(md_nodes: dynamic, pattern: dynamic, depth: dynamic): array function

Returns sections whose title contains the specified pattern. If depth is true, each section spans until the next header at the same or higher level (delegates to section::sections(md_nodes, depth), see its doc for details).

Module: import "section" | section::section(...)

Example
import "section" | len(section::section(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"), "A"))
Result
2
sections(md_nodes: dynamic, depth: dynamic): array function

Splits markdown nodes into sections based on headers. If depth is true, each section's body extends to the next heading at the same or higher level as that section's own heading, so nested subheadings' content is included in their parent's body. If depth is false (default), every heading of any level is a boundary, so a heading's body only extends to the very next heading regardless of level.

Module: import "section" | section::sections(...)

Example 1
import "section" | len(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")))
Result
3
Example 2
import "section" | len(section::body(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"), true))))
Result
3
filter_sections(md_nodes: dynamic, predicate: dynamic): array function

Filters sections based on a given predicate function.

Module: import "section" | section::filter_sections(...)

Example
import "section" | len(section::filter_sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"), fn(s): true;))
Result
3
map_sections(md_nodes: dynamic, mapper: dynamic): array function

Maps sections using a given mapper function.

Module: import "section" | section::map_sections(...)

Example
import "section" | section::map_sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"), fn(header, children): to_text(header);)
Result
["A", "A1", "B"]
split(md_nodes: dynamic, level: dynamic): array function

Returns an array of sections, each section is an array of markdown nodes between the specified header and the next header of the same level.

Module: import "section" | section::split(...)

Example
import "section" | len(section::split(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"), 1))
Result
2
title_contains(sections: dynamic, text: dynamic): array function

Filters the given list of sections, returning only those whose title contains the specified text.

Module: import "section" | section::title_contains(...)

Example
import "section" | len(section::title_contains(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")), "A"))
Result
2
title_match(sections: dynamic, pattern: dynamic): array function

Filters sections by a pattern match in the title text.

Module: import "section" | section::title_match(...)

Example
import "section" | len(section::title_match(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")), "^A"))
Result
2
title(section: dynamic): string function

Returns the title text of a section (header text without the # symbols).

Module: import "section" | section::title(...)

Example
import "section" | section::title(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"))))
Result
A
content(section: dynamic): array functionDeprecated

Returns the content of a section (all nodes except the header). Deprecated: Use body() instead, as content()

Module: import "section" | section::content(...)

Example
import "section" | len(section::content(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")))))
Result
1
body(section: dynamic): array function

Returns the body of a section (all nodes except the header).

Module: import "section" | section::body(...)

Example
import "section" | len(section::body(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")))))
Result
1
all_nodes(section: dynamic): array function

Returns all nodes of a section, including both the header and content.

Module: import "section" | section::all_nodes(...)

Example
import "section" | len(section::all_nodes(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")))))
Result
2
by_level(sections: dynamic, l: dynamic): array function

Filters sections by heading level. l can be a number (exact level) or a range array (e.g. 1..2).

Module: import "section" | section::by_level(...)

Example
import "section" | len(section::by_level(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")), 1))
Result
2
level(section: dynamic): number function

Returns the header level (1-6) of a section.

Module: import "section" | section::level(...)

Example
import "section" | section::level(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"))))
Result
1
nth(sections: dynamic, n: dynamic): dynamic function

Returns the nth section from an array of sections (0-indexed).

Module: import "section" | section::nth(...)

Example
import "section" | section::title(section::nth(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")), 0))
Result
A
titles(sections: dynamic): array function

Extracts titles from all sections.

Module: import "section" | section::titles(...)

Example
import "section" | section::titles(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")))
Result
["A", "A1", "B"]
bodies(sections: dynamic): array function

Extracts body from all sections.

Module: import "section" | section::bodies(...)

Example
import "section" | len(section::bodies(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"))))
Result
3
toc(sections: dynamic): array function

Generates a table of contents from sections.

Module: import "section" | section::toc(...)

Example
import "section" | section::toc(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B")))
Result
["  - A", "    - A1", "  - B"]
has_content(section: dynamic): bool function

Checks if a section has any content beyond the header.

Module: import "section" | section::has_content(...)

Example
import "section" | section::has_content(first(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"))))
Result
true
collect(sections: dynamic): array function

Flattens sections back to markdown nodes for output. This converts section objects back to their original markdown node arrays.

Module: import "section" | section::collect(...)

Example
import "section" | len(section::collect(section::sections(to_markdown("# A\n\nBody A\n\n## A1\n\nSub A\n\n# B\n\nBody B"))))
Result
6

Semantic Versioning (SemVer) Implementation in mq Based on the Semantic Versioning 2.0.0 specification: https://semver.org/

15 functions

semver_parse(s: dynamic): dict function

Parses a SemVer string into a dict with major, minor, patch, pre, and build fields.

Module: import "semver" | semver::semver_parse(...)

Example
import "semver" | semver::semver_to_string(semver::semver_parse("1.2.3-beta.1"))
Result
1.2.3-beta.1
semver_to_string(v: dynamic): string function

Converts a parsed SemVer dict back to a version string.

Module: import "semver" | semver::semver_to_string(...)

Example
import "semver" | semver::semver_to_string(semver::semver_parse("1.2.3-beta"))
Result
1.2.3-beta
semver_compare(a: dynamic, b: dynamic): number function

Compares two parsed SemVer dicts. Returns -1 if a < b, 0 if a == b, 1 if a > b.

Module: import "semver" | semver::semver_compare(...)

Example
import "semver" | semver::semver_compare(semver::semver_parse("1.0.0"), semver::semver_parse("2.0.0"))
Result
-1
semver_gt(a: dynamic, b: dynamic): bool function

Returns true if version a is greater than version b.

Module: import "semver" | semver::semver_gt(...)

Example
import "semver" | semver::semver_gt(semver::semver_parse("2.0.0"), semver::semver_parse("1.0.0"))
Result
true
semver_lt(a: dynamic, b: dynamic): bool function

Returns true if version a is less than version b.

Module: import "semver" | semver::semver_lt(...)

Example
import "semver" | semver::semver_lt(semver::semver_parse("1.0.0"), semver::semver_parse("2.0.0"))
Result
true
semver_eq(a: dynamic, b: dynamic): bool function

Returns true if version a equals version b (ignoring build metadata).

Module: import "semver" | semver::semver_eq(...)

Example
import "semver" | semver::semver_eq(semver::semver_parse("1.0.0"), semver::semver_parse("1.0.0"))
Result
true
semver_gte(a: dynamic, b: dynamic): bool function

Returns true if version a is greater than or equal to version b.

Module: import "semver" | semver::semver_gte(...)

Example
import "semver" | semver::semver_gte(semver::semver_parse("1.0.0"), semver::semver_parse("1.0.0"))
Result
true
semver_lte(a: dynamic, b: dynamic): bool function

Returns true if version a is less than or equal to version b.

Module: import "semver" | semver::semver_lte(...)

Example
import "semver" | semver::semver_lte(semver::semver_parse("1.0.0"), semver::semver_parse("1.0.0"))
Result
true
semver_bump_major(v: dynamic): dict function

Increments the major version and resets minor, patch, and pre-release.

Module: import "semver" | semver::semver_bump_major(...)

Example
import "semver" | semver::semver_to_string(semver::semver_bump_major(semver::semver_parse("1.2.3")))
Result
2.0.0
semver_bump_minor(v: dynamic): dict function

Increments the minor version and resets patch and pre-release.

Module: import "semver" | semver::semver_bump_minor(...)

Example
import "semver" | semver::semver_to_string(semver::semver_bump_minor(semver::semver_parse("1.2.3")))
Result
1.3.0
semver_bump_patch(v: dynamic): dict function

Increments the patch version and clears pre-release.

Module: import "semver" | semver::semver_bump_patch(...)

Example
import "semver" | semver::semver_to_string(semver::semver_bump_patch(semver::semver_parse("1.2.3")))
Result
1.2.4
semver_sort(versions: dynamic): array function

Sorts an array of parsed SemVer dicts in ascending order.

Module: import "semver" | semver::semver_sort(...)

Example
import "semver" | map(semver::semver_sort([semver::semver_parse("2.0.0"), semver::semver_parse("1.0.0")]), semver::semver_to_string)
Result
["1.0.0", "2.0.0"]
semver_max(versions: dynamic): dict function

Returns the maximum version from an array of parsed SemVer dicts.

Module: import "semver" | semver::semver_max(...)

Example
import "semver" | semver::semver_to_string(semver::semver_max([semver::semver_parse("1.0.0"), semver::semver_parse("2.0.0")]))
Result
2.0.0
semver_min(versions: dynamic): dict function

Returns the minimum version from an array of parsed SemVer dicts.

Module: import "semver" | semver::semver_min(...)

Example
import "semver" | semver::semver_to_string(semver::semver_min([semver::semver_parse("1.0.0"), semver::semver_parse("2.0.0")]))
Result
1.0.0
semver_satisfies(version: dynamic, range: dynamic): bool function

Returns true if the given version string satisfies every comma-separated comparator in `range`. Supported comparators: "=", "==", "!=", ">", ">=", "<", "<=". A bare version (no operator) requires an exact match. Example: semver_satisfies("1.5.0", ">=1.0.0,<2.0.0") == true

Module: import "semver" | semver::semver_satisfies(...)

Example
import "semver" | semver::semver_satisfies("1.5.0", ">=1.0.0,<2.0.0")
Result
true

The table module extracts and transforms Markdown tables. This module is under development; APIs and behavior may change without notice. Call it via `import "table"` then `table::fn()` — from an inline query, a script, or `mq -A 'import "table" | table::fn()'` on the command line. Unlike `section`, `import` must always be written explicitly (no `include` shortcut). Table functions need every document node at once: pass `-A` on the CLI, or pipe through `nodes` inline.

Example
import "table" | len(table::tables(to_markdown("| a | b |\n| - | - |\n| 1 | 2 |")))
Result
1

15 functions

tables(md_nodes: dynamic): array function

Extract table structures from a list of markdown nodes.

Module: import "table" | table::tables(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | len(self)
Result
1
set_align(table: dynamic, align: dynamic): dict function

Set the alignment for a table.

Module: import "table" | table::set_align(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::set_align(self, ["left", "right"]) | table::to_csv(self)
Result
a,b
1,2
3,4
add_row(table: dynamic, row: dynamic): dict function

Add a new row to a table.

Module: import "table" | table::add_row(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::add_row(self, ["5", "6"]) | table::to_csv(self)
Result
a,b
1,2
3,4
5,6
add_column(table: dynamic, col: dynamic): dict function

Add a new column to a table.

Module: import "table" | table::add_column(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::add_column(self, ["c", "9", "10"]) | table::to_csv(self)
Result
a,b,c
1,2,9
3,4,10
remove_row(table: dynamic, row_index: dynamic): dict function

Remove a row from a table at the specified index.

Module: import "table" | table::remove_row(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::remove_row(self, 0) | table::to_csv(self)
Result
a,b
3,4
remove_column(table: dynamic, col_index: dynamic): dict function

Remove a column from a table at the specified index.

Module: import "table" | table::remove_column(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::remove_column(self, 0) | len(self[:rows][0])
Result
1
map_rows(table: dynamic, f: dynamic): dict function

Map a function over each row in the table.

Module: import "table" | table::map_rows(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::map_rows(self, fn(row): row;) | table::to_csv(self)
Result
a,b
1,2
3,4
filter_tables(tables: dynamic, f: dynamic): array function

Filter tables from markdown nodes based on a predicate function.

Module: import "table" | table::filter_tables(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | table::filter_tables(self, fn(h, r): true;) | len(self)
Result
1
filter_rows(table: dynamic, f: dynamic): dict function

Filter rows in the table based on a predicate function.

Module: import "table" | table::filter_rows(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::filter_rows(self, fn(row): true;) | table::to_csv(self)
Result
a,b
1,2
3,4
sort_rows(table: dynamic, column_index: dynamic): dict function

Sort rows in the table by a specified column index or default sorting.

Module: import "table" | table::sort_rows(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::sort_rows(self) | table::to_csv(self)
Result
a,b
1,2
3,4
to_markdown(table: dynamic): array function

Convert a table structure back into a list of markdown nodes.

Module: import "table" | table::to_markdown(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::to_markdown(self) | len(self)
Result
7
to_csv(table: dynamic, delimiter: dynamic): string function

Convert a table structure into a CSV string with the specified delimiter.

Module: import "table" | table::to_csv(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::to_csv(self)
Result
a,b
1,2
3,4
to_array(table: dynamic): array function

Convert a table structure into an array of dict records keyed by header text. The resulting shape matches `csv::csv_parse`'s output, so it composes with `join_by` and other record-array builtins.

Module: import "table" | table::to_array(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::to_array(self)
Result
[{"a": "1", "b": "2"}, {"a": "3", "b": "4"}]
pivot_longer(table: dynamic, value_columns: dynamic, names_to: dynamic, values_to: dynamic): dict function

Reshape a table from wide format to long format (a.k.a. melt/unpivot). `value_columns` is an array of column indices to unpivot; each one becomes a row holding its header name (in the `names_to` column) and its cell value (in the `values_to` column). Columns not listed in `value_columns` are treated as identifier columns and repeated for every unpivoted value.

Module: import "table" | table::pivot_longer(...)

Example
import "table" | table::tables(to_markdown("| a | b |\n| --- | --- |\n| 1 | 2 |\n| 3 | 4 |")) | first(self) | table::pivot_longer(self, [1]) | table::to_csv(self)
Result
a,name,value
1,b,2
3,b,4
pivot_wider(table: dynamic, names_from: dynamic, values_from: dynamic): dict function

Reshape a table from long format to wide format (a.k.a. pivot/cast). `names_from` is the column index whose distinct values become the headers of new columns; `values_from` is the column index supplying the values for those new columns. Columns other than `names_from` and `values_from` are treated as identifier columns and used to group rows together.

Module: import "table" | table::pivot_wider(...)

Example
import "table" | table::tables(to_markdown("| id | name | value |\n| --- | --- | --- |\n| 1 | x | 10 |\n| 1 | y | 20 |")) | first(self) | table::pivot_wider(self, 1, 2) | table::to_csv(self)
Result
id,x,y
1,10,20

Testing framework for mq A simple testing framework to execute test functions and output results

16 functions

assert(cond: dynamic): dynamic function

Verifies that a condition is true and raises an error if it's false.

Module: import "test" | test::assert(...)

Example
true | include "test" | assert(true)
Result
true
assert_eq(actual: dynamic, expected: dynamic): dynamic function

Verifies that two values are equal

Module: import "test" | test::assert_eq(...)

Example
1 | include "test" | assert_eq(1, 1)
Result
1
assert_ne(actual: dynamic, expected: dynamic): dynamic function

Verifies that two values are not equal

Module: import "test" | test::assert_ne(...)

Example
1 | include "test" | assert_ne(1, 2)
Result
1
assert_true(value: dynamic): dynamic function

Verifies that a value is true

Module: import "test" | test::assert_true(...)

Example
true | include "test" | assert_true(true)
Result
true
assert_false(value: dynamic): dynamic function

Verifies that a value is false

Module: import "test" | test::assert_false(...)

Example
false | include "test" | assert_false(false)
Result
false
assert_none(value: dynamic): dynamic function

Verifies that a value is None

Module: import "test" | test::assert_none(...)

Example
None | include "test" | assert_none(None)
Result
assert_not_none(value: dynamic): dynamic function

Verifies that a value is not None

Module: import "test" | test::assert_not_none(...)

Example
1 | include "test" | assert_not_none(1)
Result
1
assert_contains(array: dynamic, value: dynamic): dynamic function

Verifies that an array contains a specific value

Module: import "test" | test::assert_contains(...)

Example
[1, 2] | include "test" | assert_contains([1, 2], 1)
Result
[1, 2]
assert_len(array: dynamic, expected_length: dynamic): dynamic function

Verifies that an array has a specific length

Module: import "test" | test::assert_len(...)

Example
[1, 2] | include "test" | assert_len([1, 2], 2)
Result
[1, 2]
assert_empty(array: dynamic): dynamic function

Verifies that an array is empty

Module: import "test" | test::assert_empty(...)

Example
[] | include "test" | assert_empty([])
Result
[]
assert_not_empty(array: dynamic): dynamic function

Verifies that an array is not empty

Module: import "test" | test::assert_not_empty(...)

Example
[1] | include "test" | assert_not_empty([1])
Result
[1]
assert_type(value: dynamic, expected_type: dynamic): dynamic function

Verifies that a value has the given type. For markdown nodes this checks the node kind (e.g. "h1", "code", "list"), matching `to_md_name`. For every other value it checks the runtime type returned by `type`. On failure the source range of `value` is included so callers (e.g. content-lint rules) can point at the offending node.

Module: import "test" | test::assert_type(...)

Example
1 | include "test" | assert_type(1, "number")
Result
1
assert_field(value: dynamic, field: dynamic): dynamic function

Verifies that a dict has the given field.

Module: import "test" | test::assert_field(...)

Example
{"a": 1} | include "test" | assert_field({"a": 1}, "a")
Result
{"a": 1}
assert_matches(value: dynamic, pattern: dynamic): dynamic function

Verifies that a value's string representation matches the given regular expression pattern.

Module: import "test" | test::assert_matches(...)

Example
"abc" | include "test" | assert_matches("abc", "a.c")
Result
abc
run_tests(tests: dynamic): bool function

Executes multiple test functions. The whole report is built as a single string and printed with one `print` call, so concurrently running test files (the Rust runner may evaluate several files in parallel) can never interleave their output mid-line. Returns `true` if every test passed, so the caller can aggregate pass/fail across files itself instead of this function terminating the process.

Module: import "test" | test::run_tests(...)

test_case(name: dynamic, func: dynamic): dict function

Helper function to create a test case

Module: import "test" | test::test_case(...)

Example
include "test" | test_case("my test", fn(): true;)["name"]
Result
my test

TOML Implementation in mq Based on TOML v1.0.0 specification

4 functions

toml_parse(input: dynamic): dynamic function

Parses a TOML string and returns the parsed data structure.

Module: import "toml" | toml::toml_parse(...)

Example
import "toml" | toml::toml_parse("key = 1")
Result
{"key": 1}
toml_stringify(data: dynamic): string function

Converts a data structure to a TOML string representation.

Module: import "toml" | toml::toml_stringify(...)

Example
import "toml" | toml::toml_stringify({"key": 1})
Result
key = 1
toml_to_json(data: dynamic): string function

Converts a data structure to a JSON string representation.

Module: import "toml" | toml::toml_to_json(...)

Example
import "toml" | toml::toml_to_json({"key": 1})
Result
{"key":1}
toml_to_markdown_table(data: dynamic): string function

Converts a TOML data structure to a Markdown table.

Module: import "toml" | toml::toml_to_markdown_table(...)

Example
import "toml" | toml::toml_to_markdown_table([{"a": 1}])
Result
| a |
| --- |
| 1 |

TOON implementation in mq

2 functions

toon_stringify(data: dynamic): string function

To convert a data structure into a TOON string

Module: import "toon" | toon::toon_stringify(...)

Example
import "toon" | toon::toon_stringify({"a": 1})
Result
a: 1
toon_parse(input: dynamic): dynamic function

To parse a TOON string into a data structure

Module: import "toon" | toon::toon_parse(...)

Example
import "toon" | toon::toon_parse(toon::toon_stringify({"a": 1}))
Result
{"a": 1}

XML Implementation in mq

3 functions

xml_parse(input: dynamic): dynamic function

Parses an XML string and returns the corresponding data structure.

Module: import "xml" | xml::xml_parse(...)

Example
import "xml" | xml::xml_parse("<a>hi</a>")["tag"]
Result
a
xml_stringify(data: dynamic): string function

Serializes a value to an XML string.

Module: import "xml" | xml::xml_stringify(...)

Example
import "xml" | xml::xml_stringify({"tag": "a", "attributes": {}, "children": [], "text": "hi"})
Result
<?xml version="1.0" encoding="UTF-8"?>
<a>hi</a>
xml_to_markdown_table(data: dynamic): string function

Converts an XML data structure to a Markdown table.

Module: import "xml" | xml::xml_to_markdown_table(...)

Example
import "xml" | xml::xml_to_markdown_table({"tag": "a", "attributes": {}, "children": [], "text": "hi"})
Result
| Tag | Attributes | Text | Children |
| --- | --- | --- | --- |
| a |  | hi | 0 |

Based on YAML 1.2 specification

6 functions

yaml_parse(input: dynamic): dynamic function

Parses a YAML string and returns the parsed data structure. A single `---`-separated document is returned as-is; if the input contains multiple `---`-separated documents, an array of the parsed documents is returned.

Module: import "yaml" | yaml::yaml_parse(...)

Example
import "yaml" | yaml::yaml_parse("key: 1")
Result
{"key": 1}
yaml_stringify(data: dynamic): string function

Converts a data structure to a YAML string representation.

Module: import "yaml" | yaml::yaml_stringify(...)

Example
import "yaml" | yaml::yaml_stringify({"key": 1})
Result
key: 1
yaml_to_markdown_table(data: dynamic): string function

Converts a YAML data structure to a Markdown table.

Module: import "yaml" | yaml::yaml_to_markdown_table(...)

Example
import "yaml" | yaml::yaml_to_markdown_table([{"a": 1}])
Result
| a |
| --- |
| 1 |
yaml_to_json(data: dynamic): string function

Converts a data structure to a JSON string representation.

Module: import "yaml" | yaml::yaml_to_json(...)

Example
import "yaml" | yaml::yaml_to_json({"key": 1})
Result
{"key": 1}
to_front_matter(data: dynamic): string functionDeprecated

Converts a data structure to a YAML front matter string. deprecated: use to_frontmatter instead

Module: import "yaml" | yaml::to_front_matter(...)

Example
import "yaml" | yaml::to_front_matter({"key": 1})
Result
---
key: 1
---
to_frontmatter(data: dynamic): string function

Converts a data structure to a YAML front matter string.

Module: import "yaml" | yaml::to_frontmatter(...)

Example
import "yaml" | yaml::to_frontmatter({"key": 1})
Result
---
key: 1
---

48 selectors

..(): array selector

Recursively selects every descendant node (depth-first), not the node itself. Combine with a following selector for a descendant chain, e.g. `.blockquote .code` (sugar for `.blockquote | .. | .code`).

Example
to_markdown("> ## Nested")[0] | ..
Result
[Nested, ## Nested]
.<>(): markdown selector

Selects an HTML node.

.[](index: number, ...: dynamic): markdown selector

Selects a list item node, optionally filtered by item index (e.g. `.[](0)`). To filter by checked state, use `.task`/`.todo`/`.done` instead.

Example
to_md_list("Item", 0) | .[]
Result
- Item
.[][](row: number, column: number): markdown selector

Selects a table cell node with the specified row and column.

Example
to_md_table_cell("A1", 0, 0) | .[][]
Result
A1
.blockquote(): markdown selector

Selects a blockquote node.

Example
to_blockquote("Quote") | .blockquote
Result
> Quote
.break(): markdown selector

Selects a break node.

Example
to_markdown("Line1  \nLine2")[1] | .break
Result
\
.callout(kind: string, ...: dynamic): markdown selector

Selects an Obsidian-style callout node, optionally filtered by kind (e.g. `.callout("note")`).

Example
to_markdown("> [!NOTE]\n> body")[0] | .callout
Result
> [!NOTE]
> body
.code(lang: string, ...: dynamic): markdown selector

Selects a code block node with the specified language.

Example
to_code("x = 1", "python") | .code
Result
```python
x = 1
```
.code_inline(): markdown selector

Selects an inline code node.

Example
to_code_inline("x") | .code_inline
Result
`x`
.definition(ident: string, ...: dynamic): markdown selector

Selects a definition node, optionally filtered by identifier.

Example
to_markdown("[ref]: https://example.com")[0] | .definition
Result
[ref]: https://example.com
.delete(): markdown selector

Selects a delete (strikethrough) node.

Example
to_delete("Old") | .delete
Result
~~Old~~
.done(): markdown selector

Selects a done item in the task list node.

Example
to_markdown("- [ ] Todo\n- [x] Done")[1] | .done
Result
- [x] Done
.embed(target: string, ...: dynamic): markdown selector

Selects an Obsidian-style embed node, optionally filtered by target.

Example
to_markdown("![[image.png]]")[0] | .embed
Result
![[image.png]]
.emphasis(): markdown selector

Selects an emphasis (italic) node.

Example
to_em("Italic") | .emphasis
Result
*Italic*
.footnote(ident: string, ...: dynamic): markdown selector

Selects a footnote node, optionally filtered by identifier.

Example
to_markdown("Text[^1]\n\n[^1]: Note")[2] | .footnote
Result
[^1]: Note
.footnote_ref(ident: string, ...: dynamic): markdown selector

Selects a footnote reference node, optionally filtered by identifier.

Example
to_markdown("Text[^1]\n\n[^1]: Note")[1] | .footnote_ref
Result
[^1]
.h(depth: number, ...: dynamic): markdown selector

Selects a heading node with the specified depth.

Example
to_h("Title", 3) | .h
Result
### Title
.h1(): markdown selector

Selects a heading node with the 1 depth.

Example
to_h("Title", 1) | .h1
Result
# Title
.h2(): markdown selector

Selects a heading node with the 2 depth.

Example
to_h("Title", 2) | .h2
Result
## Title
.h3(): markdown selector

Selects a heading node with the 3 depth.

Example
to_h("Title", 3) | .h3
Result
### Title
.h4(): markdown selector

Selects a heading node with the 4 depth.

Example
to_h("Title", 4) | .h4
Result
#### Title
.h5(): markdown selector

Selects a heading node with the 5 depth.

Example
to_h("Title", 5) | .h5
Result
##### Title
.h6(): markdown selector

Selects a heading node with the 6 depth.

Example
to_h("Title", 6) | .h6
Result
###### Title
.heading(depth: number, ...: dynamic): markdown selector

Selects a heading node with the specified depth.

Example
to_h("Title", 2) | .heading
Result
## Title
.horizontal_rule(): markdown selector

Selects a horizontal rule node.

Example
to_hr() | .horizontal_rule
Result
***
.html(): markdown selector

Selects an HTML node.

Example
to_markdown("<div>hi</div>")[0] | .html
Result
<div>hi</div>
.image(url: string, ...: dynamic): markdown selector

Selects an image node, optionally filtered by URL (e.g. `.image("a.png")`).

Example
to_image("https://example.com/a.png", "Alt", "") | .image
Result
![Alt](https://example.com/a.png "")
.image_ref(ident: string, ...: dynamic): markdown selector

Selects an image reference node, optionally filtered by identifier.

Example
to_markdown("![alt][ref]\n\n[ref]: https://example.com/a.png")[0] | .image_ref
Result
![alt][ref]
.inline_math(): markdown selector

Selects an inline math node.

Example
to_math_inline("x^2") | .inline_math
Result
$x^2$
.link(url: string, ...: dynamic): markdown selector

Selects a link node, optionally filtered by URL (e.g. `.link("https://example.com")`).

Example
to_link("https://example.com", "Example", "") | .link
Result
[Example](https://example.com)
.link_ref(ident: string, ...: dynamic): markdown selector

Selects a link reference node, optionally filtered by identifier.

Example
to_markdown("[text][ref]\n\n[ref]: https://example.com")[0] | .link_ref
Result
[text][ref]
.list(index: number, ...: dynamic): markdown selector

Selects a list item node, optionally filtered by item index (e.g. `.list(0)`). To filter by checked state, use `.task`/`.todo`/`.done` instead.

Example
to_md_list("Item", 0) | .list
Result
- Item
.math(): markdown selector

Selects a math node.

Example
to_math("x^2") | .math
Result
$$
x^2
$$
.math_inline(): markdown selector

Selects a math inline node.

Example
to_math_inline("x^2") | .math_inline
Result
$x^2$
.mdx_flow_expression(): markdown selector

Selects an MDX flow expression node.

Example
to_mdx("{1 + 1}")[0] | .mdx_flow_expression
Result
{1 + 1}
.mdx_js_esm(): markdown selector

Selects an MDX JS ESM node.

.mdx_jsx_flow_element(name: string, ...: dynamic): markdown selector

Selects an MDX JSX flow element node, optionally filtered by tag name.

Example
to_mdx("<Foo />")[0] | .mdx_jsx_flow_element
Result
<Foo />
.mdx_jsx_text_element(name: string, ...: dynamic): markdown selector

Selects an MDX JSX text element node, optionally filtered by tag name.

Example
to_mdx("Hello <b>world</b>.")[1] | .mdx_jsx_text_element
Result
<b>world</b>
.mdx_text_expression(): markdown selector

Selects an MDX text expression node.

Example
to_mdx("Value is {1 + 1}.")[1] | .mdx_text_expression
Result
{1 + 1}
.strong(): markdown selector

Selects a strong (bold) node.

Example
to_strong("Bold") | .strong
Result
**Bold**
.table(row: number, column: number): markdown selector

Selects a table cell node with the specified row and column.

Example
to_md_table_cell("A1", 0, 0) | .table
Result
A1
.table_align(): markdown selector

Selects a table align node.

Example
to_md_table_align(["left", "right"]) | .table_align
Result
|:---|---:|
.task(): markdown selector

Selects a task list node.

Example
to_markdown("- [ ] Todo\n- [x] Done")[0] | .task
Result
- [ ] Todo
.text(): markdown selector

Selects a text node.

Example
to_md_text("Hello") | .text
Result
Hello
.todo(): markdown selector

Selects a todo item in the task list node.

Example
to_markdown("- [ ] Todo\n- [x] Done")[0] | .todo
Result
- [ ] Todo
.toml(): markdown selector

Selects a TOML node.

Example
to_markdown("+++\nkey = 1\n+++\n\nBody")[0] | .toml
Result
+++
key = 1
+++
.wikilink(target: string, ...: dynamic): markdown selector

Selects an Obsidian-style wikilink node, optionally filtered by target.

Example
to_markdown("[[target]]")[0] | .wikilink
Result
[[target]]
.yaml(): markdown selector

Selects a YAML node.

Example
to_markdown("---\nkey: 1\n---\n\nBody")[0] | .yaml
Result
---
key: 1
---