-
Notifications
You must be signed in to change notification settings - Fork 210
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
Conversation
…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.
…in packages easier.
…combined into larger ones, or can be loaded by hand along with the startup/loader package).
…faces with actual code.
… documenting the functions.
…p to include lib directories
…. Remove blank file.
There was a problem hiding this 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.
I've moved these to constants at the top of the Other than that, I think I've taken care of what you requested so far. |
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, andMathJax.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 abuild
command to make the files needed for a component, and amakeAll
command that will make all the components in the current directory and below.Components are controlled by two files:
build.json
andwebpack.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, thecore
component loads all the main MathJax files from thecore
andutil
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 thewebpack.common.js
file in thecomponents
directory to do most of the work of configuring the webpack process.See the
src
directory for a number of examples of these (though thesvg-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 thesamples/preload
directory for several examples). Finally, you can create your own custom components that link against existing ones (see thesamples/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 globalMathJax
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 thecomponents/samples
to see how the resulting packages are used. Then themathjax3-ts/components
files to see how loader and startup work, and finally thecomponents/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.