AnonymerNiklasistanonym / Md2Anki

Convert Markdown formatted documents to anki decks
https://pypi.org/project/md2anki/
MIT License
6 stars 1 forks source link

The `$` character is automatically processed as mathjax, no skip method is specified #23

Closed baldachin closed 1 year ago

baldachin commented 1 year ago

My body content contains $ characters, which are not inline math markers and should not be escaped. I've tried using backslashes to prevent escaping without success, and I can't find anything about this in the documentation.

AnonymerNiklasistanonym commented 1 year ago

As far as I understand in my old code a simple regex is used to find math sections that for the sake of my usage of them also allows whitespaces between inline opening/closing tags.

https://github.com/AnonymerNiklasistanonym/Md2Anki/blob/1e3510580e61cea7a85d83efc957ff1f759c970d/src/md2anki/md_util.py#L57

I tried to update the inline regex with a negative lookbehind (\$ $\rightarrow$ (?<!\\)\$) to allow escaping so in case this is not what you really want can you further elaborate what you would expect/like to happen?

https://github.com/AnonymerNiklasistanonym/Md2Anki/blob/1e3510580e61cea7a85d83efc957ff1f759c970d/examples/math_formulas_example.md?plain=1#L27-L39

baldachin commented 1 year ago

I would like to be able to mark inline math with $ signs that appear within the body of the text with a symbol to avoid processing, and also to be able to not display the avoided symbols after processing. For example: $a +b$ is a math. \$ is a symbol, \$ is another symbol. to \(a+b\) is a math. $ is a symbol, $ is another symbol.

AnonymerNiklasistanonym commented 1 year ago

I updated it once more to now ignore using the $ symbol as opening/closing tag when instead of content a whitespace is found:

https://github.com/AnonymerNiklasistanonym/Md2Anki/blob/373bd89a63805cae46189c75c13715e2e54912d8/examples/math_formulas_example.md?plain=1#L40-L41

https://github.com/AnonymerNiklasistanonym/Md2Anki/blob/373bd89a63805cae46189c75c13715e2e54912d8/src/md2anki/md_util.py#L57

image

AnonymerNiklasistanonym commented 1 year ago

With the new version release on pypi this problem should be fixed now as far as I tested and understood it.

baldachin commented 1 year ago

Thank you very much!