npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@innodoc/react-mathjax-node

v0.1.3

Published

Integrate MathJax v3 with React

Downloads

13

Readme

react-mathjax-node

A react component that renders MathJax formulars.

Version License

FeaturesInstallationUsageAPILicense

This library aims to deliver high performance and ease-of-use while still being flexible in terms of configuration. Multiple areas in the same application can be handled independently of each other. react-mathjax-node hides all the hairy details of integrating MathJax with React.

Check out the examples.

Features

  • Uses MathJax version 3.
  • Supports multiple MathJax-enabled areas that are managed independently.
  • Integrates well with your webpack setup.
  • Self-contained, CDN-less hosting possible.

Installation

$ npm install @innodoc/react-mathjax-node # or
$ yarn add @innodoc/react-mathjax-node

Usage

You need at least one MathJax.Provider and a MathJax.MathJaxNode.

import MathJax from '@innodoc/react-mathjax-node'

<MathJax.Provider>
  <p>
    Example formular: <MathJax.MathJaxNode displayType="inline" texCode="f(x)=x^2" />
  </p>
</MathJax.Provider>

See the examples for other ways of using react-mathjax-node.

API

Components

MathJax.MathJaxNode

The main component you will need most of the time.

<MathJax.MathJaxNode displayType="display" texCode="x^2" />

| Prop | Description | Type | Default | | --------------- | ------------------------------------- | -------- | -------------- | | classNameHide | className while typesetting. | string | null | | classNameShow | className when done typesetting. | string | null | | texCode | TeX code to typeset. | string | '' | | displayType | display (block) or inline element | string | 'inline' |

MathJax.Context

Access the MathJax rendering context.

Every MathJax formular needs to have a MathJax.Provider somewhere up the component tree. Within this subtree you can access the context to have more control.

const { addCallback, removeCallback, typesetDone } = useContext(MathJax.Context)

| Property | Description | Type | | ---------------- | ------------------------------------------------------------------------------------------------------------------ | ---------- | | addCallback | Add a callback when all formulars are typeset. (Example) | function | | removeCallback | Remove callback. | function | | typesetDone | If all formulars are typeset. (Example) | Boolean |

MathJax.Provider

The Provider manages all formulars in its component sub-tree.

There can be an arbitrary number of Providers in your application. So you can have different areas with formulars and distinct display logic if needed.

MathJax.ConfigProvider

Use the ConfigProvider to customize the MathJax options.

Using the ConfigProvider is completely optional. It gives you freedom to customize the MathJax configuration options. You should only have one ConfigProvider in your component tree as there will be one instance of MathJax for the entire application. Make sure all used MathJax.Providers are somewhere in the component sub-tree of your ConfigProvider. Typically the ConfigProvider would reside somewhere near the top of your component tree.

  <MathJax.ConfigProvider options={myCustomMathJaxOptions}>
    <MathJax.Provider>
      <MathJax.MathJaxNode texCode="..." />
    </MathJax.Provider>
    <MathJax.Provider>
      <MathJax.MathJaxNode texCode="..." />
    </MathJax.Provider>
  </MathJax.ConfigProvider>

Please refer to the MathJax documentation for a full description of the MathJax configuration options.

See the example on how to customize the font URL.

MathJax.useMathJax

React hook that adds MathJax typesetting capabilities.

Typically you should just use MathJaxNode which uses useMathJax under the hood.

const MathJaxComponent = () => {
  const ref = useMathJax('x^2')
  return <span ref={ref} />
}

| Argument | Description | Type | Default | | ------------- | ----------------------| --------------------- | ---------- | | texCode | TeX code to typeset. | string | '' | | displayType | Element display Type. | inline or display | 'inline' |

License

MIT