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

math_equation_editor

v1.0.11

Published

A math equation editor

Downloads

14

Readme

A math equation editor written from scratch

Demo: https://calculator-algebra.org:8166/calculator_html/equation_editor/example_equation_editor_with_panel.html

Demo, with a custom button: https://calculator-algebra.org:8166/calculator_html/equation_editor/example_equation_editor.html

Detailed demo+debug page: https://calculator-algebra.org:8166/calculator_html/equation_editor/test_equation_editor.html

  • Uses Apache 2.0 license (no more license headaches).
  • Written from scratch: not a single line from another project.
  • No css.
    • No fonts. When rendering from \(\)-text, inherits the font from the parent html element.
    • When rendering from a div with class="mathcalculator", keeps your font/styling.
  • No external dependencies whatsoever, not even jquery.
  • No more build system headaches.
    • Can be require("./equation_editor")-ed like a regular node module.
    • Can be copy and pasted: one single javascript file and you're done.
  • Matrix support from the start.
  • Will construct math tags from content enclosed in \(...\) just like MathJax; can be used as a drop-in replacement.
  • Will also construct math from <div class="mathcalculator">your formula here</div>.
  • Copy+paste your LaTeX at the cursor.
  • Prints to SVG and canvas.

<html>
<script type="text/javascript" src="equation_editor.js"></script>
<script>
  function createEditor() {
    const options = new EquationEditorOptions({
      // Can you edit the math or is it static math?
      editable: true,
      // Bind a raw LaTeX input box to the editor. Editing the box automatically updates the editor.  
      latexInput: document.getElementById('latex'),
      // Set to true to have your LaTeX sanitized to a preferred mathematical equivalent.
      sanitizeLatexSource: false,
      // Set to true to strip \displaystyle from your latex source, independent of the sanitization flag.
      removeDisplayStyle: false,
      // Show debug-related information.
      debugLogContainer: null,
      // Should I generate a copy button at the corner of the editor?
      copyButton: false,
    });
    let editor = new EquationEditor(document.getElementById('editor'), options);
    // The \cursor command indicates the desired location of the cursor. 
    new EquationEditorButtonFactory("\\frac{123}{\\cursor}\\sqrt{7}", "", "").attachToClickById("custom-button", editor);
    buttonFactories.sqrt.attachToClickById("sqrt-button", editor);
    editor.updateDOM();
    editor.rootNode.focus(- 1);
  }
</script>

<body onload="createEditor()">

  Equation editor here: <div id='editor' style="font-size: 72px; font-family:'Times New Roman'"> </div>
  <br>
  Latex of what you typed, can edit directly: <input id="latex">
  <hr>
  Sample buttons:
  <button id="sqrt-button">&Sqrt;</button>
  <button id="custom-button">custom</button>
  <hr>
  Typeset all math in the 'toBeTypeSet' tag.
  <button id="typeSetButton" onclick="typeset(document.getElementById('toBeTypeSet'));">typeset</button>

  <div id='toBeTypeSet'>
    \(\frac{-b\pm \sqrt{b^2-4ac}}{2a}\)
  </div>
</body>
</html>

Common commands

Build the example app with webpack.

npm run build

or, alternatively:

webpack src/app.js

Push a new version to npm. You also need to increment the version number in package.json.

npm publish

Run the unit tests.

npm test

Run the unit tests manually.

npx jasmine-browser-runner runSpecs