-
Notifications
You must be signed in to change notification settings - Fork 159
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
Fixed index.js delimeter logic #3
Conversation
* Since the code is suggesting using only $ - $ for inline, $$ - $$ for block math syntax, specific delimiter for $ - $ and $$ - $$ is required, not general escape logic. also it will fix the issue waylonflinn#2. * Some code optimization and variable name change was done. * I found that 'throwOnError:false' option doesn't actually work on katex. They will still throw an error if the syntax is invalid. So instead of sending this directly, I fixed this code to catch the error internally, return the original latex token, and log it on the console when throwOnError option is explicitly set to true.
Thanks! Looking this over now! Really makes me wish we had some unit tests! |
Writing some unit tests that cover current behaviour, so we can ensure nothing will break here. I'm excited about the patch for |
According to the new tests (adapted from markdown-it-math), this does fix #2, but it also breaks the following:
Going to look through the code and see if this is an easy fix. |
Okay, I missed that test things. Therefore, in this commit, changes of optimization and new logic of escaping inline $ sign would be valid. [1] though I still can't understand why it is needed. |
My inline escaping is based on following regular expression: If only javascript regexp interpreter has a lookbehind options. |
Okay, I think I've got fixes for the broken stuff. Merging. 🎉 |
specific delimiter logic for $ - $ and $$ - $$ is required, not general escape logic.
Also it will fix the issue could not parse xxx$-2x<4$xxx #2.
So instead of sending this directly, I fixed this code to catch the error internally, return the original latex token, and log it on the console when throwOnError option is explicitly set to true.