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: Disable syntax highlighting inside Katex code #3054

Closed
anjulalk opened this issue Apr 14, 2020 · 12 comments
Closed

Desktop: Disable syntax highlighting inside Katex code #3054

anjulalk opened this issue Apr 14, 2020 · 12 comments
Labels
bug It's a bug stale An issue that hasn't been active for a while...

Comments

@anjulalk
Copy link
Contributor

When using < inside Katex, the editor falsely recognize it as a HTML tag and messes up syntax highlighting. See below:

image

Use following snippet for reproducing:

Equation1

$$
\sum_{i<j}
$$


This text should not be highlighted. But it is.

Environment

Joplin version: 1.0.200
Platform: Linux
OS specifics: Ubuntu 19.10 (5.3.0-46-generic)

Steps to reproduce

  1. Copy the above snippet into editor
  2. See editor highlighting text incorrectly

Describe what you expected to happen

The editor should ignore < or other mathematical symbols inside Katex.

@anjulalk anjulalk added the bug It's a bug label Apr 14, 2020
@laurent22
Copy link
Owner

That's probably tricky to fix as it seems to be a bug in Ace Editor itself, but if you have some ideas feel free to give it a try.

@tessus
Copy link
Collaborator

tessus commented Apr 14, 2020

Yep, the Ace editor has a few bugs in that regard. It also highlights italics in the middle of a word (text_not-italics_text), which is definitely one of the most annoying bugs ever.

@Rishabh-malhotraa
Copy link
Contributor

Can't you just escape that letter, to prevent its default behaviour or am I missing something? 🤔

image

@anjulalk
Copy link
Contributor Author

anjulalk commented Apr 14, 2020

@Rishgod I guess you can do that. You can also add spaces near the < and it will also work. But the regular user won't know about that since it's not really standard in Katex.

If we can process Katex code like how comments are parsed in the Ace editor, we can maybe get the desired result? Katex blocks start with $$ and end with $$. So if anything between can be considered as a comment (like between <!-- and -->) it will ignore the < as well.
Just an idea, of course. I don't know if it's possible.

@Rishabh-malhotraa
Copy link
Contributor

Don't get me wrong you definitely can do that, but this looks too much of a work for something which could just be solved by adding a white-space.

image

@laurent22
Copy link
Owner

The problem is that $$ as a fence is not standard Markdown so Ace Editor highlights the block as if it was just any other text.

At some point Devon added custom rules to override syntax highlighting there

class CustomHighlightRules extends ace.acequire(
so maybe it's possible to do something similar to handle Katex blocks.

@anjulalk
Copy link
Contributor Author

It looks pretty straight forward. I'll give this one a go.
https://cloud9-sdk.readme.io/docs/highlighting-rules is a good reference if anyone else wants to try.

@thofma
Copy link

thofma commented May 15, 2020

I see something similar with underscores. Is this the same issue?

image

@anjulalk
Copy link
Contributor Author

Yes, it's very similar to this one.

@tessus
Copy link
Collaborator

tessus commented May 24, 2020

ajaxorg/ace#3942

@stale
Copy link

stale bot commented Jul 8, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.

@stale stale bot added the stale An issue that hasn't been active for a while... label Jul 8, 2020
@stale
Copy link

stale bot commented Jul 15, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's a bug stale An issue that hasn't been active for a while...
Projects
None yet
Development

No branches or pull requests

5 participants