Package: nestedtext
Authors: Ken & Kale KundertVersion: 3.6Released: 2023-05-30Documentation:nestedtext.org.Please post all questions, suggestions, and bug reports to:Github.NestedTextis a file format for holding structured data.  It is similar in
concept toJSON, except thatNestedTextis designed to make it easy for people to enter, edit, or view the
data directly.  It organizes the data into a nested collection of name-value
pairs, lists, and strings.  The syntax is intended to be very simple and
intuitive for most people.A unique feature of this file format is that it only supports one scalar type:
strings.  As such, quoting strings is unnecessary, and without quoting there is
no need for escaping.  While the decision to forego other types (integers,
reals, dates, etc.) may seem counter productive, it leads to simpler data files
and applications that are more robust.NestedTextis convenient for configuration files, address books, account
information, and the like.  Here is an example of a file that contains a few
addresses:# Contact information for our officersKatheryn McDaniel:position:presidentaddress:>138 Almond Street>Topeka, Kansas 20697phone:cell:1-210-555-5297home:1-210-555-8470# Katheryn prefers that we always call her on her cell phone.email:KateMcD@aol.comadditional roles:-board memberMargaret Hodge:position:vice presidentaddress:>2586 Marigold Lane>Topeka, Kansas 20682phone:1-470-555-0398email:margaret.hodge@ku.eduadditional roles:-new membership task force-accounting task forceA strength ofNestedTextis its lack of quoting and escaping, making it
particularly nice for holding code fragments.  Here is another example ofNestedTextthat shows off this feature.  It holds someParametrize From Filetest cases forpytest.  In this case a command line program is being
tested and its response is checked using regular expressions:-
    cmd: emborg version
    expected: emborg version: \d+\.\d+(\.\d+(\.?\w+\d+)?)?  \(\d\d\d\d-\d\d-\d\d\)
    expected_type: regex
-
    cmd: emborg --quiet list
    expected: home-\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d
    expected_type: regex
-
    cmd: emborg --quiet borg list --glob-archives "home-*" --short @repo
    expected: home-\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d
    expected_type: regex
-
    cmd: emborg --quiet files -D
    expected:
        > Archive: home-\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d
        > \d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\d\d\d\d\d configs/subdir/(file|)
        > \d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\d\d\d\d\d configs/subdir/(file|)
            # Unfortunately, we cannot check the order as they were both
            # created at the same time.
    expected_type: regex
-
    cmd: emborg due --backup-days 1 --message "{elapsed} since last {action}"
    expected: home: (\d+(\.\d)? (seconds|minutes)) since last backup\.
    expected_type: regexOne particularly attractive use-case forNestedTextis command line programs
whose output is meant to be consumed by either people or programs.  Many
programs do so by supporting a--jsoncommand-line flag that indicates the
output should be computer readable rather than human readable.  But, withNestedTextit is not necessary to make people choose.  Just output the result
inNestedTextand it can be read by people or computers.  For example,
consider a program that reads your address list and output particular fields on
demand:> address --email
Katheryn McDaniel: KateMcD@aol.com
Margaret Hodge: margaret.hodge@ku.eduThis output could be fed directly into another program that acceptsNestedTextas input:> address --email | mail-to-listContributingThis package contains a Python reference implementation ofNestedTextand
a test suite.  Implementation in many languages is required forNestedTextto
catch on widely.  If you like the format, please consider contributing
additional implementations.Also, please consider usingNestedTextfor any applications you create.  It is
especially suitable for configuration files.