23 releases

new 4.0.0-alpha.24 Jan 18, 2022
4.0.0-alpha.22 Apr 27, 2021
4.0.0-alpha.18 Feb 16, 2021
4.0.0-alpha.13 Oct 19, 2020
0.0.0 Jun 6, 2020

#65 in Text processing

Download history 16/week @ 2021-10-02 44/week @ 2021-10-09 56/week @ 2021-10-16 4/week @ 2021-10-23 3/week @ 2021-10-30 26/week @ 2021-11-06 222/week @ 2021-11-20 4/week @ 2021-11-27 46/week @ 2021-12-04 4/week @ 2021-12-11 2/week @ 2021-12-25 25/week @ 2022-01-01 31/week @ 2022-01-08 32/week @ 2022-01-15

92 downloads per month

MIT/Apache

520KB
12K SLoC

Rant Logo

Crates.io Docs.rs Discord

Rant is a high-level procedural templating language with a diverse toolset for easily creating dynamic code templates, game dialogue, stories, name generators, test data, and much more.


Prerelease notice

This project is in alpha. This means that the API is unstable, functionality may be broken/missing, and everything is subject to change.

Please do try it out and give feedback; however, do not use in production environments until a stable version is released.

Features may appear/disappear at any time for any reason. Assume that every alpha release will have breaking changes.

Introducing Rant 4

Rant 4 is a complete redesign and reimplementation of the original Rant language, written in Rust.

More than a text generator

Unlike previous versions, Rant 4 is for more than just text: you can now generate arbitrary structured data of any kind with improved and expanded syntax that preserves the ergonomics of its predecessor.

Built on a decade of experience

Based on 10 years (and counting) of ideas, iteration, and community feedback, Rant 4 is built on a desire for an all-in-one data templating tool made especially for creative applications like games and interactive art.

Use integrated or standalone

Whether you want to integrate Rant directly into a product or use it as a standalone tool to assist with writing, Rant has a place in any part of your workflow.

Why Rant?

🧰 Painless API
Rant has a no-nonsense API designed for ease of use. No getting lost in configuration hell. Integrating Rant into your project only takes a few lines of code.

💻 Cross-Platform
Write once, run anywhere! The runtime works on Windows, Mac, Linux, and WebAssembly.

🎲 Built with ♥ for RNG
Rant is made with random generation in mind as a major use-case.

Make use of a wide array of built-in utilities for generating random numbers, strings, booleans, lists, list subsets, and much more for all your randomization needs. The internal RNG can be manually seeded to produce repeatable outputs.

🎨 It's a Scripting Language
Inspired by other popular scripting languages, Rant is a fully-fledged imperative programming language with a dynamic type system. Enjoy first-class support for common primitives like strings, numbers, collections, closures, and more.

🖨 It's a Templating Language
Rant is all about "printing": each lexical scope has an output to print (append values) to, which then prints itself to the parent output, and so on. This enables you to intuitively build strings, collections, and more in a familiar templating setting.

🔱 Advanced Branching
Fine-tune branching behavior with a multitude of configuration options and branch selection modes for iterative, random, and weighted selection.

🧬 Delightful Combinatorics
Perform nested mappings, filters, zips, combinations, and more with minimal effort. Rant's powerful piping syntax lets you perform complex operations with shorter, more readable code.

🎛 Automatic Formatting
Passively format text output with automatic capitalization, whitespace normalization, and number formatting — including built-in support for numerous writing systems.

🧩 Simple Module System
Creating a library and depending on it in another program should be trivial, and Rant makes it so. Just create your library script, then import it elsewhere with a single function call.

You can add your own package manager on top if you want, but it's not required.

📚 Rant Standard Library
A comprehensive standard library provides the tools needed to quickly iterate on your ideas.

Getting started

CLI

Rant's CLI can run Rant code from files or the command line. Install it from Cargo with:

$ cargo install rant --version 4.0.0-alpha.24 --features cli

Then run it:

$ rant

Library

Add Rant to your Cargo.toml:

[dependencies]
rant = "*"

You can run a Rant program with just a few lines of code:

use rant::Rant;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
  // Create a default Rant context
  let mut rant = Rant::new();

  // Compile a simple program
  let program = rant.compile_quiet(r#"
  [$greet:name] {
    {Hello|Hi|Hey} <name>!
  }
  [greet:world]
  "#)?;

  // Run the program and print the output
  let output = rant.run(&program)?;
  println!("{}", output);

  Ok(())
}

Examples

This repository contains a directory of example programs written in Rant for you to learn from. Check them out!

Documentation

The latest reference documentation can be found at docs.rant-lang.org.

Since Rant 4 is early in development, some documentation may be outdated/incomplete, but it is actively updated to ensure that it reflects current features with reasonable accuracy.

Changelog

The changelog is updated constantly throughout the development process, providing a complete summary of upcoming changes at a glance even before the next release.

MSRV

The minimum supported Rust version is 1.57.0.

License

Licensed under either of

at your option.

Dependencies

~1.6–2.3MB
~38K SLoC

|Oća