apy
apy copied to clipboard
Using $$-style escapes for math
I really enjoy using this program because it speeds up adding flashcards for my preexisting notes. :) Unfortunately my note taking programs all use the $$ style to start and end mathjax blocks. So I can't copy the notes over. I figured out that you can't change this setting in anki. I have written a function to convert from the $$-notation to the other one in my fork: https://github.com/JohannesHatke/apy If youre interested in including this feature, I would open up a pull request and finish implementing it by adding a configuration key for it.
I have implemented it so that _parse_file calls the function for each line. If you have any suggestions and are interested I'd love to know.
I really enjoy using this program because it speeds up adding flashcards for my preexisting notes. :)
Thanks, I'm glad to hear that!
Unfortunately my note taking programs all use the $$ style to start and end mathjax blocks. So I can't copy the notes over. I figured out that you can't change this setting in anki. I have written a function to convert from the $$-notation to the other one in my fork: https://github.com/JohannesHatke/apy
Cool! For completeness, could you outline how your workflow with apy
and your notes look like?
If youre interested in including this feature, I would open up a pull request and finish implementing it by adding a configuration key for it.
I'm not 100% sure. It seems like a very specific use case, and I don't immediately recognize this as a "natural" part of apy
. This is why I'm asking for the workflow above, I would like to hear more how this feature might make sense possibly for more people.
Thanks for the reply.
Cool! For completeness, could you outline how your workflow with apy and your notes look like?
Usually i write long notes with a lot of math equations in vim with Markdown-Preview. I import some of these into Obsidian, where the $$-style is used. I then add flash cards by just copying the relevant parts over into apy.
I think the benefit of adding this feature is that it would allow more users to create flashcards from existing notes easily. Obsidian is quite popular and this would make apy a lot more useful for Obsidian users.
Usually i write long notes with a lot of math equations in vim with Markdown-Preview. I import some of these into Obsidian, where the $$-style is used. I then add flash cards by just copying the relevant parts over into apy.
Ok, so, something like this?
-
Oblivion open, copy some Markdown note with possibly some math.
-
In a terminal, you do
apy sync
if necessary, thenapy add
and use the note you copied from step 1.
The point of asking for the details here is first to ensure we are not in a x-y problem setting. Also, I would want to know how the feature should be incorporated. E.g., should it be an option or only a configuration parameter in the config file? How does it actually look? If this feature existed, do I understand that your preferred integration would be to have this as an option in the apy.json
file, such as markdown_math_to_mathjax
which would be false by default (to ensure backward compatibility)?
I think the benefit of adding this feature is that it would allow more users to create flashcards from existing notes easily. Obsidian is quite popular and this would make apy a lot more useful for Obsidian users.
You may be right, but at the same time, this is the first time someone make this type of request. I want to properly understand the idea before I add it, as that makes it easier to properly maintain things.
I'm closing this due to inactivity.
Hey :)
Could this be reopened? I'm also interested in this.
My use case is similar to that of @JohannesHatke. Also it's really useful to preview MathJax before creating the cards, to ensure that the formulas etc. get rendered correctly. The $
/$$
math delimiters are much more common in markdown and are supported by a lot of markdown editors.
I'm not 100% sure. It seems like a very specific use case, and I don't immediately recognize this as a "natural" part of apy.
I would argue that it is related to apy, since apy introduces the markdown format for writing Anki notes, which AFAIK Anki does not use (it uses HTML). Anki introduces \(...\)
and \[...\]
delimiters to HTML for MathJax and LaTeX (which ofc are not part of HTML), but for markdown, $
/$$
math delimiters are more common, as mentioned above. So IMO it would make sense to support it in Anki.
Also, I would want to know how the feature should be incorporated. E.g., should it be an option or only a configuration parameter in the config file? How does it actually look? If this feature existed, do I understand that your preferred integration would be to have this as an option in the apy.json file, such as markdown_math_to_mathjax which would be false by default (to ensure backward compatibility)?
That is a good question.
Personally, I'd like to enable it globally, so a config option in apy.json
sounds reasonable to me, perhaps with an associated command line switch (but I would not use that). I think it does not make sense to enable/disable this feature on a per-notes basis (correct me if I'm wrong).
It would be nice to convert from $...$
to \(...\)
and from $$...$$
and \[...\]
, since markdown uses the former, and Anki uses the latter, respectively.
Another thought: I think it would be good to do the conversion on a per-field basis instead of per-note or even per-file, as a safety measure. Because, with $...$
and $$...$$
, the left and right delimiter cannot be distinguished by itself, so unintentional syntax errors are more likely. E.g., a dangling $$
somewhere could "shift" all other $$
and result in text being interpreted as MathJax and vice versa.