wp-calypso icon indicating copy to clipboard operation
wp-calypso copied to clipboard

SyntaxHighlighter block incorrectly highlighting Clojure codes

Open rinazrina opened this issue 2 years ago • 3 comments

Quick summary

When adding Clojure programming language using the SyntaxHighlighter Block, the block incorrectly highlights a word inside a comment when the word has the same name as a function. It also highlights any string with the same name as a function name.

Disclaimer: I'm not familiar with Clojure code, but this is based on a report from a user who's using Clojure language.

Steps to reproduce

  1. On a Simple site, add a Syntax Highlighter Block
  2. Add a Clojure codes
  3. Add a word in the comment that is the same word as one of Clojure functions, such as first or sort functions

What you expected to happen

The Block should not highlight the word in the comment and should not highlight a word that acts as a string.

What actually happened

The Block highlights the words that do not act as functions.

Code samples can be found here.

Example 1:

Screenshot on 2023-11-01 at 21-51-27

From the screenshot above, the word "first" is highlighted, even though it is in a comment, which shouldn't get a special highlighting, even though it is a function name.


Example 2:

Screenshot on 2023-11-01 at 21-53-09 (1)

From the screenshot above, the word "sort" in "selection-sort" is highlighted in a different color than "selection-", since "sort" is a built-in function in Clojure. But, in this case, the "sort" part of "selection-sort" has nothing to do with the "sort" function.

Impact

Some (< 50%)

Available workarounds?

No but the platform is still usable

Platform (Simple and/or Atomic)

Simple

Logs or notes

Reproduced this on both FSE theme (Masu) and Classic theme (Twenty Twenty).

User report: 7246001-zd-a8c

rinazrina avatar Nov 01 '23 14:11 rinazrina

Support References

This comment is automatically generated. Please do not edit it.

  • [ ] 7246001-zen

github-actions[bot] avatar Nov 01 '23 14:11 github-actions[bot]

📌 REPRODUCTION RESULTS – Tested on Simple – Replicated

  • Steps are as per the original report.
  • Add the syntax highlighter block, select Clojure language, paste in code examples, comments are highlighted, not just commands

rickmgithub avatar Nov 17 '23 09:11 rickmgithub

I believe this uses the SyntaxHighlighter JS library. My assumption is that this would need to be addressed further up the chain and that there may be a fix already in place if we dig in to see if a relevant update is available. Moving the status to be "Needs Core/3rd Party Fix".

davemart-in avatar Oct 18 '24 19:10 davemart-in