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

[Bug] Syntax highlighted colors use the wrong font and aren't reset when toggling a code block #59

Open
dhda opened this issue May 6, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@dhda
Copy link

dhda commented May 6, 2020

Describe the bug
In code blocks, syntax highlighted tokens are rendered in the base font instead of monospaced. Then, when toggle the code block off for a line of text, the colors are not reset to black (or whatever they were previously). The colors can then never be reset and will spread throughout the document like a permanently highlighted plauge. Somehow the editor seems to support multiple notions of colored text (the infected text doesn't register as having a color in the editor top bar).

To Reproduce
Steps to reproduce the behavior:

  1. Type a line of plain text that would be highlighted in code
  2. Click the code button and toggle the block to code
  3. See highlighted tokens are rendered in the regular font
  4. Click the code button again and toggle the block back to regular text
  5. The pink colored literals stay the same color
  6. Try making the text black again
  7. The highlighted literals stay permanently highlighted for the lifetime of the document, regardless of any color changes through the editor.
  8. Any text that gets entered by placing the cursor immediately adjacent to the highlighted words is also made pink–the highlighting spreads like a virus through the whole document!
  9. If you copy and paste the text to a whole new document, it still stays pink forever!

Expected behavior
Code is rendered in monospaced font regardless of the highlighting, and the colors are reset when the block is toggled back.

Screenshots
pre-code block
Screen Shot 2020-05-05 at 19 52 00

toggle code block on (note wrong font)
Screen Shot 2020-05-05 at 19 52 19

toggle code block off (note the text that's still pink)
Screen Shot 2020-05-05 at 19 52 28

trying to type more text after the highlighted text
Screen Shot 2020-05-05 at 19 59 38

System Information (please complete the following information):

  • Device: Macbook Pro
  • OS: OS X 10.11.6
  • Browser: Firefox v75
  • Browser Extensions: tested with all extensions disabled
@dhda
Copy link
Author

dhda commented May 6, 2020

It's the coronavirus bug! 😆 I have one document now with a few perma pink words in it. I'm quarantining the entire section of text to make sure I don't accidentally spread it. We don't know the course of this disease or if they'll recover. All the other words are very worried.

@dhda
Copy link
Author

dhda commented May 6, 2020

I can clear the pinkness if I delete a character from the highlighted words (so that it no longer is parsed as highlightable syntax), and then toggle the code block on and off again.

@johnozbay johnozbay added the bug Something isn't working label Jun 7, 2020
@johnozbay johnozbay changed the title Syntax highlighted colors use the wrong font and aren't reset when toggling a code block [Bug] Syntax highlighted colors use the wrong font and aren't reset when toggling a code block Jun 7, 2020
@johnozbay
Copy link
Member

Hi there! This is a fantastic catch! 🚀
I've added this to our bug tracker and we'll get this fixed as quickly as possible.

Looks like an underlying bug with the core editor we're using & highlight.js (the code highlighter) not playing well together.

Shortly, the editor toolbar color selector uses inline CSS to color the text. (so that it can be stored with the text when it's copy pasted / restored etc) and the editor functions on the top, look for these to toggle colors on / off.

Screen Shot 2020-06-07 at 10 43 05

Whereas highlight.js adds a bunch of custom classes to highlight things like variables, keywords, function declarations etc.

Screen Shot 2020-06-07 at 10 44 51

And looks like when you toggle the code-block off (notice p vs pre parent tag), these classes aren't removed :

Screen Shot 2020-06-07 at 10 46 48

So whatever you type keeps going into these hljs-keyword span elements, and gets colored.

The quick duct-tape solution is, after turning code block off, select all the text, and click clear formatting (or cmd/ctrl + \ ), and this will get rid of all the hljs-keyword classes = clear the color.

Screen Shot 2020-06-07 at 10 48 54

And in the meantime, we'll get this bug fixed right away 👍🏻

Many thanks for this!

Best,
J

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants