A world-class math input for the web

Caret#

Caret is a world-class math input for the web.

WARNING

Caret is not ready for public use/contributions. Caret is not yet usable. Everything can and will change. Do not rely on it. I am not accepting contributions or PRs right now. It is just published so you can poke around if you're curious.

The README information below is written in the present tense, but most of it is not yet true. This document demonstrates my aspirations, not what actually exists!

Features#

  • Parsing. Caret has built-in support for parsing user input into an easily-consumable tree. This makes it easy to analyze and perform computation on user input.

  • Syntax Highlighting. Define your own custom syntax highlighting. Create custom rules that use the parsed tree to customize rendering.

  • Live Multiplayer. Use Caret's built-in CRDT to effortlessly support live multiplayer editing, with or without a central server.

  • Any Frontend Library. Caret can be integrated with any frontend library or used with plain JavaScript.

  • Custom Rendering. Provide your own components to customize rendering of all token types.

  • World-Class Accessibility. Caret has native support for keyboard navigation, screen reader output, speech input, braille displays, and more.

  • LaTeX Input/Output. Caret can instantly input and output LaTeX for interoperability with other tools.

  • MathQuill Compatibility. Coming from MathQuill? The MathQuill compatibility layer makes Caret a drop-in replacement.

  • Customize Everything. Absolutely everything in Caret is modular and customizable. Define your own token types, customizing parsing behavior, and more.

Alternatives to Caret#

Caret is not the only library that allows users to type math on the web. Here are some possible alternatives.

MathQuill#

MathQuill is a robust, battle-tested library for typing math on the web. Desmos uses a modified version of MathQuill, which also means it is used by the College Board on the SAT.

Key Points:

  • ✅ User experience is excellent
  • ✅ Extremely battle-tested
  • ⛔️ Poor developer experience (jQuery-based, bad fit for modern ecosystem)
  • ⛔️ Few customization options (not plugin-based, limited to a limited few settings)

MathLive <math-field>#

The MathLive <math-field> is an open-source web component that allows typing math.

On paper, MathLive does many things right. But in practice I find that it has many little papercuts that make it slightly unpleasant as both a user and a developer.

  • Reasonable user experience
  • Extreme dedication to LaTeX compatibility
  • Built-in virtual keyboard
  • Wide scope (does many things with lots of configuration options)

Katex (LaTeX rendering only)#

If your only goal is to render static LaTeX math (not allow typing), you should almost certainly use Katex. It's a gold-standard, time-tested tool that does one thing extremely well.

  • ✅ Renders to static HTML and CSS on the server or the client
  • ✅ Accessible rendering
  • ✅ Extremely fast
  • ✅ Supports a very large subset of LaTeX
  • ✅ Simple, friendly developer experience
  • ⛔️ No user input (rendering only)