Skip to content

CorvidLabs/3md

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

85 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

3md

CI Release License: MIT Live demo

Markdown with a Z axis. A .3md file is ordinary Markdown extended along one free axis: stack your content into planes and tell the reader what the depth means. Time for a daily planner. Frames for an animation. Layers for annotations. Space for a scene.

Try the interactive demo (also on corvidlabs.xyz/3md), open the viewer & editor (paste any .3md and share a link), read the docs, or browse 270 examples in the gallery (all of Examples/, rendered live), or flip through the animated gallery where every example is a card showing its motion as a GIF.

This repo eats its own dog food: every doc here is also combined into one docs.3md (each Markdown file is a plane). GitHub can't preview .3md natively, so open all the docs in the 3md viewer and scrub through them.

The 3md interactive demo: planes stacked along the Z axis with a synced source view

---
3md: 0.1
axis: time
title: My Week
---
@plane z=0 label="Monday"
# Monday
- [ ] Standup

@plane z=1 label="Tuesday"
# Tuesday

This repository holds the format specification (SPEC.md), example documents (Examples/), three parsers kept in lockstep (ThreeMD, a cross-platform Swift parser; a TypeScript port in js/; and a Rust crate in rust/), and a shared cross-implementation conformance suite (conformance/) that all three pass.

Why

Markdown is two dimensional. Plenty of documents are not: a planner moves through time, an annotated contract has overlay layers, an ASCII animation is a stack of frames. 3md keeps Markdown's plain-text simplicity and adds one axis, with the author declaring what that axis means. Nothing comparable ships today; the closest prior art renders existing Markdown into 3D rather than giving the text a depth dimension of its own.

Installation

Swift Package Manager

Add the package to your Package.swift:

.package(url: "https://github.com/CorvidLabs/3md", from: "1.0.0")

Then depend on the ThreeMD library product:

.product(name: "ThreeMD", package: "3md")

JavaScript / TypeScript

A faithful TypeScript port of the Swift parser is published to GitHub Packages, alongside the <three-md> web component (@corvidlabs/three-md-element). All three implementations (Swift, TypeScript, and the Rust crate in rust/) are kept in sync by the shared conformance suite (conformance/).

GitHub Packages requires a GitHub token to install (even for public packages), so point the @corvidlabs scope at the registry and add a token in a project or user .npmrc, then install:

echo "@corvidlabs:registry=https://npm.pkg.github.com" >> .npmrc
echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN" >> .npmrc
bun add @corvidlabs/threemd

No install needed just to use it: try the hosted editor and viewer, or load the self-contained component bundle directly with <script type="module" src=".../three-md.js">.

import { parse, serialize } from "@corvidlabs/threemd";

const document = parse(source);
console.log(document.axis); // "time"

// Round trips back to text:
const text = serialize(document);

Rust

The threemd crate is published on crates.io with zero runtime dependencies:

cargo add threemd
let document = threemd::parse(source)?;
println!("{}", document.axis); // "time"

Library usage

import ThreeMD

let document = try Parser().parse(source)
print(document.axis)          // Axis(rawValue: "time")
for plane in document.planesByZ {
    print(plane.label ?? "", plane.body)
}

// Round trips back to text:
let text = Serializer().render(document)

Command-line tool

The threemd CLI ships with the package and self-documents (run threemd --help). A path of - reads from standard input.

swift run threemd validate <file>   # parse a file; print "ok" or exit non-zero with the error
swift run threemd info <file>       # print version, axis, title, and each plane's position
swift run threemd html <file>       # render the document to HTML on stdout

Format at a glance

  • A required --- frontmatter block declares 3md: (the version, and the file's magic marker), an optional axis:, an optional title:, and free metadata.
  • @plane z=... label="..." directives start planes; the Markdown between directives is the plane body.
  • A plain Markdown file with a 3md header and no directives is a valid one-plane document.

See SPEC.md for the full grammar and conformance rules.

Examples

The Examples/ directory holds all 270 example documents across 13 axis types - from medical charts, weather, and file transfers to games, maps, and animations. Browse them all live in the gallery viewer; a few highlights:

Want to see it work? docs/PROOF.md records how 3md was verified for machines (a blind AI authored valid 3md from the spec; all three parsers agreed) and for people (plain, readable, diffable text).

Development

This repo uses the CorvidLabs trust toolchain. The single gate is:

fledge lanes run verify

which runs the Swift format check, build, and tests plus the Rust crate. See AGENTS.md for the standing rules every contributor and agent follows.

Each implementation has its own tests (the Swift suite has 122 tests, the TypeScript suite 76), and all three implementations run the shared 43-vector conformance suite in conformance/, which is the cross-implementation contract that keeps the parsers behaving identically.

Status

The format and spec are at version 1.0 (stable, frozen grammar). The latest release is v1.0.0. Older 3md: 0.1 documents remain valid: the parser is version-lenient and never rejects a document by its version string.

License

MIT (c) CorvidLabs. See LICENSE.

About

🧊 Markdown with a Z axis. A plain-text format for documents with depth (time, layers, frames, space), with conformance-verified parsers in Swift, TypeScript, and Rust.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors