Skip to content

Commit 1f3b9c1

Browse files
committed
docs: update comments
1 parent 920e84b commit 1f3b9c1

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

ts/src/mathjax/base.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export abstract class BaseMathJaxHelper {
1515
}
1616

1717
/**
18-
* Loads MathJax from a CDN.
18+
* Loads MathJax from a CDN and initializes it.
1919
*
2020
* @protected
2121
*/
@@ -33,6 +33,8 @@ export abstract class BaseMathJaxHelper {
3333
script.onload = () => {
3434
// @ts-expect-error After loading the script, window.MathJax will exist.
3535
this.mathjax = window.MathJax;
36+
37+
// We return the startup promise to ensure that MathJax is fully initialized before using it.
3638
resolve(this.mathjax.startup.promise);
3739
};
3840
script.onerror = () => reject(new Error(`Failed to load ${this.cdnUrl}.`));
@@ -52,8 +54,6 @@ export abstract class BaseMathJaxHelper {
5254
* Renders LaTeX inside an element. Loads MathJax from a CDN if necessary.
5355
*/
5456
render(element: Element, inline: boolean): Promise<void> {
55-
// We do this to chain every render call. This also ensures that we only load once from the CDN:
56-
// https://docs.mathjax.org/en/v3.2-latest/web/typeset.html#handling-asynchronous-typesetting
5757
if (this.mathjax === undefined) {
5858
return this.loadFromCdn().then(() => this._render(element, inline));
5959
}

ts/src/mathjax/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function renderLaTeX(element: Element, inline: boolean = true): Promise<v
2424
return Promise.reject(new Error("Only MathJax 3.x and 4.x are supported."));
2525
}
2626
} else {
27-
// We should in theory switch to MathJax4 as the default, but we might need to change our UI.
27+
// We should in theory switch to MathJax 4 as the default, but we might need to change our UI.
2828
mathJaxHelper = new MathJax3Helper();
2929
}
3030
}

ts/src/mathjax/v3.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export class MathJax3Helper extends BaseMathJaxHelper {
3535
}
3636

3737
protected _render(element: Element, inline: boolean): Promise<void> {
38-
// Ensure that MathJax is fully initialized.
38+
// We need to manually chain every render call.
39+
// https://docs.mathjax.org/en/v3.2/web/typeset.html#handling-asynchronous-typesetting
3940
return this.queue = this.queue.then(() => {
4041
// Get the delimiters.
4142
const inlineDelimiters = this.mathjax.config.tex?.inlineMath?.[0] ?? ["\\(", "\\)"];

0 commit comments

Comments
 (0)