Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Builtin functions

Function NameDescriptionParametersExample
absReturns the absolute value of the given number.numberabs(number)
addAdds two values.value1, value2add(value1, value2)
allReturns true if all element in the array satisfies the provided function.v, fall(v, f)
andPerforms a logical AND operation on two boolean values.value1, value2and(value1, value2)
anyReturns true if any element in the array satisfies the provided function.v, fany(v, f)
arrayCreates an array from the given values.valuesarray(values)
arraysReturns array if input is array, None otherwiseaarrays(a)
assertVerifies that a condition is true and raises an error if it’s false.condassert(cond)
assertAsserts that two values are equal, returns the value if true, otherwise raises an error.value1, value2assert(value1, value2)
attrRetrieves the value of the specified attribute from a markdown node.markdown, attributeattr(markdown, attribute)
base64Encodes the given string to base64.inputbase64(input)
base64dDecodes the given base64 string.inputbase64d(input)
booleansReturns boolean if input is boolean, None otherwisebbooleans(b)
ceilRounds the given number up to the nearest integer.numberceil(number)
compactRemoves None values from the given array.arraycompact(array)
containsChecks if string contains a substringhaystack, needlecontains(haystack, needle)
csv2tableConvert csv string to markdown tablecsvcsv2table(csv)
csv2table_rowConvert csv string to markdown table rowrowcsv2table_row(row)
csv2table_with_headerConverts a CSV string array to a markdown table.csvcsv2table_with_header(csv)
debugPrints the debug information of the given value.msgdebug(msg)
decrease_header_levelDecreases the level of a markdown heading node by one, down to a minimum of 1.heading_nodedecrease_header_level(heading_node)
delDeletes the element at the specified index in the array or string.array_or_string, indexdel(array_or_string, index)
dictCreates a new, empty dict.dict()
divDivides the first value by the second value.value1, value2div(value1, value2)
downcaseConverts the given string to lowercase.inputdowncase(input)
ends_withChecks if the given string ends with the specified substring.string, substringends_with(string, substring)
entriesReturns an array of key-value pairs from the dict as arrays.dictentries(dict)
eqChecks if two values are equal.value1, value2eq(value1, value2)
errorRaises a user-defined error with the specified message.messageerror(message)
explodeSplits the given string into an array of characters.stringexplode(string)
fillReturns an array of length n filled with the given value.value, nfill(value, n)
filterFilters the elements of an array based on a provided callback function.v, ffilter(v, f)
find_indexReturns the index of the first element in an array that satisfies the provided function.arr, ffind_index(arr, f)
firstReturns the first element of an arrayarrfirst(arr)
flattenFlattens a nested array into a single level array.arrayflatten(array)
floorRounds the given number down to the nearest integer.numberfloor(number)
foldReduces an array to a single value by applying a function, starting from an initial value.arr, init, ffold(arr, init, f)
from_dateConverts a date string to a timestamp.date_strfrom_date(date_str)
getRetrieves a value from a dict by its key. Returns None if the key is not found.dict, keyget(dict, key)
get_md_list_levelReturns the indent level of a markdown list node.listget_md_list_level(list)
get_titleReturns the title of a markdown node.nodeget_title(node)
get_urlReturns the url of a markdown node.nodeget_url(node)
group_byGroups elements of an array by the result of applying a function to each elementarr, fgroup_by(arr, f)
gsubReplaces all occurrences matching a regular expression pattern with the replacement string.from, pattern, togsub(from, pattern, to)
gtChecks if the first value is greater than the second value.value1, value2gt(value1, value2)
gteChecks if the first value is greater than or equal to the second value.value1, value2gte(value1, value2)
haltTerminates the program with the given exit code.exit_codehalt(exit_code)
halt_errorHalts execution with error code 5halt_error()
identityReturns the input value unchanged.xidentity(x)
implodeJoins an array of characters into a string.arrayimplode(array)
inReturns true if the element is in the array.v, elemin(v, elem)
increase_header_levelIncreases the level of a markdown heading node by one, up to a maximum of 6.heading_nodeincrease_header_level(heading_node)
indexFinds the first occurrence of a substring in the given string.string, substringindex(string, substring)
insertInserts a value into an array or string at the specified index, or into a dict with the specified key.target, index_or_key, valueinsert(target, index_or_key, value)
is_arrayChecks if input is an arrayais_array(a)
is_boolChecks if input is a booleanbis_bool(b)
is_codeChecks if markdown is code blockmdis_code(md)
is_dictChecks if input is a dictionarydis_dict(d)
is_emChecks if markdown is emphasismdis_em(md)
is_emptyChecks if string, array or dict is emptysis_empty(s)
is_hChecks if markdown is headingmdis_h(md)
is_h1Checks if markdown is h1 headingmdis_h1(md)
is_h2Checks if markdown is h2 headingmdis_h2(md)
is_h3Checks if markdown is h3 headingmdis_h3(md)
is_h4Checks if markdown is h4 headingmdis_h4(md)
is_h5Checks if markdown is h5 headingmdis_h5(md)
is_h6Checks if markdown is h6 headingmdis_h6(md)
is_h_levelChecks if markdown is a heading of the specified level (1-6)md, levelis_h_level(md, level)
is_htmlChecks if markdown is htmlmdis_html(md)
is_listChecks if markdown is listlistis_list(list)
is_list1Checks if markdown is list with indentation level 1listis_list1(list)
is_list2Checks if markdown is list with indentation level 2listis_list2(list)
is_list3Checks if markdown is list with indentation level 3listis_list3(list)
is_markdownChecks if input is markdownmis_markdown(m)
is_mdxChecks if markdown is MDXmdxis_mdx(mdx)
is_mdx_flow_expressionChecks if markdown is MDX Flow Expressionmdxis_mdx_flow_expression(mdx)
is_mdx_js_esmChecks if markdown is MDX Js Esmmdxis_mdx_js_esm(mdx)
is_mdx_jsx_flow_elementChecks if markdown is MDX Jsx Flow Elementmdxis_mdx_jsx_flow_element(mdx)
is_mdx_jsx_text_elementChecks if markdown is MDX Jsx Text Elementmdxis_mdx_jsx_text_element(mdx)
is_mdx_text_expressionChecks if markdown is MDX Text Expressionmdxis_mdx_text_expression(mdx)
is_noneChecks if input is Nonenis_none(n)
is_not_h1Checks if markdown is not an h1 headingmdis_not_h1(md)
is_not_h2Checks if markdown is not an h2 headingmdis_not_h2(md)
is_not_h3Checks if markdown is not an h3 headingmdis_not_h3(md)
is_not_h4Checks if markdown is not an h4 headingmdis_not_h4(md)
is_not_h5Checks if markdown is not an h5 headingmdis_not_h5(md)
is_not_h6Checks if markdown is not an h6 headingmdis_not_h6(md)
is_numberChecks if input is a numbernis_number(n)
is_stringChecks if input is a stringsis_string(s)
is_textChecks if markdown is texttextis_text(text)
is_tomlChecks if markdown is tomlmdis_toml(md)
is_yamlChecks if markdown is yamlmdis_yaml(md)
joinJoins the elements of an array into a string with the given separator.array, separatorjoin(array, separator)
keysReturns an array of keys from the dict.dictkeys(dict)
lastReturns the last element of an arrayarrlast(arr)
lenReturns the length of the given string or array.valuelen(value)
ltChecks if the first value is less than the second value.value1, value2lt(value1, value2)
lteChecks if the first value is less than or equal to the second value.value1, value2lte(value1, value2)
ltrimstrRemoves prefix string from input if it existss, leftltrimstr(s, left)
mapApplies a given function to each element of the provided array and returns a new array with the results.v, fmap(v, f)
markdownsReturns markdown if input is markdown, None otherwisemmarkdowns(m)
matchFinds all matches of the given pattern in the string.string, patternmatch(string, pattern)
matches_urlChecks if markdown node’s URL matches a specified URLnode, urlmatches_url(node, url)
maxReturns the maximum of two values.value1, value2max(value1, value2)
minReturns the minimum of two values.value1, value2min(value1, value2)
modCalculates the remainder of the division of the first value by the second value.value1, value2mod(value1, value2)
mulMultiplies two values.value1, value2mul(value1, value2)
neChecks if two values are not equal.value1, value2ne(value1, value2)
notPerforms a logical NOT operation on a boolean value.valuenot(value)
nowReturns the current timestamp.now()
nthGets the element at the specified index in the array or string.array_or_string, indexnth(array_or_string, index)
numbersReturns number if input is number, None otherwisennumbers(n)
orPerforms a logical OR operation on two boolean values.value1, value2or(value1, value2)
powRaises the base to the power of the exponent.base, exponentpow(base, exponent)
printPrints a message to standard output and returns the current value.messageprint(message)
rangeCreates an array from start to end with an optional step.start, end, steprange(start, end, step)
repeatRepeats the given string a specified number of times.string, countrepeat(string, count)
replaceReplaces all occurrences of a substring with another substring.from, pattern, toreplace(from, pattern, to)
reverseReverses the given string or array.valuereverse(value)
rindexFinds the last occurrence of a substring in the given string.string, substringrindex(string, substring)
roundRounds the given number to the nearest integer.numberround(number)
rtrimstrRemoves suffix string from input if it existss, rightrtrimstr(s, right)
secondReturns the second element of an arrayarrsecond(arr)
sectionsReturns 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, levelsections(md_nodes, level)
selectReturns value if condition is true, None otherwisev, fselect(v, f)
setSets a key-value pair in a dict. If the key exists, its value is updated. Returns the modified map.dict, key, valueset(dict, key, value)
set_attrSets the value of the specified attribute on a markdown node.markdown, attribute, valueset_attr(markdown, attribute, value)
set_checkCreates a markdown list node with the given checked state.list, checkedset_check(list, checked)
set_code_block_langSets the language of a markdown code block node.code_block, languageset_code_block_lang(code_block, language)
set_list_orderedSets the ordered property of a markdown list node.list, orderedset_list_ordered(list, ordered)
set_refSets the reference identifier for markdown nodes that support references (e.g., Definition, LinkRef, ImageRef, Footnote, FootnoteRef).node, reference_idset_ref(node, reference_id)
skipSkips the first n elements of an array and returns the restarr, nskip(arr, n)
skip_whileSkips elements from the beginning of an array while the provided function returns truearr, fskip_while(arr, f)
sliceExtracts a substring from the given string.string, start, endslice(string, start, end)
sortSorts the elements of the given array.arraysort(array)
sort_bySorts an array using a key function that extracts a comparable value for each element.arr, fsort_by(arr, f)
splitSplits the given string by the specified separator.string, separatorsplit(string, separator)
starts_withChecks if the given string starts with the specified substring.string, substringstarts_with(string, substring)
stderrPrints a message to standard error and returns the current value.messagestderr(message)
subSubtracts the second value from the first value.value1, value2sub(value1, value2)
takeTakes the first n elements of an arrayarr, ntake(arr, n)
take_whileTakes elements from the beginning of an array while the provided function returns truearr, ftake_while(arr, f)
testTests if string matches a patterns, patterntest(s, pattern)
to_arrayConverts input to an arrayato_array(a)
to_codeCreates a markdown code block with the given value and language.value, languageto_code(value, language)
to_code_inlineCreates an inline markdown code node with the given value.valueto_code_inline(value)
to_csvConverts the given value to a CSV.vto_csv(v)
to_dateConverts a timestamp to a date string with the given format.timestamp, formatto_date(timestamp, format)
to_date_iso8601Formats a date to ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)dto_date_iso8601(d)
to_emCreates a markdown emphasis (italic) node with the given value.valueto_em(value)
to_hCreates a markdown heading node with the given value and depth.value, depthto_h(value, depth)
to_hrCreates a markdown horizontal rule node.to_hr()
to_htmlConverts the given markdown string to HTML.markdownto_html(markdown)
to_imageCreates a markdown image node with the given URL, alt text, and title.url, alt, titleto_image(url, alt, title)
to_linkCreates a markdown link node with the given url and title.url, value, titleto_link(url, value, title)
to_markdown_stringConverts the given value(s) to a markdown string representation.valueto_markdown_string(value)
to_mathCreates a markdown math block with the given value.valueto_math(value)
to_math_inlineCreates an inline markdown math node with the given value.valueto_math_inline(value)
to_md_listCreates a markdown list node with the given value and indent level.value, indentto_md_list(value, indent)
to_md_nameReturns the name of the given markdown node.markdownto_md_name(markdown)
to_md_table_rowCreates a markdown table row node with the given values.cellsto_md_table_row(cells)
to_md_textCreates a markdown text node with the given value.valueto_md_text(value)
to_numberConverts the given value to a number.valueto_number(value)
to_stringConverts the given value to a string.valueto_string(value)
to_strongCreates a markdown strong (bold) node with the given value.valueto_strong(value)
to_textConverts the given markdown node to plain text.markdownto_text(markdown)
to_tsvConverts the given value to a TSV.vto_tsv(v)
trimTrims whitespace from both ends of the given string.inputtrim(input)
truncTruncates the given number to an integer by removing the fractional part.numbertrunc(number)
tsv2tableConvert tsv string to markdown tabletsvtsv2table(tsv)
tsv2table_rowConvert tsv string to markdown table rowrowtsv2table_row(row)
tsv2table_with_headerConverts a CSV string array to a markdown table.tsvtsv2table_with_header(tsv)
typeReturns the type of the given value.valuetype(value)
uniqRemoves duplicate elements from the given array.arrayuniq(array)
unique_byReturns a new array with duplicate elements removed, comparing by the result of the provided function.arr, funique_by(arr, f)
upcaseConverts the given string to uppercase.inputupcase(input)
updateUpdate the value with specified value.target_value, source_valueupdate(target_value, source_value)
url_encodeURL-encodes the given string.inputurl_encode(input)
valuesReturns an array of values from the dict.dictvalues(dict)