Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

' character replaced with &; unexpectedly in display math block #536

Open
kai-kea opened this issue Feb 27, 2024 · 3 comments · May be fixed by #627
Open

' character replaced with &; unexpectedly in display math block #536

kai-kea opened this issue Feb 27, 2024 · 3 comments · May be fixed by #627
Labels
needs-review Need peer testing/review (prolly a bug)

Comments

@kai-kea
Copy link

kai-kea commented Feb 27, 2024

A simplified example as follows:

Markdown:

> [!eqn] Open Addressing with Quadratic Probing
> $$ h(k, i) = (h'(k) + c_1 \cdot i + c_2 \cdot i^2) \mod m $$
<!--ID: 1708997849864-->

Notes added to Anki using this regex:

^\> *\[\!(?:ret|def|eqn|thm)\][-\+]? ?((?:[^\n])+)?\n*((?:\n(?:^.{1,3}$|^.{4}(?<!<!--).*))+)

Which matches some types of callouts.

In Anki, I get:
Front: Open Addressing with Quadratic Probing
Back: h(k, i) = (h&;(k) + c_1 \cdot i + c_2 \cdot i^2) \mod m
Tags: 039, obsidian

I read through the source code and from what I understand, inside Math blocks, the mathjax/latex is masked. When it's unmasked, ' char is masked and then replaced with &#039;. The RegexNote.parse method removes the #039 if the option to make obsidian tags to anki tags is on.

@kai-kea kai-kea changed the title ' character escaped unexpectedly in display math block ' character replaced with &; unexpectedly in display math block Feb 27, 2024
kai-kea added a commit to kai-kea/Obsidian_to_Anki that referenced this issue Feb 27, 2024
addresses ObsidianToAnki#536 

This regex matches obsidian tag style `#my-tag` only if it's not part of an HTML expression, e.g. from ObsidianToAnki#536, `&ObsidianToAnki#39;` will be matched and skipped over.
@ShootingKing-AM ShootingKing-AM added the needs-review Need peer testing/review (prolly a bug) label Feb 28, 2024
@nicoberling
Copy link

Just ran into the same issue after activating tags, with the following example, using :

> [!anki]+ Q
> $id'$

Giving the following backside:

<blockquote>
  <p><anki-mathjax>id&amp;;</anki-mathjax></p>
</blockquote>

All using a similar regex for the cards: (?:\> \[!anki\][+-]?) ([^\n]+)\n(.+(?:\n(?:^.{1,3}$|^.{4}(?<!<!--).*))*)

@menghuu
Copy link

menghuu commented Jul 18, 2024

I have the same issue(but with code block).

START
问答题
something
背面: A few more elements to see.
You can include links to websites.
Code blocks are supported
Github-flavoured code blocks too, but Anki won't do syntax highlighting

    print("Hello world!")
    a = 'test'

END

the codeblock show in anki app:

    print("Hello world!")
    a = &;test&;

@brockar
Copy link

brockar commented Nov 26, 2024

The problem still continues.
Any way to solve it?

@nicoberling nicoberling linked a pull request Dec 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-review Need peer testing/review (prolly a bug)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants