Giter VIP home page Giter VIP logo

mathjax-edit's Introduction

MathJax edit

MathJax-edit is a small Javascript application that allows you to mark part of a MathML formula in an HTML page and apply a correction to it.

MathJax-edit depends on MathJax. It uses a slight modification of MathJax, which marks inferred mrows in the HTML page.

MathJax-edit consists of two javascript files:

  1. MathJax-edit.js, the core library. It takes a selection as input and prepares it for modification. Then it takes a correction formula as input and replaces the selected part with the correction.

  2. call-mathjax-edit.js, an application of MathJax-edit.js. It provides a button which, when pressed, reads the selected range. Then it sets up a form in which the correction can be entered. Finally the correction is applied to the selected range.

Sample page

You may check editing of MathJax formulas in the sample page sample1.html.

  1. Open it in your browser.
  2. Select part of a formula.
  3. Press the button 'Modify selected range'.
  4. Write a correction formula in the correction text box.
  5. Click the radio button for your type of formula.
  6. Press the button 'Apply correction'.

Quick start

Call MathJax, MathJax-edit and call-mathjax-edit in your web page, as follows:

<script type="text/javascript"
		src="path/to/MathJax.js?config=TeX-MML-AM_HTMLorMML">
</script>
<script type="text/javascript" src="path/to/MathJax-edit.js"></script>
<script type="text/javascript" src="path/to/call-mathjax-edit.js"></script>

Edit 'path/to/' to match the paths to your scripts. Make sure you use the modified version of MathJax (or make sure that your formulas explicitly contain all mrows).

All formulas in your web page should be in MathML.

For debugging purposes you may set verbose mode as follows:

<script type="text/javascript">callMathJaxCorrection.setVerbose(true)</script>

Writing your own application

Consult the documentation for the API of MathJax-edit. Consult call-mathjax-edit.js and its documentation as an example.

  1. Create a MathJaxCorrection object: var correction = new MathJaxCorrection().
  2. Let the object read the selection: correction.readSelection().
  3. Let the object apply the correction: correction.applyCorrection(correctionText, correctionType), where correctionText is the text of the correction formula.
  4. Ask MathJax to rerender the corrected formula: MathJax.Hub.Update(ancestor), where ancestor is any ancestor containing the corrected formula.

mathjax-edit's People

Contributors

spepping avatar

Watchers

James Cloos avatar Abou Mohamed  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.