1. Introduction
  2. User Guide
  3. 1. Installation
  4. 2. Quick Start
  5. 3. Changelog
  6. Usage
  7. 4. Command Line Interface
  8. 5. Editor Integration
  9. Features
  10. 6. Formatting Features
    1. 6.1. Markup
    2. 6.2. Code
    3. 6.3. Math Equations
    4. 6.4. Tables
  11. 7. Escape Hatch
  12. 8. Limitations
  13. Advanced
  14. 9. How It Works
  15. 10. Developer Guide
    1. 10.1. Core
    2. 10.2. Documentation
    3. 10.3. Playground

typstyle

#

Core Development

This section covers building, testing, and benchmarking the Rust crates of typstyle.

#

Building Components

#

CLI and Core

cargo build                     # Debug build
cargo build --release           # Release build
cargo build -p typstyle         # CLI only
cargo build -p typstyle-core    # Core only

#

WebAssembly Plugin

For the embedded Typst plugin:

just build-plugin
# or manually:
cargo build -p typstyle-typlugin --release --target wasm32-unknown-unknown

For the WASM bindings used in the playground:

just build-wasm
# or manually:
cd crates/typstyle-wasm && wasm-pack build --target web --out-dir ../../playground/typstyle-wasm

#

Running Tests

❗ Important

Update snapshots with cargo insta when changing core library or fixtures.

Add CLI tests to crates/typstyle/tests/ when modifying CLI behavior. For style arguments, add tests to test_style_args.rs.

#

Test Commands

List all tests:

cargo nextest list --workspace

Run all tests and review snapshots:

cargo nextest run --workspace --no-fail-fast
cargo insta review

Snapshot tests only:

cargo nextest run --workspace -E 'test([snapshot])' \
  --no-fail-fast --no-default-features
cargo insta review

Exclude end-to-end tests:

cargo nextest run --workspace -E '!test([e2e])' --no-fail-fast

CLI tests only:

cargo nextest run -p typstyle --no-fail-fast

Integration tests:

cargo nextest run -p tests --no-fail-fast

#

Snapshot Management

Review and accept snapshot changes:

cargo insta review    # Interactive review
cargo insta accept    # Accept all changes

#

Benchmarks

Using Criterion.rs:

cargo bench --workspace -- --list    # List benchmarks
cargo bench --workspace              # Run all benchmarks

View HTML reports at target/criterion/report/index.html.

#

Code Quality

#

Formatting and Linting

Format code:

cargo fmt --all

Run clippy:

cargo clippy --workspace --all-targets --all-features

#

Testing Guidelines

  • Add tests to appropriate modules when implementing new features
  • Use snapshot tests for formatter output validation
  • Update snapshots after intentional changes to formatting behavior
  • Add CLI integration tests for new command-line features
  • Benchmark performance-critical changes