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

Desktop: Modify the codemirror linter plugin to fix katex #3582

Merged
merged 3 commits into from
Aug 2, 2020

Conversation

CalebJohn
Copy link
Collaborator

This stops the katex mode from triggering on a single $
This also allows the user to escape $ characters

This is the bug I mentioned in #3560

To do this fix I needed to change the multiplexing plugin provided by codemirror, I only made a couple of changes to the file which I marked with comments.

Old
image

New
image

This stops the katex mode from trigger on a single $
This also allows the user to escape $ characters
@laurent22 laurent22 changed the base branch from master to dev August 1, 2020 18:10
@laurent22
Copy link
Owner

Thanks for the fix, that looks good. I assume there's no other way than modifying CodeMirror source code to get this working? In that case, please could you use patch-package to apply the fix? That would make it easier to track what changes we've made and to update CodeMirror later on.

This gives us more control over katex parsing and the ability to upgrade
in the future
@CalebJohn
Copy link
Collaborator Author

Your comment prompted me to think about the problem and unfortunately for me there actually was a better solution. On the first iteration I was using a multiplexingMode which is basically a shortcut for creating a special mode. But since it was insufficient in our case the proper way to address this would instead be to write an actual mode for Joplin. That's what I've now done, it still borrows from the multiplexing mode but has the functionality we need (and only what we need).
This doesn't parse exactly like the markdown-it katex rule, it instead uses a series of regexes to handle valid markers. Eventually the markdown-it rule and this could probably be merged but I felt that was better left for the future.

image

@laurent22
Copy link
Owner

That looks good now, thanks for the fix!

@laurent22 laurent22 merged commit 7f73931 into laurent22:dev Aug 2, 2020
@CalebJohn CalebJohn deleted the escape-katex branch August 2, 2020 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants