Skip to content

MathJax source permanently replaced upon editing card/HTML-viewer #4

@p4nix

Description

@p4nix

Upon trying to make it reproducible, I actually stumbled upon another error. They might be related though, I can't tell.

Anki/macOS-version:

Anki 2.1.26 (70784154) Python 3.8.0 Qt 5.13.1 PyQt 5.14.1
Platform: Mac 10.15.4
Flags: frz=True ao=True sv=1
Add-ons, last update check: 2020-05-18 13:30:21


===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Show LaTeX and MathJax result in editorbrowser ['882784122', 2020-05-17T00:01, 'None', '']

===IDs of active AnkiWeb add-ons===
882784122

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Add card default copies current cards tag and deck in ['676957592', 2020-04-03T11:47, 'None', '']
Anki Simulator ['817108664', 2020-04-03T21:11, 'None', '']
AnkiWebView Inspector ['31746032', 2019-05-03T00:43, 'None', '']
BetterTags ['bettertags', 2020-04-28T17:40, 'None', '']
Cloze Overlapper ['cloze_overlapper', 2019-02-01T13:37, 'None', '']
Customize Sidebar ['1988760596', 2020-01-28T11:44, 'None', '']
Enhance main window ['877182321', 2020-05-03T18:58, 'None', mod]
Extended Card Stats During Review ['1008566916', 2017-08-29T20:59, 'None', '']
Frozen Fields ['516643804', 2020-03-01T05:12, 'None', '']
HoochieBaby Queue Controller  Day-Lrn Q ['1847358755', 2020-04-25T05:16, 'None', '']
HoochieMama Randomize Rev Queue ['1460733408', 2020-04-25T05:16, 'None', '']
HoochiePapa Randomize New Queue ['1173108619', 2020-04-25T05:17, 'None', '']
Image Occlusion Enhanced for Anki 21 alpha ['1374772155', 2020-04-28T04:21, 'None', '']
MIA Japanese ['278530045', 2020-03-05T00:19, 'None', '']
Pop-up Dictionary beta ['153625306', 2019-03-23T18:32, 'None', '']
Progress Bar ['2091361802', 2020-02-01T13:10, 'None', '']
Puppy Reinforcement ['puppy_reinforcement', 2020-03-02T20:22, 'None', mod]
ReMemorize Rescheduler with sibling and logging v140 ['323586997', 2020-04-17T09:07, 'None', mod]
Resize images in editor ['1103084694', 2020-04-27T15:19, 'None', mod]
Review Heatmap ['review_heatmap', 2020-04-30T15:23, 'None', '']
Search Everywhere - Ctrl+F Find ['search_everywhere', 2020-03-31T22:13, 'None', mod]
Searching PDF Reading  Note-Taking in Add Dialog ['1781298089', 2020-05-16T09:56, 'None', mod]
Symbols As You Type ['2040501954', 2020-04-30T16:32, 'None', '']
True Retention ['613684242', 2019-07-29T13:23, 'None', '']
Visual Feedback for Reviews ['review_feedback', 2020-01-29T20:43, 'None', '']

A new profile was started. Upon selecting the Basic note type, this error message showed up:

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site.
Debug info:
Anki 2.1.26 (70784154) Python 3.8.0 Qt 5.13.1 PyQt 5.14.1
Platform: Mac 10.15.4
Flags: frz=True ao=True sv=1
Add-ons, last update check: 2020-05-18 13:30:21
Add-ons possibly involved: ⁨Show LaTeX and MathJax result in editorbrowser⁩

Caught exception:
Traceback (most recent call last):
  File "aqt/webview.py", line 34, in cmd
  File "aqt/webview.py", line 114, in _onCmd
  File "aqt/webview.py", line 512, in _onBridgeCmd
  File "aqt/gui_hooks.py", line 2091, in __call__
  File "/Users/xxx/Library/Application Support/Anki2/addons21/882784122/__init__.py", line 33, in onBridgeCmd
    ord = onBlur(editor, message)
  File "/Users/xxx/Library/Application Support/Anki2/addons21/882784122/anki_code.py", line 30, in onBlur
    if gui_hooks.editor_did_unfocus_field(False, self.note, int(ord)):
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Anki had to be restarted to get enable the add-on after this crash again. Upon changing the note type again, this error reappears. After this crash appears, entering a mathjax formula: \(1 = 1\) won't render the formula after switching to another field, but will clear the formula upon switching back to the original field.

Anyway, after restarting and not switching the note field in order for this error to not occur, the following workflow was done:

Enter MathJax formula in Front field: \(1 = 1\)
Switching the field to Back will show the MathJax in Front and going back to the Front field gives back the source \(1 = 1\). Pressing CMD+Shift+X (equivalent to Ctrl+Shift+X) to reveal the HTML while in the front field will reveal \(1 = 1\) as expected, but then closing the HTML editor will permanently change it to some SVG (?) stuff (can be displayed upon reopening the HTML editor):

<span class="MathJax_Preview" style="display: none;"></span><span id="MathJax-Element-6-Frame" class="mjx-chtml MathJax_CHTML" tabindex="0" style="font-size: 117%;"><span id="MJXc-Node-26" class="mjx-math"><span id="MJXc-Node-27" class="mjx-mrow"><span id="MJXc-Node-28" class="mjx-mn"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.387em; padding-bottom: 0.344em;">1</span></span><span id="MJXc-Node-29" class="mjx-mo MJXc-space3"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.088em; padding-bottom: 0.301em;">=</span></span><span id="MJXc-Node-30" class="mjx-mn MJXc-space3"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.387em; padding-bottom: 0.344em;">1</span></span></span></span></span><script type="math/tex" id="MathJax-Element-6">1 = 1</script>

So now, for the actual thing I wanted to report:
The screwed up card is dismissed going back to the home screen (without creating the cards). Then, the add card dialog is reopened. This time, no playing around:

Front: \(1 = 1\)
Back: lalala

Add card.

The Default deck is opened to learn the new card. E is used to edit the card. The cursor will be automatically in the Front field, leaving me with the same permanent SVG (?) stuff like previously.

I think the takeaway is:
The focus can be inside the first field if the HTML-Editor is used, or the card edited from the Reviewer. This will permanently destroy the MathJax source code. The first error I stumbled into is probably not related, but I included it anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions