426 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
abs |
Returns the absolute value of the given number. | number |
abs(number) |
add |
Adds two values. | value1, value2 |
add(value1, value2) |
all |
Returns true if all element in the array satisfies the provided function. | v, f |
all(v, f) |
all_symbols |
Returns an array of all interned symbols. | all_symbols() |
|
and |
Performs a logical AND operation on two boolean values. | value1, value2 |
and(value1, value2) |
any |
Returns true if any element in the array satisfies the provided function. | v, f |
any(v, f) |
array |
Creates an array from the given values. | values |
array(values) |
arrays |
Returns array if input is array, None otherwise | a |
arrays(a) |
ascii_downcase |
Converts ASCII uppercase letters (A-Z) in the given string to lowercase, leaving all other characters unchanged. | input |
ascii_downcase(input) |
ascii_upcase |
Converts ASCII lowercase letters (a-z) in the given string to uppercase, leaving all other characters unchanged. | input |
ascii_upcase(input) |
assert |
Asserts that two values are equal, returns the value if true, otherwise raises an error. | value1, value2 |
assert(value1, value2) |
attr |
Retrieves the value of the specified attribute from a markdown node. | markdown, attribute |
attr(markdown, attribute) |
band |
Computes the bitwise AND of two byte arrays of equal length. | bytes1, bytes2 |
band(bytes1, bytes2) |
base64 |
Encodes the given string to base64. | input |
base64(input) |
base64d |
Decodes the given base64 string. | input |
base64d(input) |
base64url |
Encodes the given string to URL-safe base64. | input |
base64url(input) |
base64urld |
Decodes the given URL-safe base64 string. | input |
base64urld(input) |
basename |
Returns the final component of a path string (e.g. "file.txt" from "/a/b/file.txt"). | path |
basename(path) |
between |
Checks if a value is between min and max (inclusive). | value, min, max |
between(value, min, max) |
bnot |
Computes the bitwise NOT (complement) of a byte array. | bytes |
bnot(bytes) |
booleans |
Returns boolean if input is boolean, None otherwise | b |
booleans(b) |
bor |
Computes the bitwise OR of two byte arrays of equal length. | bytes1, bytes2 |
bor(bytes1, bytes2) |
breakpoint |
Sets a breakpoint for debugging; execution will pause at this point if a debugger is attached. | breakpoint() |
|
bsearch |
Performs a binary search on a sorted array to find the index of the target value. | arr, target |
bsearch(arr, target) |
bytes |
Returns bytes if input is bytes, None otherwise | b |
bytes(b) |
capture |
Captures named groups from the given string based on the specified regular expression pattern and returns them as a dictionary keyed by group names. | string, pattern |
capture(string, pattern) |
ceil |
Rounds the given number up to the nearest integer. | number |
ceil(number) |
chunk_by |
Splits an array into chunks based on the result of applying a function to each element, grouping consecutive elements with the same key together. | v, f |
chunk_by(v, f) |
chunks |
Splits an array into chunks of a specified size, returning an array of arrays. | v, size |
chunks(v, size) |
coalesce |
Returns the first non-None value from the two provided arguments. | value1, value2 |
coalesce(value1, value2) |
collection |
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. Requires the --allow-read CLI flag; otherwise returns a runtime error. | dir |
collection(dir) |
comp |
Composes functions into one function, applying them right-to-left. `comp(f, g, h)(x)` is equivalent to `f(g(h(x)))`. | fns |
comp(fns) |
compact |
Removes None values from the given array. | array |
compact(array) |
compact_map |
Maps over an array and removes None values from the result. | arr, f |
compact_map(arr, f) |
complement |
Returns a new predicate function that negates the result of the given function. | f |
complement(f) |
contains |
Checks if string contains a substring | haystack, needle |
contains(haystack, needle) |
convert |
Converts the input value to the specified format. Supported formats: base64, html, text, uri, heading (#, ##, etc.), blockquote (>), list item (-), or link (URL). | input, format |
convert(input, format) |
count_by |
Returns the count of elements in the array that satisfy the provided function. | arr, f |
count_by(arr, f) |
date_add |
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. | array, n, unit |
date_add(array, n, unit) |
date_diff |
Returns the difference (array2 - array1) in the given unit. Units: "seconds", "minutes", "hours", "days", "weeks". | array1, array2, unit |
date_diff(array1, array2, unit) |
debug |
Prints the debug information of the given value(s). | args |
debug(args) |
decrease_header_depth |
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. | node |
decrease_header_depth(node) |
decrease_header_level |
Deprecated: use `decrease_header_depth` or `promote_heading` instead. Kept for backward compatibility; behavior unchanged. | node |
decrease_header_level(node) |
del |
Deletes the element at the specified index in the array or string. | array_or_string, index |
del(array_or_string, index) |
demote_heading |
Demotes a markdown heading by increasing its depth (numeric level) by one. This is an alias for `increase_header_depth`. | node |
demote_heading(node) |
dict |
Creates a new, empty dict. | dict() |
|
dicts |
Returns dict if input is dict, None otherwise | d |
dicts(d) |
dirname |
Returns the parent directory of a path string (e.g. "/a/b" from "/a/b/file.txt"). Returns "." if the path has no parent. | path |
dirname(path) |
div |
Divides the first value by the second value. | value1, value2 |
div(value1, value2) |
downcase |
Converts the given string to lowercase. | input |
downcase(input) |
each |
Executes a provided function once for each element in an array or each key-value pair in a dictionary. | v, f |
each(v, f) |
ends_with |
Checks if the given string or byte array ends with the specified suffix. | value, suffix |
ends_with(value, suffix) |
entries |
Returns an array of key-value pairs from the dict as arrays. | dict |
entries(dict) |
eq |
Checks if two values are equal. | value1, value2 |
eq(value1, value2) |
error |
Raises a user-defined error with the specified message. | message |
error(message) |
exp |
Returns the exponential (e^x) of the given number. | number |
exp(number) |
explode |
Splits the given string into an array of characters. | string |
explode(string) |
extname |
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. | path |
extname(path) |
file_exists |
Checks if a file exists at the given path. Requires the --allow-read CLI flag; otherwise returns a runtime error. | path |
file_exists(path) |
fill |
Returns an array of length n filled with the given value. | value, n |
fill(value, n) |
filter |
Filters the elements of an array based on a provided callback function. | v, f |
filter(v, f) |
find_index |
Returns the index of the first element in an array that satisfies the provided function. | arr, f |
find_index(arr, f) |
first |
Returns the first element of an array | arr |
first(arr) |
flat_map |
Applies a function to each element and flattens the result into a single array | v, f |
flat_map(v, f) |
flatten |
Flattens a nested array into a single level array. | array |
flatten(array) |
flip |
Returns a new function that takes the same arguments as the original function but with the first two arguments flipped. | f, a, b |
flip(f, a, b) |
floor |
Rounds the given number down to the nearest integer. | number |
floor(number) |
fold |
Reduces an array to a single value by applying a function, starting from an initial value. | arr, init, f |
fold(arr, init, f) |
frequencies_by |
Counts occurrences of each key extracted from the elements of an array, returning a dict of `{key: count}`. | arr, f |
frequencies_by(arr, f) |
from_date |
Converts a date string to a timestamp. | date_str |
from_date(date_str) |
from_entries |
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. | arr |
from_entries(arr) |
from_hex |
Parses a hex string into raw bytes. | hex_string |
from_hex(hex_string) |
from_html |
Converts the given HTML string to Markdown. | html |
from_html(html) |
frontmatter |
Parses frontmatter from a markdown node, supporting both YAML and TOML formats. | v |
frontmatter(v) |
geomean |
Returns the median of an array of numbers, or None if the array is empty. | arr |
geomean(arr) |
get |
Retrieves a value from a dict by its key. Returns None if the key is not found. | obj, key |
get(obj, key) |
get_or |
Safely gets a value from a dict with a default if the key doesn't exist. | dict, key, default |
get_or(dict, key, default) |
get_path |
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. | value, path |
get_path(value, path) |
get_title |
Returns the title of a markdown node. | node |
get_title(node) |
get_url |
Returns the url of a markdown node. | node |
get_url(node) |
get_variable |
Retrieves the value of a symbol or variable from the current environment. | symbol_or_string |
get_variable(symbol_or_string) |
glob_match |
Checks whether the given path matches the glob pattern (e.g. "*.md", "docs/**/*.rs"), commonly used to filter file lists. | pattern, path |
glob_match(pattern, path) |
gmtime |
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)]. | timestamp |
gmtime(timestamp) |
group_by |
Groups elements of an array by the result of applying a function to each element | arr, f |
group_by(arr, f) |
gsub |
Replaces all occurrences matching a regular expression pattern with the replacement string. | from, pattern, to |
gsub(from, pattern, to) |
gt |
Checks if the first value is greater than the second value. | value1, value2 |
gt(value1, value2) |
gte |
Checks if the first value is greater than or equal to the second value. | value1, value2 |
gte(value1, value2) |
halt |
Terminates the program with the given exit code. | exit_code |
halt(exit_code) |
halt_error |
Halts execution with error code 5 | halt_error() |
|
has |
Checks if a dict has the given key, or an array has an element at the given index. | v, key |
has(v, key) |
html_escape |
Escapes `&`, `<`, `>`, `"`, and `'` in the given string as HTML entities. | string |
html_escape(string) |
html_unescape |
Decodes named and numeric HTML entities in the given string into their corresponding characters. | string |
html_unescape(string) |
http_delete |
Performs an HTTPS DELETE request, optionally with the given headers (a dict of string to string), and returns the response body as a string | url, headers |
http_delete(url, headers) |
http_delete_json |
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 | url, headers |
http_delete_json(url, headers) |
http_get |
Performs an HTTPS GET request, optionally with the given headers (a dict of string to string), and returns the response body as a string | url, headers |
http_get(url, headers) |
http_get_json |
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 | url, headers |
http_get_json(url, headers) |
http_head |
Performs an HTTPS HEAD request, optionally with the given headers (a dict of string to string), and returns the response body as a string | url, headers |
http_head(url, headers) |
http_patch |
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 | url, body, headers |
http_patch(url, body, headers) |
http_patch_json |
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 | url, body, headers |
http_patch_json(url, body, headers) |
http_post |
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 | url, body, headers |
http_post(url, body, headers) |
http_post_json |
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 | url, body, headers |
http_post_json(url, body, headers) |
http_put |
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 | url, body, headers |
http_put(url, body, headers) |
http_put_json |
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 | url, body, headers |
http_put_json(url, body, headers) |
identity |
Returns the input value unchanged. | x |
identity(x) |
implode |
Joins an array of characters into a string. | array |
implode(array) |
in |
Returns true if the element is in the array. | v, elem |
in(v, elem) |
increase_header_depth |
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. | node |
increase_header_depth(node) |
increase_header_level |
Deprecated: use `increase_header_depth` or `demote_heading` instead. Kept for backward compatibility; behavior unchanged. | node |
increase_header_level(node) |
index |
Finds the first occurrence of a substring or byte subsequence. Returns -1 if not found. | value, needle |
index(value, needle) |
index_by |
Creates a dictionary indexed by a key extracted from each element. | arr, f |
index_by(arr, f) |
infinite |
Returns an infinite number value. | infinite() |
|
input |
Reads a line from standard input and returns it as a string. | input() |
|
insert |
Inserts a value into an array or string at the specified index, or into a dict with the specified key. | target, index_or_key, value |
insert(target, index_or_key, value) |
inspect |
Inspects a value by printing its string representation and returning the value. | value |
inspect(value) |
intern |
Interns the given string, returning a canonical reference for efficient comparison. | string |
intern(string) |
is_array |
Checks if input is an array | a |
is_array(a) |
is_bool |
Checks if input is a boolean | b |
is_bool(b) |
is_bytes |
Checks if input is bytes | b |
is_bytes(b) |
is_callout |
Checks if markdown is a callout block | md |
is_callout(md) |
is_code |
Checks if markdown is code block | md |
is_code(md) |
is_debug_mode |
Checks if the runtime is currently in debug mode, returning true if a debugger is attached. | is_debug_mode() |
|
is_dict |
Checks if input is a dictionary | d |
is_dict(d) |
is_em |
Checks if markdown is emphasis | md |
is_em(md) |
is_empty |
Checks if string, array or dict is empty | s |
is_empty(s) |
is_h |
Checks if markdown is heading | md |
is_h(md) |
is_h1 |
Checks if markdown is h1 heading | md |
is_h1(md) |
is_h2 |
Checks if markdown is h2 heading | md |
is_h2(md) |
is_h3 |
Checks if markdown is h3 heading | md |
is_h3(md) |
is_h4 |
Checks if markdown is h4 heading | md |
is_h4(md) |
is_h5 |
Checks if markdown is h5 heading | md |
is_h5(md) |
is_h6 |
Checks if markdown is h6 heading | md |
is_h6(md) |
is_h_level |
Checks if markdown is a heading of the specified level (1-6) | md, level |
is_h_level(md, level) |
is_html |
Checks if markdown is html | md |
is_html(md) |
is_list |
Checks if markdown is list | list |
is_list(list) |
is_markdown |
Checks if input is markdown | m |
is_markdown(m) |
is_mdx |
Checks if markdown is MDX | mdx |
is_mdx(mdx) |
is_mdx_flow_expression |
Checks if markdown is MDX Flow Expression | mdx |
is_mdx_flow_expression(mdx) |
is_mdx_js_esm |
Checks if markdown is MDX Js Esm | mdx |
is_mdx_js_esm(mdx) |
is_mdx_jsx_flow_element |
Checks if markdown is MDX Jsx Flow Element | mdx |
is_mdx_jsx_flow_element(mdx) |
is_mdx_jsx_text_element |
Checks if markdown is MDX Jsx Text Element | mdx |
is_mdx_jsx_text_element(mdx) |
is_mdx_text_expression |
Checks if markdown is MDX Text Expression | mdx |
is_mdx_text_expression(mdx) |
is_none |
Checks if input is None | n |
is_none(n) |
is_not_regex_match |
Checks if the given pattern does not match the string. | string, pattern |
is_not_regex_match(string, pattern) |
is_number |
Checks if input is a number | n |
is_number(n) |
is_regex_match |
Checks if the given pattern matches the string. | string, pattern |
is_regex_match(string, pattern) |
is_string |
Checks if input is a string | s |
is_string(s) |
is_table_align |
Checks if markdown is table align | md |
is_table_align(md) |
is_table_cell |
Checks if markdown is table cell | md |
is_table_cell(md) |
is_text |
Checks if markdown is text | text |
is_text(text) |
is_toml |
Checks if markdown is toml | md |
is_toml(md) |
is_yaml |
Checks if markdown is yaml | md |
is_yaml(md) |
iterables |
Returns the value if it is an array or dict (i.e. a container that can be iterated over), None otherwise | v |
iterables(v) |
join |
Joins the elements of an array into a string with the given separator. | array, separator |
join(array, separator) |
juxt |
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)]`. | fns |
juxt(fns) |
keys |
Returns an array of keys from the dict. | dict |
keys(dict) |
last |
Returns the last element of an array | arr |
last(arr) |
len |
Returns the length of the given string or array. | value |
len(value) |
lines |
Returns the lines of a string as an array by splitting on newline characters. | s |
lines(s) |
ln |
Returns the natural logarithm (base e) of the given number. | number |
ln(number) |
load_markdown |
Loads a markdown file from the specified path | path |
load_markdown(path) |
localtime |
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)]. | timestamp |
localtime(timestamp) |
log10 |
Returns the base-10 logarithm of the given number. | number |
log10(number) |
lpad |
Left-pads a string to a specified length using a given padding string. | s, length, pad_str |
lpad(s, length, pad_str) |
lt |
Checks if the first value is less than the second value. | value1, value2 |
lt(value1, value2) |
lte |
Checks if the first value is less than or equal to the second value. | value1, value2 |
lte(value1, value2) |
ltrim |
Trims whitespace from the left end of the given string. | input |
ltrim(input) |
ltrimstr |
Removes prefix string from input if it exists | s, left |
ltrimstr(s, left) |
map |
Applies a given function to each element of the provided array and returns a new array with the results. | v, f |
map(v, f) |
markdowns |
Returns markdown if input is markdown, None otherwise | m |
markdowns(m) |
matches_url |
Checks if markdown node's URL matches a specified URL deprecated: use select(.link.url == url) instead | node, url |
matches_url(node, url) |
max |
Returns the maximum of two values. | value1, value2 |
max(value1, value2) |
max_by |
Returns the maximum element in an array based on a provided function that extracts a comparable value from each element. | arr, f |
max_by(arr, f) |
md5 |
Computes the MD5 hash of a string or bytes and returns a lowercase hex string. | input |
md5(input) |
mean |
Returns the average (mean) of an array of numbers, or None if the array is empty. | arr |
mean(arr) |
min |
Returns the minimum of two values. | value1, value2 |
min(value1, value2) |
min_by |
Returns the minimum element in an array based on a provided function that extracts a comparable value from each element. | arr, f |
min_by(arr, f) |
mktime |
Converts broken-down UTC time array [year, mon (0-11), mday, hour, min, sec, wday, yday] to Unix timestamp (seconds since epoch). | time_array |
mktime(time_array) |
mod |
Calculates the remainder of the division of the first value by the second value. | value1, value2 |
mod(value1, value2) |
mul |
Multiplies two values. | value1, value2 |
mul(value1, value2) |
nan |
Returns a Not-a-Number (NaN) value. | nan() |
|
ne |
Checks if two values are not equal. | value1, value2 |
ne(value1, value2) |
negate |
Returns the negation of the given number. | number |
negate(number) |
ngram |
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. | s, n |
ngram(s, n) |
nones |
Returns the value if it is None, None otherwise | n |
nones(n) |
not |
Performs a logical NOT operation on a boolean value. | value |
not(value) |
now |
Returns the current timestamp. | now() |
|
numbers |
Returns number if input is number, None otherwise | n |
numbers(n) |
omit |
Returns a new dictionary excluding the specified keys from the original dictionary. | d, keys |
omit(d, keys) |
or |
Performs a logical OR operation on two boolean values. | value1, value2 |
or(value1, value2) |
pack |
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. | format, value |
pack(format, value) |
partial |
Creates a new function by partially applying the given arguments to the specified function. | function, arg1, arg2, ... |
partial(function, arg1, arg2, ...) |
partition |
Splits an array into two arrays: [matching, not_matching] based on a condition. | arr, f |
partition(arr, f) |
path_join |
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"). | base, component |
path_join(base, component) |
paths |
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. | value |
paths(value) |
percentile |
Calculates the p-th percentile of an array of numbers using linear interpolation between closest ranks. | arr, p |
percentile(arr, p) |
pick |
Returns a new dictionary containing only the specified keys from the original dictionary, if they exist. | d, keys |
pick(d, keys) |
pluck |
Extracts values from an array of objects based on a specified selector. | pluck_obj, selector |
pluck(pluck_obj, selector) |
pow |
Raises the base to the power of the exponent. | base, exponent |
pow(base, exponent) |
print |
Prints a message to standard output and returns the current value. | message |
print(message) |
promote_heading |
Promotes a markdown heading by decreasing its depth (numeric level) by one. This is an alias for `decrease_header_depth`. | node |
promote_heading(node) |
rand |
Generates a pseudo-random number in the range [0, 1). Not cryptographically secure. | rand() |
|
rand_int |
Generates a pseudo-random integer uniformly distributed in [min, max] (inclusive). Not cryptographically secure. | min, max |
rand_int(min, max) |
random_string |
Generates a random string of `len` characters, each independently chosen (with replacement) from `charset`. Not cryptographically secure. | len, charset |
random_string(len, charset) |
range |
Creates an array from start to end with an optional step. | start, end, step |
range(start, end, step) |
read_file |
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. | path |
read_file(path) |
read_file_bytes |
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. | path |
read_file_bytes(path) |
regex_match |
Finds all matches of the given pattern in the string. | string, pattern |
regex_match(string, pattern) |
reject |
Filters out elements that match the condition (opposite of filter). | arr, f |
reject(arr, f) |
repeat |
Repeats the given string a specified number of times. | string, count |
repeat(string, count) |
replace |
Replaces all occurrences of a substring with another substring. | from, pattern, to |
replace(from, pattern, to) |
reverse |
Reverses the given string or array. | value |
reverse(value) |
rindex |
Finds the last occurrence of a substring or byte subsequence. Returns -1 if not found. | value, needle |
rindex(value, needle) |
round |
Rounds the given number to the nearest integer. | number |
round(number) |
rpad |
Right-pads a string to a specified length using a given padding string. | s, length, pad_str |
rpad(s, length, pad_str) |
rtrim |
Trims whitespace from the right end of the given string. | input |
rtrim(input) |
rtrimstr |
Removes suffix string from input if it exists | s, right |
rtrimstr(s, right) |
sample |
Returns n elements sampled from the array without replacement, in random order. Errors if n exceeds the array length. | array, n |
sample(array, n) |
sanitize_html |
Sanitizes the given HTML string using an allowlist of safe tags and attributes, removing scripts and other XSS vectors. | html |
sanitize_html(html) |
scalars |
Returns the value if it is not an array or dict (i.e. a leaf/scalar value), None otherwise | v |
scalars(v) |
scan |
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. | string, pattern |
scan(string, pattern) |
second |
Returns the second element of an array | arr |
second(arr) |
select |
Returns value if condition is true, None otherwise | v, f |
select(v, f) |
set |
Sets a key-value pair in a dict. If the key exists, its value is updated. Returns the modified map. | obj, key, value |
set(obj, key, value) |
set_attr |
Sets the value of the specified attribute on a markdown node. | markdown, attribute, value |
set_attr(markdown, attribute, value) |
set_check |
Creates a markdown list node with the given checked state. | list, checked |
set_check(list, checked) |
set_children |
Sets the children nodes of a markdown node. Nodes without children (e.g. text, code) are left unchanged. | markdown, children |
set_children(markdown, children) |
set_code_block_lang |
Sets the language of a markdown code block node. | code_block, language |
set_code_block_lang(code_block, language) |
set_list_ordered |
Sets the ordered property of a markdown list node. | list, ordered |
set_list_ordered(list, ordered) |
set_path |
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. | value, path, new_value |
set_path(value, path, new_value) |
set_ref |
Sets the reference identifier for markdown nodes that support references (e.g., Definition, LinkRef, ImageRef, Footnote, FootnoteRef). | node, reference_id |
set_ref(node, reference_id) |
set_variable |
Sets a symbol or variable in the current environment with the given value. | symbol_or_string, value |
set_variable(symbol_or_string, value) |
sha256 |
Computes the SHA-256 hash of a string or bytes and returns a lowercase hex string. | input |
sha256(input) |
sha512 |
Computes the SHA-512 hash of a string or bytes and returns a lowercase hex string. | input |
sha512(input) |
shift_left |
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. | value, shift_amount |
shift_left(value, shift_amount) |
shift_right |
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. | value, shift_amount |
shift_right(value, shift_amount) |
shuffle |
Returns a new array containing the same elements as the input, in a uniformly random order. | array |
shuffle(array) |
skip |
Skips the first n elements of an array and returns the rest | arr, n |
skip(arr, n) |
skip_while |
Skips elements from the beginning of an array while the provided function returns true | arr, f |
skip_while(arr, f) |
slice |
Extracts a substring from the given string. | string, start, end |
slice(string, start, end) |
slugify |
Converts a string into a URL-friendly slug by lowercasing, replacing non-alphanumeric characters with hyphens, and trimming hyphens from the ends. | s, separator |
slugify(s, separator) |
sort |
Sorts the elements of the given array. | array |
sort(array) |
sort_by |
Sorts an array using a key function that extracts a comparable value for each element. | arr, f |
sort_by(arr, f) |
split |
Splits the given string by the specified separator. | string, separator |
split(string, separator) |
sqrt |
Returns the square root of the given number. | number |
sqrt(number) |
starts_with |
Checks if the given string or byte array starts with the specified prefix. | value, prefix |
starts_with(value, prefix) |
stderr |
Prints a message to standard error and returns the current value. | message |
stderr(message) |
stem |
Returns the file name without the extension (e.g. "file" from "/a/b/file.txt"). | path |
stem(path) |
strftime |
Formats a Unix timestamp (seconds) as a date string using the given strftime format (e.g. "%Y-%m-%d"). | timestamp, format |
strftime(timestamp, format) |
strings |
Returns string if input is string, None otherwise | s |
strings(s) |
strip_tags |
Removes HTML tags from the given string, keeping the surrounding text content. | string |
strip_tags(string) |
sub |
Subtracts the second value from the first value. | value1, value2 |
sub(value1, value2) |
sum |
Returns the sum of the elements in an array after applying a transformation function to each element. | arr |
sum(arr) |
sum_by |
Sums elements of an array after applying a transformation function. | arr, f |
sum_by(arr, f) |
take |
Takes the first n elements of an array | arr, n |
take(arr, n) |
take_while |
Takes elements from the beginning of an array while the provided function returns true | arr, f |
take_while(arr, f) |
tally |
Counts occurrences of each element in an array, returning a dict of `{value: count}`. | arr |
tally(arr) |
tap |
Applies a function to a value and returns the value (useful for debugging or side effects). | tap_value, tap_expr |
tap(tap_value, tap_expr) |
test |
Tests if string matches a pattern | s, pattern |
test(s, pattern) |
times |
Executes an expression n times and returns an array of results. | t_n, t_expr |
times(t_n, t_expr) |
to_array |
Converts the given value to an array. | value |
to_array(value) |
to_blockquote |
Creates a markdown blockquote node with the given value. | value |
to_blockquote(value) |
to_boolean |
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. | value |
to_boolean(value) |
to_bytes |
Converts a string (UTF-8), array of numbers, or bytes to raw bytes. | value |
to_bytes(value) |
to_callout |
Creates a markdown callout node with the given value, kind, and title. | value, kind, title |
to_callout(value, kind, title) |
to_code |
Creates a markdown code block with the given value and language. | value, language |
to_code(value, language) |
to_code_inline |
Creates an inline markdown code node with the given value. | value |
to_code_inline(value) |
to_date |
Converts a timestamp to a date string with the given format. | timestamp, format |
to_date(timestamp, format) |
to_date_iso8601 |
Formats a date to ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ) | d |
to_date_iso8601(d) |
to_delete |
Creates a markdown delete (strikethrough) node with the given value. | value |
to_delete(value) |
to_em |
Creates a markdown emphasis (italic) node with the given value. | value |
to_em(value) |
to_front_matter |
Converts a data structure to a YAML front matter string. deprecated: use to_frontmatter instead | data |
to_front_matter(data) |
to_frontmatter |
Converts a data structure to a YAML front matter string. | data |
to_frontmatter(data) |
to_h |
Creates a markdown heading node with the given value and depth. | value, depth |
to_h(value, depth) |
to_hex |
Encodes raw bytes as a lowercase hex string. | bytes |
to_hex(bytes) |
to_hr |
Creates a markdown horizontal rule node. | to_hr() |
|
to_html |
Converts the given markdown string to HTML. | markdown |
to_html(markdown) |
to_image |
Creates a markdown image node with the given URL, alt text, and title. | url, alt, title |
to_image(url, alt, title) |
to_link |
Creates a markdown link node with the given url and title. | url, value, title |
to_link(url, value, title) |
to_markdown |
Parses a markdown string and returns an array of markdown nodes. | markdown_string |
to_markdown(markdown_string) |
to_markdown_string |
Converts the given value(s) to a markdown string representation. | value |
to_markdown_string(value) |
to_math |
Creates a markdown math block with the given value. | value |
to_math(value) |
to_math_inline |
Creates an inline markdown math node with the given value. | value |
to_math_inline(value) |
to_md_fragment |
Creates a markdown fragment node that groups an array of markdown nodes into a single value. | values |
to_md_fragment(values) |
to_md_list |
Creates a markdown list node with the given value and indent level. | value, indent |
to_md_list(value, indent) |
to_md_name |
Returns the name of the given markdown node. | markdown |
to_md_name(markdown) |
to_md_table_align |
Creates a markdown table alignment row node from an array of alignments ("left", "right", "center", "none"). | aligns |
to_md_table_align(aligns) |
to_md_table_cell |
Creates a markdown table cell node with the given value at the specified row and column. | value, row, column |
to_md_table_cell(value, row, column) |
to_md_table_row |
Creates a markdown table row node with the given values. | cells |
to_md_table_row(cells) |
to_md_text |
Creates a markdown text node with the given value. | value |
to_md_text(value) |
to_mdx |
Parses an MDX string and returns an array of MDX nodes. | mdx_string |
to_mdx(mdx_string) |
to_number |
Converts the given value to a number. | value |
to_number(value) |
to_string |
Converts the given value to a string. | value |
to_string(value) |
to_strong |
Creates a markdown strong (bold) node with the given value. | value |
to_strong(value) |
to_text |
Converts the given markdown node to plain text. | markdown |
to_text(markdown) |
token_count |
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. | text, model? |
token_count(text, model?) |
toml_parse |
Parses a TOML string and returns the parsed data structure. | input |
toml_parse(input) |
toml_stringify |
Converts a data structure to a TOML string representation. | data |
toml_stringify(data) |
toml_to_json |
Converts a data structure to a JSON string representation. | data |
toml_to_json(data) |
toml_to_markdown_table |
Converts a TOML data structure to a Markdown table. | data |
toml_to_markdown_table(data) |
transpose |
Transposes a 2D array (matrix), swapping rows and columns. | matrix |
transpose(matrix) |
trim |
Trims whitespace from both ends of the given string. | input |
trim(input) |
trunc |
Truncates the given number to an integer by removing the fractional part. | number |
trunc(number) |
truncate |
Truncates the given string to the specified display width, appending the ellipsis string when truncated (CJK and other wide characters count as two columns). | string, width, ellipsis |
truncate(string, width, ellipsis) |
type |
Returns the type of the given value. | value |
type(value) |
uniq |
Removes duplicate elements from the given array. | array |
uniq(array) |
unique_by |
Returns a new array with duplicate elements removed, comparing by the result of the provided function. | arr, f |
unique_by(arr, f) |
unless |
Executes the expression only if the condition is false. | unless_cond, unless_expr |
unless(unless_cond, unless_expr) |
unlines |
Joins an array of strings into a single string with newline characters between them. | arr |
unlines(arr) |
unpack |
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. | format, bytes |
unpack(format, bytes) |
until |
Executes the expression repeatedly until the condition is true. | until_cond, until_expr |
until(until_cond, until_expr) |
upcase |
Converts the given string to uppercase. | input |
upcase(input) |
update |
Update the value with specified value. | target_value, source_value |
update(target_value, source_value) |
url_decode |
URL-decodes the given string. | input |
url_decode(input) |
url_encode |
URL-encodes the given string. | input |
url_encode(input) |
utf8 |
Decodes bytes as a UTF-8 string, returning an error if the bytes are not valid UTF-8. | bytes |
utf8(bytes) |
uuid |
Generates a random (version 4, RFC 4122) UUID string. | uuid() |
|
uuid_v4 |
Generates a random (version 4, RFC 4122) UUID string. Alias of `uuid`. | uuid_v4() |
|
uuid_v7 |
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. | uuid_v7() |
|
values |
Returns an array of values from the dict. | dict |
values(dict) |
walk |
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. | v, f |
walk(v, f) |
with_entries |
Transforms each [key, value] pair of a dict by applying the given function, then rebuilds a dict from the resulting pairs. | d, f |
with_entries(d, f) |
word_wrap |
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). | string, width |
word_wrap(string, width) |
write_file |
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. | path, content |
write_file(path, content) |
xor |
Computes the bitwise XOR of two byte arrays of equal length. | bytes1, bytes2 |
xor(bytes1, bytes2) |
yaml_parse |
Parses a YAML string and returns the parsed data structure. | input |
yaml_parse(input) |
yaml_stringify |
Converts a data structure to a YAML string representation. | data |
yaml_stringify(data) |
yaml_to_json |
Converts a data structure to a JSON string representation. | data |
yaml_to_json(data) |
yaml_to_markdown_table |
Converts a YAML data structure to a Markdown table. | data |
yaml_to_markdown_table(data) |
zip |
Combines two arrays into an array of pairs, where each pair contains elements from the same index in both arrays. | arr1, arr2 |
zip(arr1, arr2) |
get_args |
Gets the arguments of an AST node | node |
get_args(node) |
to_code |
Converts an AST node back to code | node |
to_code(node) |
cbor_parse |
CBOR Implementation in mq Parses a base64-encoded CBOR string (or raw bytes) and returns the corresponding data structure. | input |
cbor_parse(input) |
cbor_stringify |
Serializes a value to CBOR bytes. | data |
cbor_stringify(data) |
csv_needs_quote |
CSV/TSV Implementation in mq Based on RFC 4180 for CSV format | field, delimiter |
csv_needs_quote(field, delimiter) |
csv_parse |
Parses CSV content using a comma as the delimiter. | input, has_header |
csv_parse(input, has_header) |
csv_parse_with_delimiter |
Parses CSV content with a specified delimiter and optional header row. | input, delimiter, has_header |
csv_parse_with_delimiter(input, delimiter, has_header) |
csv_stringify |
Converts data to a CSV string with a specified delimiter. | data, delimiter |
csv_stringify(data, delimiter) |
csv_to_json |
Converts CSV data to a JSON string. | data |
csv_to_json(data) |
csv_to_markdown_table |
Converts CSV data to a Markdown table format. | data |
csv_to_markdown_table(data) |
psv_parse |
Parses PSV (Pipe-Separated Values) content. | input, has_header |
psv_parse(input, has_header) |
tsv_parse |
Parses TSV (Tab-Separated Values) content. | input, has_header |
tsv_parse(input, has_header) |
fuzzy_best_match |
Finds the best fuzzy match from candidates. | candidates, query |
fuzzy_best_match(candidates, query) |
fuzzy_filter |
Filters candidates by minimum fuzzy match score using Jaro-Winkler. | candidates, query, threshold |
fuzzy_filter(candidates, query, threshold) |
fuzzy_match |
Performs fuzzy matching on an array of strings using Jaro-Winkler distance. | candidates, query |
fuzzy_match(candidates, query) |
fuzzy_match_jaro |
Performs fuzzy matching using Jaro distance. | candidates, query |
fuzzy_match_jaro(candidates, query) |
fuzzy_match_levenshtein |
Performs fuzzy matching using Levenshtein distance. | candidates, query |
fuzzy_match_levenshtein(candidates, query) |
jaro |
Calculates the Jaro distance between two strings (0.0 to 1.0, where 1.0 is exact match). | s1, s2 |
jaro(s1, s2) |
jaro_winkler |
Calculates the Jaro-Winkler distance between two strings. | s1, s2 |
jaro_winkler(s1, s2) |
levenshtein |
Calculates the Levenshtein distance between two strings. | s1, s2 |
levenshtein(s1, s2) |
json_parse |
JSON Implementation in mq Parses a JSON string and returns the corresponding data structure. | input |
json_parse(input) |
json_stringify |
Serializes a value to a JSON string. | data |
json_stringify(data) |
json_to_markdown_table |
Converts a JSON data structure to a Markdown table. | data |
json_to_markdown_table(data) |
all_nodes |
Returns all nodes of a section, including both the header and content. | section |
all_nodes(section) |
bodies |
Extracts body from all sections. | sections |
bodies(sections) |
body |
Returns the body of a section (all nodes except the header). | section |
body(section) |
by_level |
Filters sections by heading level. l can be a number (exact level) or a range array (e.g. 1..2). | sections, l |
by_level(sections, l) |
collect |
Flattens sections back to markdown nodes for output. This converts section objects back to their original markdown node arrays. | sections |
collect(sections) |
content |
Returns the content of a section (all nodes except the header). Deprecated: Use body() instead, as content() | section |
content(section) |
filter_sections |
Filters sections based on a given predicate function. | md_nodes, predicate |
filter_sections(md_nodes, predicate) |
has_content |
Checks if a section has any content beyond the header. | section |
has_content(section) |
level |
Returns the header level (1-6) of a section. | section |
level(section) |
map_sections |
Maps sections using a given mapper function. | md_nodes, mapper |
map_sections(md_nodes, mapper) |
nth |
Returns the nth section from an array of sections (0-indexed). | sections, n |
nth(sections, n) |
section |
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. | md_nodes, pattern, depth |
section(md_nodes, pattern, depth) |
sections |
Splits markdown nodes into sections based on headers. | md_nodes |
sections(md_nodes) |
split |
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. | md_nodes, level |
split(md_nodes, level) |
title |
Returns the title text of a section (header text without the # symbols). | section |
title(section) |
title_contains |
Filters the given list of sections, returning only those whose title contains the specified text. | sections, text |
title_contains(sections, text) |
title_match |
Filters sections by a pattern match in the title text. | sections, pattern |
title_match(sections, pattern) |
titles |
Extracts titles from all sections. | sections |
titles(sections) |
toc |
Generates a table of contents from sections. | sections |
toc(sections) |
semver_bump_major |
Increments the major version and resets minor, patch, and pre-release. | v |
semver_bump_major(v) |
semver_bump_minor |
Increments the minor version and resets patch and pre-release. | v |
semver_bump_minor(v) |
semver_bump_patch |
Increments the patch version and clears pre-release. | v |
semver_bump_patch(v) |
semver_compare |
Compares two parsed SemVer dicts. Returns -1 if a < b, 0 if a == b, 1 if a > b. | a, b |
semver_compare(a, b) |
semver_eq |
Returns true if version a equals version b (ignoring build metadata). | a, b |
semver_eq(a, b) |
semver_gt |
Returns true if version a is greater than version b. | a, b |
semver_gt(a, b) |
semver_gte |
Returns true if version a is greater than or equal to version b. | a, b |
semver_gte(a, b) |
semver_lt |
Returns true if version a is less than version b. | a, b |
semver_lt(a, b) |
semver_lte |
Returns true if version a is less than or equal to version b. | a, b |
semver_lte(a, b) |
semver_max |
Returns the maximum version from an array of parsed SemVer dicts. | versions |
semver_max(versions) |
semver_min |
Returns the minimum version from an array of parsed SemVer dicts. | versions |
semver_min(versions) |
semver_parse |
Parses a SemVer string into a dict with major, minor, patch, pre, and build fields. | s |
semver_parse(s) |
semver_satisfies |
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 | version, range |
semver_satisfies(version, range) |
semver_sort |
Sorts an array of parsed SemVer dicts in ascending order. | versions |
semver_sort(versions) |
semver_to_string |
Converts a parsed SemVer dict back to a version string. | v |
semver_to_string(v) |
add_column |
Add a new column to a table. | table, col |
add_column(table, col) |
add_row |
Add a new row to a table. | table, row |
add_row(table, row) |
filter_rows |
Filter rows in the table based on a predicate function. | table, f |
filter_rows(table, f) |
filter_tables |
Filter tables from markdown nodes based on a predicate function. | tables, f |
filter_tables(tables, f) |
map_rows |
Map a function over each row in the table. | table, f |
map_rows(table, f) |
remove_column |
Remove a column from a table at the specified index. | table, col_index |
remove_column(table, col_index) |
remove_row |
Remove a row from a table at the specified index. | table, row_index |
remove_row(table, row_index) |
set_align |
Set the alignment for a table. | table, align |
set_align(table, align) |
sort_rows |
Sort rows in the table by a specified column index or default sorting. | table, column_index |
sort_rows(table, column_index) |
tables |
Extract table structures from a list of markdown nodes. | md_nodes |
tables(md_nodes) |
to_csv |
Convert a table structure into a CSV string with the specified delimiter. | table, delimiter |
to_csv(table, delimiter) |
to_markdown |
Convert a table structure back into a list of markdown nodes. | table |
to_markdown(table) |
assert |
Testing framework for mq A simple testing framework to execute test functions and output results Verifies that a condition is true and raises an error if it's false. | cond |
assert(cond) |
assert_contains |
Verifies that an array contains a specific value | array, value |
assert_contains(array, value) |
assert_empty |
Verifies that an array is empty | array |
assert_empty(array) |
assert_eq |
Verifies that two values are equal | actual, expected |
assert_eq(actual, expected) |
assert_false |
Verifies that a value is false | value |
assert_false(value) |
assert_len |
Verifies that an array has a specific length | array, expected_length |
assert_len(array, expected_length) |
assert_ne |
Verifies that two values are not equal | actual, expected |
assert_ne(actual, expected) |
assert_none |
Verifies that a value is None | value |
assert_none(value) |
assert_not_empty |
Verifies that an array is not empty | array |
assert_not_empty(array) |
assert_not_none |
Verifies that a value is not None | value |
assert_not_none(value) |
assert_true |
Verifies that a value is true | value |
assert_true(value) |
run_tests |
Executes multiple test functions | tests |
run_tests(tests) |
test_case |
Helper function to create a test case | name, func |
test_case(name, func) |
toml_parse |
Parses a TOML string and returns the parsed data structure. | input |
toml_parse(input) |
toml_stringify |
Converts a data structure to a TOML string representation. | data |
toml_stringify(data) |
toml_to_json |
Converts a data structure to a JSON string representation. | data |
toml_to_json(data) |
toml_to_markdown_table |
Converts a TOML data structure to a Markdown table. | data |
toml_to_markdown_table(data) |
toon_parse |
To parse a TOON string into a data structure | input |
toon_parse(input) |
toon_stringify |
To convert a data structure into a TOON string | data |
toon_stringify(data) |
xml_parse |
XML Implementation in mq Parses an XML string and returns the corresponding data structure. | input |
xml_parse(input) |
xml_stringify |
Serializes a value to an XML string. | data |
xml_stringify(data) |
xml_to_markdown_table |
Converts an XML data structure to a Markdown table. | data |
xml_to_markdown_table(data) |
to_front_matter |
Converts a data structure to a YAML front matter string. deprecated: use to_frontmatter instead | data |
to_front_matter(data) |
to_frontmatter |
Converts a data structure to a YAML front matter string. | data |
to_frontmatter(data) |
yaml_parse |
Parses a YAML string and returns the parsed data structure. | input |
yaml_parse(input) |
yaml_stringify |
Converts a data structure to a YAML string representation. | data |
yaml_stringify(data) |
yaml_to_json |
Converts a data structure to a JSON string representation. | data |
yaml_to_json(data) |
yaml_to_markdown_table |
Converts a YAML data structure to a Markdown table. | data |
yaml_to_markdown_table(data) |
329 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
abs |
Returns the absolute value of the given number. | number |
abs(number) |
add |
Adds two values. | value1, value2 |
add(value1, value2) |
all |
Returns true if all element in the array satisfies the provided function. | v, f |
all(v, f) |
all_symbols |
Returns an array of all interned symbols. | all_symbols() |
|
and |
Performs a logical AND operation on two boolean values. | value1, value2 |
and(value1, value2) |
any |
Returns true if any element in the array satisfies the provided function. | v, f |
any(v, f) |
array |
Creates an array from the given values. | values |
array(values) |
arrays |
Returns array if input is array, None otherwise | a |
arrays(a) |
ascii_downcase |
Converts ASCII uppercase letters (A-Z) in the given string to lowercase, leaving all other characters unchanged. | input |
ascii_downcase(input) |
ascii_upcase |
Converts ASCII lowercase letters (a-z) in the given string to uppercase, leaving all other characters unchanged. | input |
ascii_upcase(input) |
assert |
Asserts that two values are equal, returns the value if true, otherwise raises an error. | value1, value2 |
assert(value1, value2) |
attr |
Retrieves the value of the specified attribute from a markdown node. | markdown, attribute |
attr(markdown, attribute) |
band |
Computes the bitwise AND of two byte arrays of equal length. | bytes1, bytes2 |
band(bytes1, bytes2) |
base64 |
Encodes the given string to base64. | input |
base64(input) |
base64d |
Decodes the given base64 string. | input |
base64d(input) |
base64url |
Encodes the given string to URL-safe base64. | input |
base64url(input) |
base64urld |
Decodes the given URL-safe base64 string. | input |
base64urld(input) |
basename |
Returns the final component of a path string (e.g. "file.txt" from "/a/b/file.txt"). | path |
basename(path) |
between |
Checks if a value is between min and max (inclusive). | value, min, max |
between(value, min, max) |
bnot |
Computes the bitwise NOT (complement) of a byte array. | bytes |
bnot(bytes) |
booleans |
Returns boolean if input is boolean, None otherwise | b |
booleans(b) |
bor |
Computes the bitwise OR of two byte arrays of equal length. | bytes1, bytes2 |
bor(bytes1, bytes2) |
breakpoint |
Sets a breakpoint for debugging; execution will pause at this point if a debugger is attached. | breakpoint() |
|
bsearch |
Performs a binary search on a sorted array to find the index of the target value. | arr, target |
bsearch(arr, target) |
bytes |
Returns bytes if input is bytes, None otherwise | b |
bytes(b) |
capture |
Captures named groups from the given string based on the specified regular expression pattern and returns them as a dictionary keyed by group names. | string, pattern |
capture(string, pattern) |
ceil |
Rounds the given number up to the nearest integer. | number |
ceil(number) |
chunk_by |
Splits an array into chunks based on the result of applying a function to each element, grouping consecutive elements with the same key together. | v, f |
chunk_by(v, f) |
chunks |
Splits an array into chunks of a specified size, returning an array of arrays. | v, size |
chunks(v, size) |
coalesce |
Returns the first non-None value from the two provided arguments. | value1, value2 |
coalesce(value1, value2) |
collection |
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. Requires the --allow-read CLI flag; otherwise returns a runtime error. | dir |
collection(dir) |
comp |
Composes functions into one function, applying them right-to-left. `comp(f, g, h)(x)` is equivalent to `f(g(h(x)))`. | fns |
comp(fns) |
compact |
Removes None values from the given array. | array |
compact(array) |
compact_map |
Maps over an array and removes None values from the result. | arr, f |
compact_map(arr, f) |
complement |
Returns a new predicate function that negates the result of the given function. | f |
complement(f) |
contains |
Checks if string contains a substring | haystack, needle |
contains(haystack, needle) |
convert |
Converts the input value to the specified format. Supported formats: base64, html, text, uri, heading (#, ##, etc.), blockquote (>), list item (-), or link (URL). | input, format |
convert(input, format) |
count_by |
Returns the count of elements in the array that satisfy the provided function. | arr, f |
count_by(arr, f) |
date_add |
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. | array, n, unit |
date_add(array, n, unit) |
date_diff |
Returns the difference (array2 - array1) in the given unit. Units: "seconds", "minutes", "hours", "days", "weeks". | array1, array2, unit |
date_diff(array1, array2, unit) |
debug |
Prints the debug information of the given value(s). | args |
debug(args) |
decrease_header_depth |
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. | node |
decrease_header_depth(node) |
decrease_header_level |
Deprecated: use `decrease_header_depth` or `promote_heading` instead. Kept for backward compatibility; behavior unchanged. | node |
decrease_header_level(node) |
del |
Deletes the element at the specified index in the array or string. | array_or_string, index |
del(array_or_string, index) |
demote_heading |
Demotes a markdown heading by increasing its depth (numeric level) by one. This is an alias for `increase_header_depth`. | node |
demote_heading(node) |
dict |
Creates a new, empty dict. | dict() |
|
dicts |
Returns dict if input is dict, None otherwise | d |
dicts(d) |
dirname |
Returns the parent directory of a path string (e.g. "/a/b" from "/a/b/file.txt"). Returns "." if the path has no parent. | path |
dirname(path) |
div |
Divides the first value by the second value. | value1, value2 |
div(value1, value2) |
downcase |
Converts the given string to lowercase. | input |
downcase(input) |
each |
Executes a provided function once for each element in an array or each key-value pair in a dictionary. | v, f |
each(v, f) |
ends_with |
Checks if the given string or byte array ends with the specified suffix. | value, suffix |
ends_with(value, suffix) |
entries |
Returns an array of key-value pairs from the dict as arrays. | dict |
entries(dict) |
eq |
Checks if two values are equal. | value1, value2 |
eq(value1, value2) |
error |
Raises a user-defined error with the specified message. | message |
error(message) |
exp |
Returns the exponential (e^x) of the given number. | number |
exp(number) |
explode |
Splits the given string into an array of characters. | string |
explode(string) |
extname |
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. | path |
extname(path) |
file_exists |
Checks if a file exists at the given path. Requires the --allow-read CLI flag; otherwise returns a runtime error. | path |
file_exists(path) |
fill |
Returns an array of length n filled with the given value. | value, n |
fill(value, n) |
filter |
Filters the elements of an array based on a provided callback function. | v, f |
filter(v, f) |
find_index |
Returns the index of the first element in an array that satisfies the provided function. | arr, f |
find_index(arr, f) |
first |
Returns the first element of an array | arr |
first(arr) |
flat_map |
Applies a function to each element and flattens the result into a single array | v, f |
flat_map(v, f) |
flatten |
Flattens a nested array into a single level array. | array |
flatten(array) |
flip |
Returns a new function that takes the same arguments as the original function but with the first two arguments flipped. | f, a, b |
flip(f, a, b) |
floor |
Rounds the given number down to the nearest integer. | number |
floor(number) |
fold |
Reduces an array to a single value by applying a function, starting from an initial value. | arr, init, f |
fold(arr, init, f) |
frequencies_by |
Counts occurrences of each key extracted from the elements of an array, returning a dict of `{key: count}`. | arr, f |
frequencies_by(arr, f) |
from_date |
Converts a date string to a timestamp. | date_str |
from_date(date_str) |
from_entries |
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. | arr |
from_entries(arr) |
from_hex |
Parses a hex string into raw bytes. | hex_string |
from_hex(hex_string) |
from_html |
Converts the given HTML string to Markdown. | html |
from_html(html) |
frontmatter |
Parses frontmatter from a markdown node, supporting both YAML and TOML formats. | v |
frontmatter(v) |
geomean |
Returns the median of an array of numbers, or None if the array is empty. | arr |
geomean(arr) |
get |
Retrieves a value from a dict by its key. Returns None if the key is not found. | obj, key |
get(obj, key) |
get_or |
Safely gets a value from a dict with a default if the key doesn't exist. | dict, key, default |
get_or(dict, key, default) |
get_path |
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. | value, path |
get_path(value, path) |
get_title |
Returns the title of a markdown node. | node |
get_title(node) |
get_url |
Returns the url of a markdown node. | node |
get_url(node) |
get_variable |
Retrieves the value of a symbol or variable from the current environment. | symbol_or_string |
get_variable(symbol_or_string) |
glob_match |
Checks whether the given path matches the glob pattern (e.g. "*.md", "docs/**/*.rs"), commonly used to filter file lists. | pattern, path |
glob_match(pattern, path) |
gmtime |
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)]. | timestamp |
gmtime(timestamp) |
group_by |
Groups elements of an array by the result of applying a function to each element | arr, f |
group_by(arr, f) |
gsub |
Replaces all occurrences matching a regular expression pattern with the replacement string. | from, pattern, to |
gsub(from, pattern, to) |
gt |
Checks if the first value is greater than the second value. | value1, value2 |
gt(value1, value2) |
gte |
Checks if the first value is greater than or equal to the second value. | value1, value2 |
gte(value1, value2) |
halt |
Terminates the program with the given exit code. | exit_code |
halt(exit_code) |
halt_error |
Halts execution with error code 5 | halt_error() |
|
has |
Checks if a dict has the given key, or an array has an element at the given index. | v, key |
has(v, key) |
html_escape |
Escapes `&`, `<`, `>`, `"`, and `'` in the given string as HTML entities. | string |
html_escape(string) |
html_unescape |
Decodes named and numeric HTML entities in the given string into their corresponding characters. | string |
html_unescape(string) |
http_delete |
Performs an HTTPS DELETE request, optionally with the given headers (a dict of string to string), and returns the response body as a string | url, headers |
http_delete(url, headers) |
http_delete_json |
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 | url, headers |
http_delete_json(url, headers) |
http_get |
Performs an HTTPS GET request, optionally with the given headers (a dict of string to string), and returns the response body as a string | url, headers |
http_get(url, headers) |
http_get_json |
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 | url, headers |
http_get_json(url, headers) |
http_head |
Performs an HTTPS HEAD request, optionally with the given headers (a dict of string to string), and returns the response body as a string | url, headers |
http_head(url, headers) |
http_patch |
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 | url, body, headers |
http_patch(url, body, headers) |
http_patch_json |
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 | url, body, headers |
http_patch_json(url, body, headers) |
http_post |
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 | url, body, headers |
http_post(url, body, headers) |
http_post_json |
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 | url, body, headers |
http_post_json(url, body, headers) |
http_put |
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 | url, body, headers |
http_put(url, body, headers) |
http_put_json |
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 | url, body, headers |
http_put_json(url, body, headers) |
identity |
Returns the input value unchanged. | x |
identity(x) |
implode |
Joins an array of characters into a string. | array |
implode(array) |
in |
Returns true if the element is in the array. | v, elem |
in(v, elem) |
increase_header_depth |
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. | node |
increase_header_depth(node) |
increase_header_level |
Deprecated: use `increase_header_depth` or `demote_heading` instead. Kept for backward compatibility; behavior unchanged. | node |
increase_header_level(node) |
index |
Finds the first occurrence of a substring or byte subsequence. Returns -1 if not found. | value, needle |
index(value, needle) |
index_by |
Creates a dictionary indexed by a key extracted from each element. | arr, f |
index_by(arr, f) |
infinite |
Returns an infinite number value. | infinite() |
|
input |
Reads a line from standard input and returns it as a string. | input() |
|
insert |
Inserts a value into an array or string at the specified index, or into a dict with the specified key. | target, index_or_key, value |
insert(target, index_or_key, value) |
inspect |
Inspects a value by printing its string representation and returning the value. | value |
inspect(value) |
intern |
Interns the given string, returning a canonical reference for efficient comparison. | string |
intern(string) |
is_array |
Checks if input is an array | a |
is_array(a) |
is_bool |
Checks if input is a boolean | b |
is_bool(b) |
is_bytes |
Checks if input is bytes | b |
is_bytes(b) |
is_callout |
Checks if markdown is a callout block | md |
is_callout(md) |
is_code |
Checks if markdown is code block | md |
is_code(md) |
is_debug_mode |
Checks if the runtime is currently in debug mode, returning true if a debugger is attached. | is_debug_mode() |
|
is_dict |
Checks if input is a dictionary | d |
is_dict(d) |
is_em |
Checks if markdown is emphasis | md |
is_em(md) |
is_empty |
Checks if string, array or dict is empty | s |
is_empty(s) |
is_h |
Checks if markdown is heading | md |
is_h(md) |
is_h1 |
Checks if markdown is h1 heading | md |
is_h1(md) |
is_h2 |
Checks if markdown is h2 heading | md |
is_h2(md) |
is_h3 |
Checks if markdown is h3 heading | md |
is_h3(md) |
is_h4 |
Checks if markdown is h4 heading | md |
is_h4(md) |
is_h5 |
Checks if markdown is h5 heading | md |
is_h5(md) |
is_h6 |
Checks if markdown is h6 heading | md |
is_h6(md) |
is_h_level |
Checks if markdown is a heading of the specified level (1-6) | md, level |
is_h_level(md, level) |
is_html |
Checks if markdown is html | md |
is_html(md) |
is_list |
Checks if markdown is list | list |
is_list(list) |
is_markdown |
Checks if input is markdown | m |
is_markdown(m) |
is_mdx |
Checks if markdown is MDX | mdx |
is_mdx(mdx) |
is_mdx_flow_expression |
Checks if markdown is MDX Flow Expression | mdx |
is_mdx_flow_expression(mdx) |
is_mdx_js_esm |
Checks if markdown is MDX Js Esm | mdx |
is_mdx_js_esm(mdx) |
is_mdx_jsx_flow_element |
Checks if markdown is MDX Jsx Flow Element | mdx |
is_mdx_jsx_flow_element(mdx) |
is_mdx_jsx_text_element |
Checks if markdown is MDX Jsx Text Element | mdx |
is_mdx_jsx_text_element(mdx) |
is_mdx_text_expression |
Checks if markdown is MDX Text Expression | mdx |
is_mdx_text_expression(mdx) |
is_none |
Checks if input is None | n |
is_none(n) |
is_not_regex_match |
Checks if the given pattern does not match the string. | string, pattern |
is_not_regex_match(string, pattern) |
is_number |
Checks if input is a number | n |
is_number(n) |
is_regex_match |
Checks if the given pattern matches the string. | string, pattern |
is_regex_match(string, pattern) |
is_string |
Checks if input is a string | s |
is_string(s) |
is_table_align |
Checks if markdown is table align | md |
is_table_align(md) |
is_table_cell |
Checks if markdown is table cell | md |
is_table_cell(md) |
is_text |
Checks if markdown is text | text |
is_text(text) |
is_toml |
Checks if markdown is toml | md |
is_toml(md) |
is_yaml |
Checks if markdown is yaml | md |
is_yaml(md) |
iterables |
Returns the value if it is an array or dict (i.e. a container that can be iterated over), None otherwise | v |
iterables(v) |
join |
Joins the elements of an array into a string with the given separator. | array, separator |
join(array, separator) |
juxt |
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)]`. | fns |
juxt(fns) |
keys |
Returns an array of keys from the dict. | dict |
keys(dict) |
last |
Returns the last element of an array | arr |
last(arr) |
len |
Returns the length of the given string or array. | value |
len(value) |
lines |
Returns the lines of a string as an array by splitting on newline characters. | s |
lines(s) |
ln |
Returns the natural logarithm (base e) of the given number. | number |
ln(number) |
load_markdown |
Loads a markdown file from the specified path | path |
load_markdown(path) |
localtime |
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)]. | timestamp |
localtime(timestamp) |
log10 |
Returns the base-10 logarithm of the given number. | number |
log10(number) |
lpad |
Left-pads a string to a specified length using a given padding string. | s, length, pad_str |
lpad(s, length, pad_str) |
lt |
Checks if the first value is less than the second value. | value1, value2 |
lt(value1, value2) |
lte |
Checks if the first value is less than or equal to the second value. | value1, value2 |
lte(value1, value2) |
ltrim |
Trims whitespace from the left end of the given string. | input |
ltrim(input) |
ltrimstr |
Removes prefix string from input if it exists | s, left |
ltrimstr(s, left) |
map |
Applies a given function to each element of the provided array and returns a new array with the results. | v, f |
map(v, f) |
markdowns |
Returns markdown if input is markdown, None otherwise | m |
markdowns(m) |
matches_url |
Checks if markdown node's URL matches a specified URL deprecated: use select(.link.url == url) instead | node, url |
matches_url(node, url) |
max |
Returns the maximum of two values. | value1, value2 |
max(value1, value2) |
max_by |
Returns the maximum element in an array based on a provided function that extracts a comparable value from each element. | arr, f |
max_by(arr, f) |
md5 |
Computes the MD5 hash of a string or bytes and returns a lowercase hex string. | input |
md5(input) |
mean |
Returns the average (mean) of an array of numbers, or None if the array is empty. | arr |
mean(arr) |
min |
Returns the minimum of two values. | value1, value2 |
min(value1, value2) |
min_by |
Returns the minimum element in an array based on a provided function that extracts a comparable value from each element. | arr, f |
min_by(arr, f) |
mktime |
Converts broken-down UTC time array [year, mon (0-11), mday, hour, min, sec, wday, yday] to Unix timestamp (seconds since epoch). | time_array |
mktime(time_array) |
mod |
Calculates the remainder of the division of the first value by the second value. | value1, value2 |
mod(value1, value2) |
mul |
Multiplies two values. | value1, value2 |
mul(value1, value2) |
nan |
Returns a Not-a-Number (NaN) value. | nan() |
|
ne |
Checks if two values are not equal. | value1, value2 |
ne(value1, value2) |
negate |
Returns the negation of the given number. | number |
negate(number) |
ngram |
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. | s, n |
ngram(s, n) |
nones |
Returns the value if it is None, None otherwise | n |
nones(n) |
not |
Performs a logical NOT operation on a boolean value. | value |
not(value) |
now |
Returns the current timestamp. | now() |
|
numbers |
Returns number if input is number, None otherwise | n |
numbers(n) |
omit |
Returns a new dictionary excluding the specified keys from the original dictionary. | d, keys |
omit(d, keys) |
or |
Performs a logical OR operation on two boolean values. | value1, value2 |
or(value1, value2) |
pack |
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. | format, value |
pack(format, value) |
partial |
Creates a new function by partially applying the given arguments to the specified function. | function, arg1, arg2, ... |
partial(function, arg1, arg2, ...) |
partition |
Splits an array into two arrays: [matching, not_matching] based on a condition. | arr, f |
partition(arr, f) |
path_join |
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"). | base, component |
path_join(base, component) |
paths |
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. | value |
paths(value) |
percentile |
Calculates the p-th percentile of an array of numbers using linear interpolation between closest ranks. | arr, p |
percentile(arr, p) |
pick |
Returns a new dictionary containing only the specified keys from the original dictionary, if they exist. | d, keys |
pick(d, keys) |
pluck |
Extracts values from an array of objects based on a specified selector. | pluck_obj, selector |
pluck(pluck_obj, selector) |
pow |
Raises the base to the power of the exponent. | base, exponent |
pow(base, exponent) |
print |
Prints a message to standard output and returns the current value. | message |
print(message) |
promote_heading |
Promotes a markdown heading by decreasing its depth (numeric level) by one. This is an alias for `decrease_header_depth`. | node |
promote_heading(node) |
rand |
Generates a pseudo-random number in the range [0, 1). Not cryptographically secure. | rand() |
|
rand_int |
Generates a pseudo-random integer uniformly distributed in [min, max] (inclusive). Not cryptographically secure. | min, max |
rand_int(min, max) |
random_string |
Generates a random string of `len` characters, each independently chosen (with replacement) from `charset`. Not cryptographically secure. | len, charset |
random_string(len, charset) |
range |
Creates an array from start to end with an optional step. | start, end, step |
range(start, end, step) |
read_file |
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. | path |
read_file(path) |
read_file_bytes |
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. | path |
read_file_bytes(path) |
regex_match |
Finds all matches of the given pattern in the string. | string, pattern |
regex_match(string, pattern) |
reject |
Filters out elements that match the condition (opposite of filter). | arr, f |
reject(arr, f) |
repeat |
Repeats the given string a specified number of times. | string, count |
repeat(string, count) |
replace |
Replaces all occurrences of a substring with another substring. | from, pattern, to |
replace(from, pattern, to) |
reverse |
Reverses the given string or array. | value |
reverse(value) |
rindex |
Finds the last occurrence of a substring or byte subsequence. Returns -1 if not found. | value, needle |
rindex(value, needle) |
round |
Rounds the given number to the nearest integer. | number |
round(number) |
rpad |
Right-pads a string to a specified length using a given padding string. | s, length, pad_str |
rpad(s, length, pad_str) |
rtrim |
Trims whitespace from the right end of the given string. | input |
rtrim(input) |
rtrimstr |
Removes suffix string from input if it exists | s, right |
rtrimstr(s, right) |
sample |
Returns n elements sampled from the array without replacement, in random order. Errors if n exceeds the array length. | array, n |
sample(array, n) |
sanitize_html |
Sanitizes the given HTML string using an allowlist of safe tags and attributes, removing scripts and other XSS vectors. | html |
sanitize_html(html) |
scalars |
Returns the value if it is not an array or dict (i.e. a leaf/scalar value), None otherwise | v |
scalars(v) |
scan |
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. | string, pattern |
scan(string, pattern) |
second |
Returns the second element of an array | arr |
second(arr) |
select |
Returns value if condition is true, None otherwise | v, f |
select(v, f) |
set |
Sets a key-value pair in a dict. If the key exists, its value is updated. Returns the modified map. | obj, key, value |
set(obj, key, value) |
set_attr |
Sets the value of the specified attribute on a markdown node. | markdown, attribute, value |
set_attr(markdown, attribute, value) |
set_check |
Creates a markdown list node with the given checked state. | list, checked |
set_check(list, checked) |
set_children |
Sets the children nodes of a markdown node. Nodes without children (e.g. text, code) are left unchanged. | markdown, children |
set_children(markdown, children) |
set_code_block_lang |
Sets the language of a markdown code block node. | code_block, language |
set_code_block_lang(code_block, language) |
set_list_ordered |
Sets the ordered property of a markdown list node. | list, ordered |
set_list_ordered(list, ordered) |
set_path |
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. | value, path, new_value |
set_path(value, path, new_value) |
set_ref |
Sets the reference identifier for markdown nodes that support references (e.g., Definition, LinkRef, ImageRef, Footnote, FootnoteRef). | node, reference_id |
set_ref(node, reference_id) |
set_variable |
Sets a symbol or variable in the current environment with the given value. | symbol_or_string, value |
set_variable(symbol_or_string, value) |
sha256 |
Computes the SHA-256 hash of a string or bytes and returns a lowercase hex string. | input |
sha256(input) |
sha512 |
Computes the SHA-512 hash of a string or bytes and returns a lowercase hex string. | input |
sha512(input) |
shift_left |
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. | value, shift_amount |
shift_left(value, shift_amount) |
shift_right |
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. | value, shift_amount |
shift_right(value, shift_amount) |
shuffle |
Returns a new array containing the same elements as the input, in a uniformly random order. | array |
shuffle(array) |
skip |
Skips the first n elements of an array and returns the rest | arr, n |
skip(arr, n) |
skip_while |
Skips elements from the beginning of an array while the provided function returns true | arr, f |
skip_while(arr, f) |
slice |
Extracts a substring from the given string. | string, start, end |
slice(string, start, end) |
slugify |
Converts a string into a URL-friendly slug by lowercasing, replacing non-alphanumeric characters with hyphens, and trimming hyphens from the ends. | s, separator |
slugify(s, separator) |
sort |
Sorts the elements of the given array. | array |
sort(array) |
sort_by |
Sorts an array using a key function that extracts a comparable value for each element. | arr, f |
sort_by(arr, f) |
split |
Splits the given string by the specified separator. | string, separator |
split(string, separator) |
sqrt |
Returns the square root of the given number. | number |
sqrt(number) |
starts_with |
Checks if the given string or byte array starts with the specified prefix. | value, prefix |
starts_with(value, prefix) |
stderr |
Prints a message to standard error and returns the current value. | message |
stderr(message) |
stem |
Returns the file name without the extension (e.g. "file" from "/a/b/file.txt"). | path |
stem(path) |
strftime |
Formats a Unix timestamp (seconds) as a date string using the given strftime format (e.g. "%Y-%m-%d"). | timestamp, format |
strftime(timestamp, format) |
strings |
Returns string if input is string, None otherwise | s |
strings(s) |
strip_tags |
Removes HTML tags from the given string, keeping the surrounding text content. | string |
strip_tags(string) |
sub |
Subtracts the second value from the first value. | value1, value2 |
sub(value1, value2) |
sum |
Returns the sum of the elements in an array after applying a transformation function to each element. | arr |
sum(arr) |
sum_by |
Sums elements of an array after applying a transformation function. | arr, f |
sum_by(arr, f) |
take |
Takes the first n elements of an array | arr, n |
take(arr, n) |
take_while |
Takes elements from the beginning of an array while the provided function returns true | arr, f |
take_while(arr, f) |
tally |
Counts occurrences of each element in an array, returning a dict of `{value: count}`. | arr |
tally(arr) |
tap |
Applies a function to a value and returns the value (useful for debugging or side effects). | tap_value, tap_expr |
tap(tap_value, tap_expr) |
test |
Tests if string matches a pattern | s, pattern |
test(s, pattern) |
times |
Executes an expression n times and returns an array of results. | t_n, t_expr |
times(t_n, t_expr) |
to_array |
Converts the given value to an array. | value |
to_array(value) |
to_blockquote |
Creates a markdown blockquote node with the given value. | value |
to_blockquote(value) |
to_boolean |
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. | value |
to_boolean(value) |
to_bytes |
Converts a string (UTF-8), array of numbers, or bytes to raw bytes. | value |
to_bytes(value) |
to_callout |
Creates a markdown callout node with the given value, kind, and title. | value, kind, title |
to_callout(value, kind, title) |
to_code |
Creates a markdown code block with the given value and language. | value, language |
to_code(value, language) |
to_code_inline |
Creates an inline markdown code node with the given value. | value |
to_code_inline(value) |
to_date |
Converts a timestamp to a date string with the given format. | timestamp, format |
to_date(timestamp, format) |
to_date_iso8601 |
Formats a date to ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ) | d |
to_date_iso8601(d) |
to_delete |
Creates a markdown delete (strikethrough) node with the given value. | value |
to_delete(value) |
to_em |
Creates a markdown emphasis (italic) node with the given value. | value |
to_em(value) |
to_front_matter |
Converts a data structure to a YAML front matter string. deprecated: use to_frontmatter instead | data |
to_front_matter(data) |
to_frontmatter |
Converts a data structure to a YAML front matter string. | data |
to_frontmatter(data) |
to_h |
Creates a markdown heading node with the given value and depth. | value, depth |
to_h(value, depth) |
to_hex |
Encodes raw bytes as a lowercase hex string. | bytes |
to_hex(bytes) |
to_hr |
Creates a markdown horizontal rule node. | to_hr() |
|
to_html |
Converts the given markdown string to HTML. | markdown |
to_html(markdown) |
to_image |
Creates a markdown image node with the given URL, alt text, and title. | url, alt, title |
to_image(url, alt, title) |
to_link |
Creates a markdown link node with the given url and title. | url, value, title |
to_link(url, value, title) |
to_markdown |
Parses a markdown string and returns an array of markdown nodes. | markdown_string |
to_markdown(markdown_string) |
to_markdown_string |
Converts the given value(s) to a markdown string representation. | value |
to_markdown_string(value) |
to_math |
Creates a markdown math block with the given value. | value |
to_math(value) |
to_math_inline |
Creates an inline markdown math node with the given value. | value |
to_math_inline(value) |
to_md_fragment |
Creates a markdown fragment node that groups an array of markdown nodes into a single value. | values |
to_md_fragment(values) |
to_md_list |
Creates a markdown list node with the given value and indent level. | value, indent |
to_md_list(value, indent) |
to_md_name |
Returns the name of the given markdown node. | markdown |
to_md_name(markdown) |
to_md_table_align |
Creates a markdown table alignment row node from an array of alignments ("left", "right", "center", "none"). | aligns |
to_md_table_align(aligns) |
to_md_table_cell |
Creates a markdown table cell node with the given value at the specified row and column. | value, row, column |
to_md_table_cell(value, row, column) |
to_md_table_row |
Creates a markdown table row node with the given values. | cells |
to_md_table_row(cells) |
to_md_text |
Creates a markdown text node with the given value. | value |
to_md_text(value) |
to_mdx |
Parses an MDX string and returns an array of MDX nodes. | mdx_string |
to_mdx(mdx_string) |
to_number |
Converts the given value to a number. | value |
to_number(value) |
to_string |
Converts the given value to a string. | value |
to_string(value) |
to_strong |
Creates a markdown strong (bold) node with the given value. | value |
to_strong(value) |
to_text |
Converts the given markdown node to plain text. | markdown |
to_text(markdown) |
token_count |
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. | text, model? |
token_count(text, model?) |
toml_parse |
Parses a TOML string and returns the parsed data structure. | input |
toml_parse(input) |
toml_stringify |
Converts a data structure to a TOML string representation. | data |
toml_stringify(data) |
toml_to_json |
Converts a data structure to a JSON string representation. | data |
toml_to_json(data) |
toml_to_markdown_table |
Converts a TOML data structure to a Markdown table. | data |
toml_to_markdown_table(data) |
transpose |
Transposes a 2D array (matrix), swapping rows and columns. | matrix |
transpose(matrix) |
trim |
Trims whitespace from both ends of the given string. | input |
trim(input) |
trunc |
Truncates the given number to an integer by removing the fractional part. | number |
trunc(number) |
truncate |
Truncates the given string to the specified display width, appending the ellipsis string when truncated (CJK and other wide characters count as two columns). | string, width, ellipsis |
truncate(string, width, ellipsis) |
type |
Returns the type of the given value. | value |
type(value) |
uniq |
Removes duplicate elements from the given array. | array |
uniq(array) |
unique_by |
Returns a new array with duplicate elements removed, comparing by the result of the provided function. | arr, f |
unique_by(arr, f) |
unless |
Executes the expression only if the condition is false. | unless_cond, unless_expr |
unless(unless_cond, unless_expr) |
unlines |
Joins an array of strings into a single string with newline characters between them. | arr |
unlines(arr) |
unpack |
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. | format, bytes |
unpack(format, bytes) |
until |
Executes the expression repeatedly until the condition is true. | until_cond, until_expr |
until(until_cond, until_expr) |
upcase |
Converts the given string to uppercase. | input |
upcase(input) |
update |
Update the value with specified value. | target_value, source_value |
update(target_value, source_value) |
url_decode |
URL-decodes the given string. | input |
url_decode(input) |
url_encode |
URL-encodes the given string. | input |
url_encode(input) |
utf8 |
Decodes bytes as a UTF-8 string, returning an error if the bytes are not valid UTF-8. | bytes |
utf8(bytes) |
uuid |
Generates a random (version 4, RFC 4122) UUID string. | uuid() |
|
uuid_v4 |
Generates a random (version 4, RFC 4122) UUID string. Alias of `uuid`. | uuid_v4() |
|
uuid_v7 |
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. | uuid_v7() |
|
values |
Returns an array of values from the dict. | dict |
values(dict) |
walk |
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. | v, f |
walk(v, f) |
with_entries |
Transforms each [key, value] pair of a dict by applying the given function, then rebuilds a dict from the resulting pairs. | d, f |
with_entries(d, f) |
word_wrap |
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). | string, width |
word_wrap(string, width) |
write_file |
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. | path, content |
write_file(path, content) |
xor |
Computes the bitwise XOR of two byte arrays of equal length. | bytes1, bytes2 |
xor(bytes1, bytes2) |
yaml_parse |
Parses a YAML string and returns the parsed data structure. | input |
yaml_parse(input) |
yaml_stringify |
Converts a data structure to a YAML string representation. | data |
yaml_stringify(data) |
yaml_to_json |
Converts a data structure to a JSON string representation. | data |
yaml_to_json(data) |
yaml_to_markdown_table |
Converts a YAML data structure to a Markdown table. | data |
yaml_to_markdown_table(data) |
zip |
Combines two arrays into an array of pairs, where each pair contains elements from the same index in both arrays. | arr1, arr2 |
zip(arr1, arr2) |
2 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
get_args |
Gets the arguments of an AST node | node |
get_args(node) |
to_code |
Converts an AST node back to code | node |
to_code(node) |
2 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
cbor_parse |
CBOR Implementation in mq Parses a base64-encoded CBOR string (or raw bytes) and returns the corresponding data structure. | input |
cbor_parse(input) |
cbor_stringify |
Serializes a value to CBOR bytes. | data |
cbor_stringify(data) |
8 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
csv_needs_quote |
CSV/TSV Implementation in mq Based on RFC 4180 for CSV format | field, delimiter |
csv_needs_quote(field, delimiter) |
csv_parse |
Parses CSV content using a comma as the delimiter. | input, has_header |
csv_parse(input, has_header) |
csv_parse_with_delimiter |
Parses CSV content with a specified delimiter and optional header row. | input, delimiter, has_header |
csv_parse_with_delimiter(input, delimiter, has_header) |
csv_stringify |
Converts data to a CSV string with a specified delimiter. | data, delimiter |
csv_stringify(data, delimiter) |
csv_to_json |
Converts CSV data to a JSON string. | data |
csv_to_json(data) |
csv_to_markdown_table |
Converts CSV data to a Markdown table format. | data |
csv_to_markdown_table(data) |
psv_parse |
Parses PSV (Pipe-Separated Values) content. | input, has_header |
psv_parse(input, has_header) |
tsv_parse |
Parses TSV (Tab-Separated Values) content. | input, has_header |
tsv_parse(input, has_header) |
8 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
fuzzy_best_match |
Finds the best fuzzy match from candidates. | candidates, query |
fuzzy_best_match(candidates, query) |
fuzzy_filter |
Filters candidates by minimum fuzzy match score using Jaro-Winkler. | candidates, query, threshold |
fuzzy_filter(candidates, query, threshold) |
fuzzy_match |
Performs fuzzy matching on an array of strings using Jaro-Winkler distance. | candidates, query |
fuzzy_match(candidates, query) |
fuzzy_match_jaro |
Performs fuzzy matching using Jaro distance. | candidates, query |
fuzzy_match_jaro(candidates, query) |
fuzzy_match_levenshtein |
Performs fuzzy matching using Levenshtein distance. | candidates, query |
fuzzy_match_levenshtein(candidates, query) |
jaro |
Calculates the Jaro distance between two strings (0.0 to 1.0, where 1.0 is exact match). | s1, s2 |
jaro(s1, s2) |
jaro_winkler |
Calculates the Jaro-Winkler distance between two strings. | s1, s2 |
jaro_winkler(s1, s2) |
levenshtein |
Calculates the Levenshtein distance between two strings. | s1, s2 |
levenshtein(s1, s2) |
0 functions
| Function | Description | Parameters | Example |
|---|
3 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
json_parse |
JSON Implementation in mq Parses a JSON string and returns the corresponding data structure. | input |
json_parse(input) |
json_stringify |
Serializes a value to a JSON string. | data |
json_stringify(data) |
json_to_markdown_table |
Converts a JSON data structure to a Markdown table. | data |
json_to_markdown_table(data) |
19 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
all_nodes |
Returns all nodes of a section, including both the header and content. | section |
all_nodes(section) |
bodies |
Extracts body from all sections. | sections |
bodies(sections) |
body |
Returns the body of a section (all nodes except the header). | section |
body(section) |
by_level |
Filters sections by heading level. l can be a number (exact level) or a range array (e.g. 1..2). | sections, l |
by_level(sections, l) |
collect |
Flattens sections back to markdown nodes for output. This converts section objects back to their original markdown node arrays. | sections |
collect(sections) |
content |
Returns the content of a section (all nodes except the header). Deprecated: Use body() instead, as content() | section |
content(section) |
filter_sections |
Filters sections based on a given predicate function. | md_nodes, predicate |
filter_sections(md_nodes, predicate) |
has_content |
Checks if a section has any content beyond the header. | section |
has_content(section) |
level |
Returns the header level (1-6) of a section. | section |
level(section) |
map_sections |
Maps sections using a given mapper function. | md_nodes, mapper |
map_sections(md_nodes, mapper) |
nth |
Returns the nth section from an array of sections (0-indexed). | sections, n |
nth(sections, n) |
section |
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. | md_nodes, pattern, depth |
section(md_nodes, pattern, depth) |
sections |
Splits markdown nodes into sections based on headers. | md_nodes |
sections(md_nodes) |
split |
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. | md_nodes, level |
split(md_nodes, level) |
title |
Returns the title text of a section (header text without the # symbols). | section |
title(section) |
title_contains |
Filters the given list of sections, returning only those whose title contains the specified text. | sections, text |
title_contains(sections, text) |
title_match |
Filters sections by a pattern match in the title text. | sections, pattern |
title_match(sections, pattern) |
titles |
Extracts titles from all sections. | sections |
titles(sections) |
toc |
Generates a table of contents from sections. | sections |
toc(sections) |
15 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
semver_bump_major |
Increments the major version and resets minor, patch, and pre-release. | v |
semver_bump_major(v) |
semver_bump_minor |
Increments the minor version and resets patch and pre-release. | v |
semver_bump_minor(v) |
semver_bump_patch |
Increments the patch version and clears pre-release. | v |
semver_bump_patch(v) |
semver_compare |
Compares two parsed SemVer dicts. Returns -1 if a < b, 0 if a == b, 1 if a > b. | a, b |
semver_compare(a, b) |
semver_eq |
Returns true if version a equals version b (ignoring build metadata). | a, b |
semver_eq(a, b) |
semver_gt |
Returns true if version a is greater than version b. | a, b |
semver_gt(a, b) |
semver_gte |
Returns true if version a is greater than or equal to version b. | a, b |
semver_gte(a, b) |
semver_lt |
Returns true if version a is less than version b. | a, b |
semver_lt(a, b) |
semver_lte |
Returns true if version a is less than or equal to version b. | a, b |
semver_lte(a, b) |
semver_max |
Returns the maximum version from an array of parsed SemVer dicts. | versions |
semver_max(versions) |
semver_min |
Returns the minimum version from an array of parsed SemVer dicts. | versions |
semver_min(versions) |
semver_parse |
Parses a SemVer string into a dict with major, minor, patch, pre, and build fields. | s |
semver_parse(s) |
semver_satisfies |
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 | version, range |
semver_satisfies(version, range) |
semver_sort |
Sorts an array of parsed SemVer dicts in ascending order. | versions |
semver_sort(versions) |
semver_to_string |
Converts a parsed SemVer dict back to a version string. | v |
semver_to_string(v) |
12 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
add_column |
Add a new column to a table. | table, col |
add_column(table, col) |
add_row |
Add a new row to a table. | table, row |
add_row(table, row) |
filter_rows |
Filter rows in the table based on a predicate function. | table, f |
filter_rows(table, f) |
filter_tables |
Filter tables from markdown nodes based on a predicate function. | tables, f |
filter_tables(tables, f) |
map_rows |
Map a function over each row in the table. | table, f |
map_rows(table, f) |
remove_column |
Remove a column from a table at the specified index. | table, col_index |
remove_column(table, col_index) |
remove_row |
Remove a row from a table at the specified index. | table, row_index |
remove_row(table, row_index) |
set_align |
Set the alignment for a table. | table, align |
set_align(table, align) |
sort_rows |
Sort rows in the table by a specified column index or default sorting. | table, column_index |
sort_rows(table, column_index) |
tables |
Extract table structures from a list of markdown nodes. | md_nodes |
tables(md_nodes) |
to_csv |
Convert a table structure into a CSV string with the specified delimiter. | table, delimiter |
to_csv(table, delimiter) |
to_markdown |
Convert a table structure back into a list of markdown nodes. | table |
to_markdown(table) |
13 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
assert |
Testing framework for mq A simple testing framework to execute test functions and output results Verifies that a condition is true and raises an error if it's false. | cond |
assert(cond) |
assert_contains |
Verifies that an array contains a specific value | array, value |
assert_contains(array, value) |
assert_empty |
Verifies that an array is empty | array |
assert_empty(array) |
assert_eq |
Verifies that two values are equal | actual, expected |
assert_eq(actual, expected) |
assert_false |
Verifies that a value is false | value |
assert_false(value) |
assert_len |
Verifies that an array has a specific length | array, expected_length |
assert_len(array, expected_length) |
assert_ne |
Verifies that two values are not equal | actual, expected |
assert_ne(actual, expected) |
assert_none |
Verifies that a value is None | value |
assert_none(value) |
assert_not_empty |
Verifies that an array is not empty | array |
assert_not_empty(array) |
assert_not_none |
Verifies that a value is not None | value |
assert_not_none(value) |
assert_true |
Verifies that a value is true | value |
assert_true(value) |
run_tests |
Executes multiple test functions | tests |
run_tests(tests) |
test_case |
Helper function to create a test case | name, func |
test_case(name, func) |
4 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
toml_parse |
Parses a TOML string and returns the parsed data structure. | input |
toml_parse(input) |
toml_stringify |
Converts a data structure to a TOML string representation. | data |
toml_stringify(data) |
toml_to_json |
Converts a data structure to a JSON string representation. | data |
toml_to_json(data) |
toml_to_markdown_table |
Converts a TOML data structure to a Markdown table. | data |
toml_to_markdown_table(data) |
2 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
toon_parse |
To parse a TOON string into a data structure | input |
toon_parse(input) |
toon_stringify |
To convert a data structure into a TOON string | data |
toon_stringify(data) |
3 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
xml_parse |
XML Implementation in mq Parses an XML string and returns the corresponding data structure. | input |
xml_parse(input) |
xml_stringify |
Serializes a value to an XML string. | data |
xml_stringify(data) |
xml_to_markdown_table |
Converts an XML data structure to a Markdown table. | data |
xml_to_markdown_table(data) |
6 functions
| Function | Description | Parameters | Example |
|---|---|---|---|
to_front_matter |
Converts a data structure to a YAML front matter string. deprecated: use to_frontmatter instead | data |
to_front_matter(data) |
to_frontmatter |
Converts a data structure to a YAML front matter string. | data |
to_frontmatter(data) |
yaml_parse |
Parses a YAML string and returns the parsed data structure. | input |
yaml_parse(input) |
yaml_stringify |
Converts a data structure to a YAML string representation. | data |
yaml_stringify(data) |
yaml_to_json |
Converts a data structure to a JSON string representation. | data |
yaml_to_json(data) |
yaml_to_markdown_table |
Converts a YAML data structure to a Markdown table. | data |
yaml_to_markdown_table(data) |
44 selectors
| Selector | Description |
|---|---|
.<> |
Selects an HTML node. |
.[] |
Selects a list node with the specified index and checked state. |
.[][] |
Selects a table cell node with the specified row and column. |
.blockquote |
Selects a blockquote node. |
.break |
Selects a break node. |
.code |
Selects a code block node with the specified language. |
.code_inline |
Selects an inline code node. |
.definition |
Selects a definition node. |
.delete |
Selects a delete (strikethrough) node. |
.done |
Selects a done item in the task list node. |
.emphasis |
Selects an emphasis (italic) node. |
.footnote |
Selects a footnote node. |
.footnote_ref |
Selects a footnote reference node. |
.h |
Selects a heading node with the specified depth. |
.h1 |
Selects a heading node with the 1 depth. |
.h2 |
Selects a heading node with the 2 depth. |
.h3 |
Selects a heading node with the 3 depth. |
.h4 |
Selects a heading node with the 4 depth. |
.h5 |
Selects a heading node with the 5 depth. |
.h6 |
Selects a heading node with the 6 depth. |
.heading |
Selects a heading node with the specified depth. |
.horizontal_rule |
Selects a horizontal rule node. |
.html |
Selects an HTML node. |
.image |
Selects an image node. |
.image_ref |
Selects an image reference node. |
.inline_math |
Selects an inline math node. |
.link |
Selects a link node. |
.link_ref |
Selects a link reference node. |
.list |
Selects a list node with the specified index and checked state. |
.math |
Selects a math node. |
.math_inline |
Selects a math inline node. |
.mdx_flow_expression |
Selects an MDX flow expression node. |
.mdx_js_esm |
Selects an MDX JS ESM node. |
.mdx_jsx_flow_element |
Selects an MDX JSX flow element node. |
.mdx_jsx_text_element |
Selects an MDX JSX text element node. |
.mdx_text_expression |
Selects an MDX text expression node. |
.strong |
Selects a strong (bold) node. |
.table |
Selects a table cell node with the specified row and column. |
.table_align |
Selects a table align node. |
.task |
Selects a task list node. |
.text |
Selects a text node. |
.todo |
Selects a todo item in the task list node. |
.toml |
Selects a TOML node. |
.yaml |
Selects a YAML node. |