Giter VIP home page Giter VIP logo

mathjax-single-file's Introduction

mathjax-single-file

A tool to build MathJax bundles.

Getting Started

This project assumes you have NodeJS 6+ installed.

  1. Install dependencies
npm install
  1. Use

This library exports a single method build which takes several options and returns a string (the JS string of the build); it can write that string to disk.

const build = require('main.js').build;
build(
  fontname,                                // TeX, STIX-Web, Asana-Math, Neo-Euler, Gyre-Pagella, Gyre-Termes, cf. http://docs.mathjax.org/en/latest/font-support.html Latin-Modern
    input,                                // MathML, TeX, AsciiMath
    output,                               // SVG, CommonHTML, (TODO: HTML-CSS)
    {                                     // options
        toFile: true,                     // write to file
        compress: true,                   // uglify output
        customExtensions: [],             // array of extension filenames; if empty, default extensions of the input are used
        folder: ''                        // folder name to write file output to; relative to `dist` defaults to `options.input+options.output+options.fontname`, e.g., `dist/MathMLSVGTeX`
    });
  1. Build pre-configured bundles
npm run build

See build.js for details for those builds.

  1. View test pages in your browser
npm start

mathjax-single-file's People

Contributors

danielweck avatar drochgenius avatar pkra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mathjax-single-file's Issues

ERROR: GET ../fonts/TeX/Main-Bold.js?V=2.7.1 net::ERR_ABORTED

Full error message in the terminal of Google Chrome 63

MathJax-2.7.1.min.js:1 GET http://localhost/jax/output/CommonHTML/fonts/TeX/Main-Bold.js?V=2.7.1 net::ERR_ABORTED
MathJax-2.7.1.min.js:1 Uncaught TypeError: Cannot read property '2' of undefined
    at MathJax-2.7.1.min.js:1
    at Function.execute (MathJax-2.7.1.min.js:1)
    at e (MathJax-2.7.1.min.js:1)
    at Object.Execute (MathJax-2.7.1.min.js:1)
    at Object.loadComplete (MathJax-2.7.1.min.js:1)
    at Object.loadTimeout (MathJax-2.7.1.min.js:1)
    at Function.execute (MathJax-2.7.1.min.js:1)
    at HTMLScriptElement.e (MathJax-2.7.1.min.js:1)

Problem
I don't know what file this Main-Bold.js is supposed to be. It is not in the MathJax official repo. Could it be a bug?
I am using the ./dist/TeXCommonHTMLTeX/MathJax.min.js as my single file MathJax distro.

I did

git clone https://github.com/pkra/MathJax-single-file
npm install
npm run

Everything works on all my pages, except one, where I get the error above.
I tested this using the official MathJax distro, and I don't get any errors.

Great job btw. I really needed something like this, and could not find it anywhere else. Let me know if I can help with this project somehow.

/Jonas

Qt QWebpage Windows and mml3.js question

Your single-file version works wonderfully with Qt 5.4.2 QWebpage (Qts version of webkit) on Linux and Mac OSX but your 2.5.1 version and official Mathjax 2.6.0 both fail to make the mml3.js extension work on Windows Qt 5.4.2. My guess it is the xslt transformation in mml3.js that is failing. I noticed that Mathjax 2.6.0 has added some Browser check and changed the xsl code to work on Edge and MSIE for Windows. Qt reports Safari Apple Webkit as user agent so it is not using the special msn xslt namespace changes.

Do you have any plans to update this to 2.6.0 anytime soon. Or should I download and install npm and try your grunt approach to creating a single file version of MathJax 2.6.0 so that I can add to the Browser test to take advantage of 2.6.0 new xsl?

Thanks,

Allow multiple inputs

It would be nice to be able to create a bundle, say with AsciiMath and TeX inputs.

TeX-AMS_HTML configuration + [EXPECTED ERROR] while trying to render math on the page

Hi @pkra ,

Thanks for providing this example on how we can bundle mathjax in a single file.

When I use the files in the dist folder, it works, but somehow what I rebuild them with grunt it doesn't.

I get [EXPECTED ERROR] on the page, and nothing in the logs.

Basically, I'd like to build a bundle with TeX-AMS_HTML configuration, but I'm not sure where to get the list of required files and extensions, in the proper order. I would appreciate if you could give me some quick guidance on how to approach this.

Of course, if I can build this bundle, I'm happy to contribute the script back to this repo.

Thanks in advance,

Dominique

Handle MathJax classes

Include AMSmath and AMSsymbols extensions to avoid rendering issues when MathML was generated by MathJax and includes MathJax classes for TeX layout rules.

Missing config file error message

Hi,

I am getting error messages for not having a configuration file, despite configuring my MathJax properly elsewhere. Using the MathJax single file, I am able to get everything working properly in the following manner:

<script src='public/js/MathJax.min.js'>

and my configuration in the constructor of a React component:

MathJax.Hub.Config({
  jax: ['input/TeX', 'output/AMS_SVG'],
  tex2jax: { inlineMath: [['$', '$'], ['\\(', '\\)']] }
});

I have also tried the alternative in placing the configuration as follows, which produces the same results:

<script type='text/x-mathjax-config'>
  MathJax.Hub.Config({
    jax: ['input/TeX', 'output/AMS_SVG'],
    tex2jax: { inlineMath: [['$', '$'], ['\\(', '\\)']] }
  });
</script>
<script src='public/js/MathJax.min.js'></script>

The single file seeks out a config file in the path: /jax/output/AMS_SVG/config.js?V=2.7.1, which produces an error message (in both the left-hand corner of the browser window File failed to load: /jax/output/AMS_SVG/config.js?V=2.7.1 for brief period of time and in the developer console Failed to load resource: the server responded with a status of 400 (Bad Request)). How can I silence this message?

Thank you again for your help,
timolawl

TypeError: options.customExtensions is not iterable

At build function, when using with options:

build(
    'TeX',
    'AsciiMath',
    'CommonHTML', {
        toFile: true,
        compress: true,
        folder: 'ascii'
    }
);

It fails because you try to ...options.customExtensions, but it's undefined.
I suppose you meant options to be written above default options object, but it's not made. So use smth like options = Object.assign({}, defaultOptions, options); (it solved issue on my side)

TeX input \require issue

Trying to \require an extension that is included in the build throws a processing errors (but the macros from the extension work fine).

Not a major issue but annoying.

Strict mode version?

Hi,

Any plans on having a version of these single files workable in ES5's strict mode?

modify menu configuration

The preconfigured builds (and possibly all builds) should modify the menu configuration to prevent users from activating non-existing features.

  • remove renderer submenu (this library only support one renderer right now)
  • remove localizations submenu (this build does not include locales though they/some could now be specified in the build configuration)

Include tex extension

I have an usecase where it would be useful to have the tex extension. Is it even possible to bundle it?

MMLSVG: improve configuration

  • menu
    • remove renderer submenu (this build has just one renderer)
    • remove localizations (this build does not include locales)
  • remove MathJax notifications
  • possible Readium improvements
    • increase Menu z-index (possibly on the fly) to work beyond first page of a chapter
    • turn on zoom
    • add some responsive magic
      • overflow-x=scroll, responsive line-breaks, or responsive overflow=scale

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.