Skip to content

Commit

Permalink
Merge pull request #312 from mathjax/startup-document
Browse files Browse the repository at this point in the history
Startup document
  • Loading branch information
dpvc authored Aug 21, 2019
2 parents 44aaa75 + 7bcb5ce commit aeb156c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions mathjax3-ts/components/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,14 @@ export namespace Startup {
input = getInputJax();
output = getOutputJax();
adaptor = getAdaptor();
if (handler) {
mathjax.handlers.unregister(handler);
}
handler = getHandler();
if (handler) {
mathjax.handlers.register(handler);
document = getDocument();
}
};

/**
Expand All @@ -295,9 +302,6 @@ export namespace Startup {
* Make input2output() and input2outputPromise conversion methods and outputStylesheet() method
*/
export function makeMethods() {
if (!handler) return;
mathjax.handlers.register(handler);
getDocument();
if (input && output) {
makeTypesetMethods();
}
Expand Down Expand Up @@ -476,11 +480,15 @@ export namespace Startup {
/**
* Create the document with the given input and output jax
*
* @param {any=} root The Document to use as the root document (or null to use the configured document)
* @returns {MathDocument} The MathDocument with the configured input and output jax
*/
export function getDocument() {
document = mathjax.document(CONFIG.document, {...MathJax.config.options, InputJax: input, OutputJax: output});
return document;
export function getDocument(root: any = null) {
return mathjax.document(root || CONFIG.document, {
...MathJax.config.options,
InputJax: input,
OutputJax: output
});
}
};

Expand Down
2 changes: 1 addition & 1 deletion mathjax3-ts/ui/menu/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ export class Menu {
// updated document (from the new handler)
//
const document = this.document;
this.document = startup.getDocument();
this.document = startup.document = startup.getDocument();
this.document.menu = this;
this.transferMathList(document);
if (!Menu._loadingPromise) {
Expand Down

0 comments on commit aeb156c

Please sign in to comment.