Skip to content

mentat-collective/MathLive.cljs

Repository files navigation

MathLive.cljs

A ClojureScript + Reagent wrapper over the MathLive equation editor.

Build Status License cljdoc badge Clojars Project Discord Shield

Quickstart

Install MathLive.cljs into your Clojurescript project using the instructions at its Clojars page:

Clojars Project

Or grab the most recent code using a Git dependency:

;; deps
{io.github.mentat-collective/mathlive.cljs
  {:git/sha "$GIT_SHA"}}

Require mathlive.core in your namespace:

(ns my-app
   (:require [mathlive.core :as ml]
             [reagent.core :as r]))

The main entrypoint to the library is the mathlive.core/Mathfield component. This component acts like a Reagent [:textarea ,,,] and takes similar props, but allows for interactive mathematical input and conversion to LaTeX.

Here's an example component:

(r/with-let
  [!tex      (r/atom "")
   on-change #(reset! !tex (.getValue (.-target %)))]
  [:<>
   [ml/Mathfield
    {:value     @!tex
     :on-change on-change}]
   [:pre @!tex]])

2022-12-01 16 56 20

See the project's interactive documentation notebook for more examples. The MathLive guides are great resources as well.

Clerk Support

If you want to use MathLive.cljs with Clerk, check out the mathlive/clerk template. This deps-new template will generate a Clerk project for you, fully configured to use MathLive.cljs in your Clerk notebooks.

Interactive Documentation via Clerk

The project's interactive documentation was generated using Nextjournal's Clerk. If you'd like to edit or play with the documentation, you'll need to install

Once this is done, run this command:

bb clerk-watch

This will open a browser window to http://localhost:7777 with the contents of the documentation notebook. Any edits you make to dev/mathlive/notebook.clj will be picked up and displayed in the browser on save.

Thanks and Support

To support this work and my other open source projects, consider sponsoring me via my GitHub Sponsors page. Thank you to my current sponsors!

I'm grateful to Clojurists Together for financial support during this library's creation. Please consider becoming a member to support this work and projects like it.

License

Copyright © 2022 Sam Ritchie.

Distributed under the MIT License. See LICENSE.