MathJax does not currently allow for embedded HTML, but there is an old hack using MathML's <semantics> element to make it possible to put HTML into an expression. This was discussed in issue 2210:
The FilterUtil bug that was discussed there was fixed, so the patch in the example code is no longer needed. So you could use
MathJax = {
tex: {packages: {'[+]': ['input']}},
startup: {
ready() {
const Configuration = MathJax._.input.tex.Configuration.Configuration;
const CommandMap = MathJax._.input.tex.SymbolMap.CommandMap;
const TEXCLASS = MathJax._.core.MmlTree.MmlNode.TEXCLASS;
new CommandMap('input', {input: 'Input'}, {
Input(parser, name) {
const xml = parser.create('node', 'XML');
const id = parser.GetBrackets(name, '');
const w = parser.GetBrackets(name, '5em');
const value = parser.GetArgument(name);
xml.setXML(MathJax.startup.adaptor.node('input', {
id: id, value: value, style: {width: w}, xmlns: 'http://www.w3.org/1999/xhtml'
}), MathJax.startup.adaptor);
xml.getSerializedXML = function () {
return this.adaptor.outerHTML(this.xml) + '</input>';
}
parser.Push(
parser.create('node', 'TeXAtom', [
parser.create('node', 'semantics', [
parser.create('node', 'annotation-xml', [
xml
], {encoding: 'application/xhtml+xml'})
])
], {texClass: TEXCLASS.ORD})
);
}
});
Configuration.create('input', {handler: {macro: ['input']}});
MathJax.startup.defaultReady();
}
}
};
to define a `\input` macro that creates an input field. There are optional argument for an id to use for the input field, and for the width of the field, and a required argument for the initial contents of the field. So you could use something like
to set up an integral with input fields for the limits (initially showing 0 and 1) and the integrand (blank).