Commit Graph

20 Commits

Author SHA1 Message Date
Damien Elmes
ae18ba2a05 Switch editor to full MathJax package to fix broken autoloads
Re: https://forums.ankiweb.net/t/anki-2-1-53-release-candidate/20122/2

Autoloads in MathJax are asynchronous, and the caller is expected to
use asynchronous APIs when they are in use [1]. The editor uses the synchronous
tex2svg(), which throws a "MathJax retry" error when an autoload package
has not yet loaded. Attempting to use the package before it has loaded
appears to break future invocations as well, so the package fails to work
at all until a new webview is created.

The following HTML will reproduce the issue when added to a single card
in a new profile:

```
<strong>6&nbsp; &nbsp;&nbsp;</strong>Every combination of <anki-mathjax>\boldsymbol{v}=(1,-2,1)</anki-mathjax> and <anki-mathjax>\boldsymbol{w}=(0,1,-1)</anki-mathjax> has components that add to&nbsp; _____.<br>
```

Ideally we'd switch the MathJax rendering to be asynchronous, but that
didn't work well when I tried it in #1862. For now I've just switched
to the full package, which adds about 130KB to the final minified JS
(2.76MB), and likely slows down editor loading somewhat.

[1] https://github.com/mathjax/MathJax/issues/2557#issuecomment-727655089
2022-05-21 14:01:38 +10:00
Damien Elmes
8b1afc7e3a Reveal cloze answers in MathJax preview
Closes #1862
2022-05-19 12:48:12 +10:00
Henrik Giesel
3b8aa97396
Use same config for editor and reviewer Mathjax (#1865)
* Remove custom config and use tex-chtml-full for editor Mathjax

* Add mathjax package in /ts

* Share mathjax config between tex-svg and tex-chtml

* Use "[+]" in Mathjax config again

* Remove mention of MathJaxReady

* Satisfy eslint
2022-05-13 13:23:35 +10:00
Henrik Giesel
89530c5f24
Change sequence of Mathjax escaping (#1854) 2022-05-10 11:54:06 +10:00
Damien Elmes
bc6ede7c11 Fix &amp; showing up in MathJax
https://forums.ankiweb.net/t/anki-2-1-52-release-candidate/19412/22

Accidentally introduced in #1818
2022-05-03 14:21:31 +10:00
Henrik Giesel
2be1f4c56d
Instead of transforming to {\lt}, transform to &lt; (#1818)
* Instead of transforming to {\lt}, transform to &lt;

- In Mathjax editor
- This way you can also use Mathjax convenience shortcuts like <=> in
  chemistry mode: \ce{<=>}

* Remove unused translateEntitiesToMathjax() (dae)

https://github.com/ankitects/anki/pull/1818#discussion_r857238310
2022-04-25 13:42:54 +10:00
Henrik Giesel
0dff5ea3a3
Use trailingComma: all setting in .prettierrc (#1435) 2021-10-19 09:06:00 +10:00
Henrik Giesel
3f1da03615 Allow for explicit any 2021-09-17 21:30:32 +02:00
Henrik Giesel
a1dde7c966 Wrap Mathjax compilation into try/catch 2021-09-16 14:31:20 +02:00
Henrik Giesel
e06ff2ae3c Focus on mount when using Mathjax shortcuts 2021-09-15 13:45:17 +02:00
Henrik Giesel
af556c391d Fix alignment of empty icon 2021-09-15 13:43:37 +02:00
Henrik Giesel
c3f56ad5cd Refactor editable/mathjax.ts 2021-09-15 13:33:25 +02:00
Henrik Giesel
b5900da0b4 Set color of Mathjax depending on nightMode 2021-09-15 13:33:24 +02:00
Henrik Giesel
f76cf24e9d Move wrap to lib to allow editable to use it 2021-09-15 13:33:24 +02:00
Henrik Giesel
8fa6d0045d Show title on mathjax image 2021-09-15 13:33:22 +02:00
Henrik Giesel
fca31465b4 Display error Mathjax correctly 2021-09-15 13:33:22 +02:00
Henrik Giesel
c88223e069 Show math icon if Mathjax is empty 2021-09-15 13:33:22 +02:00
Henrik Giesel
d7e0f77439 Unify anki-mathjax-* to just anki-mathjax 2021-09-15 13:32:32 +02:00
Henrik Giesel
7950078e2b Nicely portray mathjax with right color + alignment in Editor 2021-09-15 13:32:31 +02:00
Henrik Giesel
5129aca66f Implement MathjaxBlock 2021-09-15 13:32:30 +02:00