/

File data

Quarkdown provides functions to retrieve information from files.

The following functions accept a path parameter, which can be either a path relative to the main source file’s location or an absolute path. Use a slash (/) as the path separator, regardless of the operating system.

File text content

The .read {path} docs ↗ function returns the string content of the specified file.

An optional lines parameter of type Range selects a specific range of lines (inclusive, starting from 1). An invalid or out-of-bounds range causes an error. If you do not provide a range, Quarkdown reads the entire file.

.read {myfile.txt} lines:{3..8}

Open ranges work as follows:

Example 1

.read is particularly useful in combination with functions such as .code, .mermaid and .css to load code snippets from external files.

.code
    .read {assets/point.ts}
export class Point {
    x: number;
    y: number;

    constructor(x: number, y: number) {
        this.x = x;
        this.y = y;
    }
}

Listing files in a directory

The .listfiles {path} {sortby?} {order?} docs ↗ function returns an iterable of the files in a directory. The result is unordered by default, but you can sort it by name or date.

Like any other collection, you can iterate over the result or supply it to other functions. For example, you can perform automatic bulk inclusions via .includeall:

.includeall {.listfiles {somedirectory} sortby:{name}}

Getting a file name

The .filename {path} {extension?} docs ↗ function returns the file name from a given file path. The optional extension boolean parameter controls whether the file extension is included in the result.

Example 2

.filename {assets/point.ts} extension:{no}

point

Table from CSV

The .csv {path} {mode?} {caption?} docs ↗ function loads a table from a CSV file. The first row of the CSV file always serves as the header row.

Tables loaded from CSV can also be manipulated. See Table manipulation for more information.

Example 3

.csv {assets/people.csv}
UsernameBirth yearFavorite foodFavorite drink
john1992ChickenOrange juice
iamgio2002PastaIced tea
daniel1986SushiBeer

You can also provide a caption.

Example 4

.csv {assets/people.csv} caption:{People data.}
UsernameBirth yearFavorite foodFavorite drink
john1992ChickenOrange juice
iamgio2002PastaIced tea
daniel1986SushiBeer
People data.

The mode parameter controls how the CSV file is parsed. It defaults to plain, which treats all cell content as plain text. If set to markdown, Quarkdown parses cell content as inline Quarkdown source code, allowing formatting, rich content, and inline function calls within the CSV.

Name,  Favorite drink, Age *(as of 2026)*
Alice, Coffee,         .subtract {2026} {1995}
Bob,   *Pepsi*,        .subtract {2026} {2001}

Example 5

.csv {assets/people2.csv} mode:{markdown}
NameFavorite drinkAge (as of 2026)
AliceCoffee31
BobPepsi25