Skip to content

Commit

Permalink
AnkiDroid does actually support MathJax
Browse files Browse the repository at this point in the history
  • Loading branch information
nihil-admirari committed May 21, 2023
1 parent 4634108 commit 3ff9d58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 4 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ In addition to ``anki-simple-cloze-overlapper`` features, support was added for:
- Nested clozes.
- Clozes in MathJax.

The code was tested on Anki Desktop and AnkiDroid; the later requires the latest
The code was tested on Anki Desktop and AnkiDroid; the latter requires the latest
`Android System WebView`__ to be installed. In principle, it should be usable on Anki Web
and Anki Mobile (but it hasn't been tested).

__ https://play.google.com/store/apps/details?id=com.google.android.webview

Modern Cloze Overlapper on AnkiDroid has several limitations:

- Android 10+ is required until https://github.com/ankidroid/Anki-Android/pull/13812 is merged.

- MathJax is not supported on AnkiDroid, see
https://github.com/ankidroid/Anki-Android/issues/13819.
- Android 10+ is required until https://github.com/ankidroid/Anki-Android/pull/13899 is merged.

- Nested clozes don't work on AnkiDroid, see
https://github.com/ankidroid/Anki-Android/issues/13770.
Expand Down Expand Up @@ -60,7 +57,7 @@ The parameters are as follows:
Set to ``true`` for e.g. long lyrics/poems.

``RevelAll`` (Boolean ``true`` or ``false``, defaults to ``false``)
Reveal all clozes on the back of the card. By default only currently active clozes are revealed.
Reveal all clozes on the back of the card. By default, only currently active clozes are revealed.
(Context clozes are revealed even on cards' fronts.)

``InactiveHints`` (Boolean ``true`` or ``false``, defaults to ``false``)
Expand All @@ -87,7 +84,7 @@ Reloading ``_cloze-overlapper.mjs``
-----------------------------------

JavaScript modules, such as ``_cloze-overlapper.mjs``, are loaded exactly once and never reloaded
(unless you restart Anki). However, you can use dummy query parameter too reload the module
(unless you restart Anki). However, you can use dummy query parameter to reload the module
without restarting Anki:

.. code:: javascript
Expand Down
3 changes: 2 additions & 1 deletion _cloze-overlapper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function doRenderClozes(config, postRender) {
}
// https://docs.mathjax.org/en/latest/web/typeset.html#updating-previously-typeset-content
if (typeof MathJax !== 'undefined') {
// Anki doesn't seem to support autonumbering, but nonetheless.
// Anki doesn't seem to support auto-numbering, but nonetheless.
MathJax.startup.document.state(0);
MathJax.typesetClear();
MathJax.texReset();
Expand All @@ -282,6 +282,7 @@ function doRenderClozes(config, postRender) {
}

export function renderClozes(config) {
// AnkiDroid loads MathJax only when \( and/or \[ are present.
if (typeof MathJax === 'undefined') {
return doRenderClozes(config);
}
Expand Down

0 comments on commit 3ff9d58

Please sign in to comment.