Skip to content

Latest commit

 

History

History
92 lines (72 loc) · 3.27 KB

README.md

File metadata and controls

92 lines (72 loc) · 3.27 KB

Backtrack

Backtrack is a simple and performant Typst library that determines the current compiler version and provides an API for comparing, displaying, and observing versions.

Unlike the built-in version API which is only available on Typst 0.9.0+, Backtrack works on any* Typst version. It uses the built-in API when available so that it'll continue to work on all future Typst versions without modification.

Additionally, it:

  • doesn't noticeably impact compilation time. All version checks are extremely simple, and newer versions are checked first to avoid overhead from supporting old versions.
  • is automatically tested on every supported Typst version to ensure reliability.
  • can be downloaded and installed manually in addition to being available as a package.

Example

#import "@preview/backtrack:1.0.0": current-version, versions

You are using Typst #current-version.displayable!
#{
  if current-version.cmpable <= versions.v2023-03-28.cmpable [
    That is ancient.
  ] else if current-version.cmpable < versions.v0-5-0.cmpable [
    That is old.
  ] else [
    That is modern.
  ]
}

Installation

There are two ways to install the library:

  • Use the package on Typst 0.6.0+. This is as simple as adding the following line to your document:
    #import "@preview/backtrack:1.0.0"
  • Download and install the library manually:
    1. Download and extract the latest release.
    2. Rename src/lib.typ to src/backtrack.typ.
    3. Move/copy COPYING into src/.
    4. Rename the src/ directory to backtrack/.
    5. Move/copy the newly-renamed backtrack/ directory into your project.
    6. Add the following line to your document:
      #import "[path/to/]backtrack/backtrack.typ"

Documentation

See DOCS.md. It's quite short. 😀

Version Support

Backtrack compiles on and can detect these versions:

Version Status Notes
0.6.0+ Also available as a package
March 28, 2023–0.5.0
March 21, 2023 Initial public/standalone Typst release
February 25, 2023 🟡 Detects as February 15, 2023
February 12–15, 2023
February 2, 2023 🟡 Detects as January 30, 2023
January 30, 2023

The partially-supported versions may be possible to detect, but they're tricky since most of their changes are content-related. Content values were opaque up until the March 21, 2023 release, making it difficult to automatically check for the presence of these changes.

Copying

Copyright © 2023 Luke Chambers

Backtrack is licensed under the Apache License, Version 2.0. You can find a copy of the license in COPYING or online at https://www.apache.org/licenses/LICENSE-2.0.