tortilla

Crates.iotortilla
lib.rstortilla
version0.1.0
created_at2025-08-18 08:57:39.316249+00
updated_at2025-09-01 21:12:49.086631+00
descriptionSomewhat syntax-aware text wrapping for source code and plain text documents
homepagehttps://codeberg.org/satoqz/tortilla#readme
repositoryhttps://codeberg.org/satoqz/tortilla
max_upload_size
id1800116
size60,268
Jonas Köhnen (satoqz)

documentation

README

tortilla

Somewhat syntax-aware text wrapping for source code and plain text documents.

What?

This is both a Rust crate and a corresponding command line tool for text wrapping, with some assumptions that are specific to code comments and plain text documents (e.g., markdown documentation or emails).

In particular, the following features are supported:

  • Preservation of indentation (both tabs and spaces)
  • Preservation of comment tokens (//, #, etc.)
  • Bulleted/numbered list alignment of subsequent lines (for -, *, 1., etc.)
  • Multiple paragraphs (delimited by at least two line breaks or a change in indentation/comment token)
  • Customizable tab width for line width calculation (--tabs)
  • Line breaking algorithms:
    • Optimal-fit (--salsa), this is the default
    • First-fit (--guacamole) as a less resource-intensive alternative

Why?

I like to hard wrap my code comments and plain text documents. It's a rough reality, but it makes them easier to read, review and maintain, and soft-wrapping is a highly subpar alternative. In many cases I want an automated initial pass at hard wrapping, and then follow up with any (rare) manual edits.

Text editors tend to provide hard wrapping functionality to some degree, but usually have limited understanding of indentation, comment tokens or bulleted/numbered lists. This project was born out of my frustrations wrapping text in the Helix editor via the :reflow command, which uses the popular textwrap crate.

Usage

Installation

Via cargo:

cargo install tortilla

Command line

$ tortilla --help
Usage: tortilla [-h, --help] [--width <WIDTH>] [--tabs <TABS>] [--crlf] [--salsa] [--guacamole]

Input is read from stdin, output is written to stdout. For example:

$ echo "foo bar baz" | tortilla --width 8
foo bar
baz

Tortilla wraps to 80 characters with LF (\n) newlines by default, counting tab indents as 4 spaces.

Text editors

For Helix, I suggest the following:

keys.normal."=" = ":pipe tortilla"

Rust crate

Add the tortilla crate to your Rust project:

cargo add tortilla

See docs.rs/tortilla for documentation.

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 0

cargo fmt