Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Definitions and utilities to create MathJax components #180

Merged
merged 37 commits into from
Feb 22, 2019
Merged

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Jan 7, 2019

This implements a mechanism to break up MathJax3 into individual components that can be loaded separately as needed, so page authors can combine the individual pieces they need without having to make a custom webpack for their needs.

There is a dynamic loader the can be used to load the components based on a configuration (similar to how v2 loads pieces on demand), or they can be loaded by hand using separate scripts in the HTML file.

There is also a startup package that allows the components to register themselves when they are loaded, and that builds typeset and conversion methods automatically based on the components that are loaded. That is, if you load the TeX input jax and the CommonHTML output jax, the startup module will build MathJax.Typeset() to typeset a page using TeX input and CHTML output, MathJax.tex2chtml() to convert a single TeX string to an HTML DOM tree, MathJax.tex2mml() to convert a tex string to serialized MathML, MathJax.texReset() to reset labels and equation numbers, and MathJax.chtmlStylesheet() to produce the stylesheet DOM element for CommonHTML.

The utilities needed to create the components are in the top-level components directory. Itsbin subdirectory has a build command to make the files needed for a component, and a makeAll command that will make all the components in the current directory and below.

Components are controlled by two files: build.json and webpack.config.js in their source directories. The first is used to define what files will be part of a component (these are the files that it will share with other components that build on it). For example, the core component loads all the main MathJax files from the core and util directories, plus the HTML handler and browser adaptor files. Other components can then use these files when they are built in reference to them. The second file controls the webpack process, and in particular which other components it depends on. These call on the webpack.common.js file in the components directory to do most of the work of configuring the webpack process.

See the src directory for a number of examples of these (though the svg-output package won't build unless you merge in the svg branch). There are packages for TeX input, CHTML output, and several other pieces.

There is also a component for the loader/startup modules that will dynamically load the needed components based on a configuration file (see the samples/loader directory for an example). The components can also be loaded by hand or combined into larger components (see the samples/preload directory for several examples). Finally, you can create your own custom components that link against existing ones (see the samples/tex2mml directory for an example).

I'm still putting together additional components (like for the TeX extensions), but those can be added as developed.

The mathjax3-ts/components directory contains the typescript files for the loader and startup modules, and a file for managing the global MathJax object that is used to configure MathJax and hold the library definitions and the typeset and conversion methods that are created automatically.

There are a lot of small files in this PR because the components each retire two or three control files, and there are a dozen or so components defined here. It might be best to start with the components/src files that do those definitions just to see how those look, then the components/samples to see how the resulting packages are used. Then the mathjax3-ts/components files to see how loader and startup work, and finally the components/bin files to see how the needed library files are created.

I hope there is enough information here to make it clear what is happening, but if not, let me know.

dpvc added 28 commits December 12, 2018 17:41
…move unneeded plugins; update core and tex-input packages, and add new ones for other components; update loader and startup code.
…ader, and won't cause webpack any problems (so no need for AsyncLoad-disabled.ts any longer).
…ckage constructor into parts, improve asyncLoad to use loader, when possible, and provide asynchLoad drivers for node and system.js
…perly, and update .gitignore to handle the needed subdirectories.
…combined into larger ones, or can be loaded by hand along with the startup/loader package).
@dpvc dpvc requested a review from zorkow January 7, 2019 20:11
Copy link
Member

@zorkow zorkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! There's a couple of questions and I think we should aim to make things a bit more robust, by extracting typescript syntax specific elements (and some others like indentation) into a meta-config file for the configuration.

Note, I've only very shallowly reviewed package.ts and startup.ts. I did not look at the webpack.config.js files.

mathjax3-ts/components/loader.ts Outdated Show resolved Hide resolved
mathjax3-ts/components/loader.ts Outdated Show resolved Hide resolved
mathjax3-ts/components/loader.ts Outdated Show resolved Hide resolved
mathjax3-ts/components/loader.ts Outdated Show resolved Hide resolved
mathjax3-ts/components/global.ts Outdated Show resolved Hide resolved
components/webpack.common.js Show resolved Hide resolved
components/samples/a11y/config.js Show resolved Hide resolved
components/samples/a11y/test.html Outdated Show resolved Hide resolved
components/samples/loader/test.html Outdated Show resolved Hide resolved
components/samples/preload/combined.html Show resolved Hide resolved
@dpvc
Copy link
Member Author

dpvc commented Feb 20, 2019

I think we should aim to make things a bit more robust, by extracting typescript syntax specific elements (and some others like indentation) into a meta-config file for the configuration.

I've moved these to constants at the top of the build file for now, and we can extract them into a separate configuration later if necessary.

Other than that, I think I've taken care of what you requested so far.

@dpvc dpvc merged commit 224de06 into master Feb 22, 2019
@dpvc dpvc deleted the components branch February 22, 2019 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants