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

Code Mirror syntax highlighting bugs #3440

Closed
ghost opened this issue Jul 1, 2020 · 3 comments
Closed

Code Mirror syntax highlighting bugs #3440

ghost opened this issue Jul 1, 2020 · 3 comments
Labels
bug It's a bug

Comments

@ghost
Copy link

ghost commented Jul 1, 2020

As discussed in #3435 (comment), also relevant #3054, the syntax highlighter in Code Mirror has even more severe issues with latex-math and even other things than the basic editor. Here's an example

# Example note

## braces

I don't think this citation to [Some Book, p. 12] should be highlighted, although I also don't really mind it. It shouldn't however happen within latex-math, as it right now does:
$$
	[x].
$$
It even detects within math stuff that is not a link:
$$
	[f+g](x).
$$

## Italics

This works
$$
	x_k = a
$$
so does (with respect to syntax highlighting) this
$$
	x_k_y = incorrect LaTeX code,
$$
(not even rendere by KaTeX), but this correct latex code
$$
	{x_k}_y = THIS  NOT BE HIGHLIGHTED IN ITALICS.
$$
fails the highlighter. It italics even flows out of the math environment.

Can you just please add a detector (and a specific highlighting colour) for math blocks?

image

@laurent22
Copy link
Owner

@CalebJohn, do you think it's possible to add a special rule for Katex blocks, so that they are either highlighted as Katex, or highlighting is disabled within the block?

Ace Editor handles this as expected:

image

Also [Some Book, p. 12] indeed shouldn't be highlighted because it's not a complete Markdown link.

@ghost
Copy link
Author

ghost commented Jul 2, 2020

I just noticed that also TV:three_letters_or_more is underlined. Why? the TV: bit is critical, other combinations like AB: don't trigger the underlining.

@CalebJohn
Copy link
Collaborator

@yadayadaydadaa Thanks for reporting these issues. Personally I disagree that katex is more broken than in the old editor (although your note does seem to be more broken!) I would say that it is just as broken :). Looking at @laurent22 's screenshot the old editor seems to fail in all the same locations (except the last one where it still fails but differently), but the highlighting is more subtle. I digress. This can be fixed as suggested by @laurent22 . I'll start looking into it right away.

In regards to the TV:three_letters_or_more this was an un-needed highlighting feature, which I'm not sure the purpose of. I disabled it in #3448.

And for [Some Book, p. 12] according to the commonmark spec this is a valid markdown link (which is supported by the Joplin renderer). I suspect this isn't a commonly used feature, so I added a commit to #3448 that disables highlighting for link text. There is still a css class associated with text in a square bracket, so users can turn highlighting back on by adding the .cm-link-text class to userchrome.css.

Source View
image
Rendered
image

Updated
image
(rendered doesn't change)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's a bug
Projects
None yet
Development

No branches or pull requests

2 participants