ObsidianToAnki / Obsidian_to_Anki

Script to add flashcards from text/markdown files to Anki
GNU General Public License v3.0
1.54k stars 136 forks source link

"$" turns into "/(" or ")/" (inside a code block) after import into Anki #293

Open oliveroliverio opened 3 years ago

oliveroliverio commented 3 years ago

Here I try to import a 'cloze' card that's markedown'd and includes a codeblock

image

Here's what I expect after import:

image

Here's what I actually get

image

Here I have to manually change all the "/)" and "/(" back into "$," which I'd rather not do. Any suggestions?

thx! Oliver

gsneath commented 2 years ago

This may be obvious, but in case it's not, that conversion happens to support Anki's use of "/)" and "/(" instead of "$" for starting/ending a MathJax equation. I frequently use MathJax equations in my cards, and Obsidian_to_Anki appears to auto-convert my equations written with "$" in Obsidian to "/)" and "/(" in Anki to maintain MathJax output. Not sure if there is a way to get around this or not for your use, but it's certainly a time-saving feature for my use.

victorfeight commented 3 months ago

This should be optional/configurable. It's very annoying to have crafted a tricky flashcard such as the following:

START Basic What is the output of the following code if a_b were properly initialized?

public class _C {
    private static int $ = 100;
    public static void main(String[] main) {
        String a_b = "Initialized";
        System.out.print($);
        System.out.print(a_b);
    }
}

Back: The output would be 100Initialized because $ is initialized to 100 and a_b is initialized to "Initialized".

Only have it backfire completely due to the Mathjax conversions (which I do not ever use).

Duplicate issue mentioned here: https://github.com/ObsidianToAnki/Obsidian_to_Anki/issues/547