diff --git a/src/addons/filter/mathjaxloader/services/handlers/mathjaxloader.ts b/src/addons/filter/mathjaxloader/services/handlers/mathjaxloader.ts index 9728707e1..0ad77d343 100644 --- a/src/addons/filter/mathjaxloader/services/handlers/mathjaxloader.ts +++ b/src/addons/filter/mathjaxloader/services/handlers/mathjaxloader.ts @@ -24,6 +24,7 @@ import { CoreEvents } from '@singletons/events'; import { CoreSite } from '@classes/sites/site'; import { makeSingleton } from '@singletons'; import { CoreWait } from '@singletons/wait'; +import { CoreDom } from '@singletons/dom'; /** * Handler to support the MathJax filter. @@ -177,6 +178,10 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan ): Promise { await this.waitForReady(); + // Make sure the element is in DOM, otherwise some equations don't work. + // Automatically timeout the promise after a certain time, we don't want to wait forever. + await CoreUtils.ignoreErrors(CoreUtils.timeoutPromise(CoreDom.waitToBeInDOM(container), 15000)); + await this.window.M!.filter_mathjaxloader!.typeset(container); }