highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.32k stars 3.52k forks source link

(Crystal) formats integer divison incorrectly #3730

Open meatball133 opened 1 year ago

meatball133 commented 1 year ago

Describe the issue Using // in crystal will make the highlighter mark the rest of the file. In crystal is // used for integer division. Code:

def something()
    something // 4
end

image

Which language seems to have the issue? Crystal

Are you using highlight or highlightAuto? highlight

Sample Code to Reproduce

def something()
    something // 4
end

image

Expected behavior The expected behavior is to not mark the rest of the code with the color green.

Additional context Nope

joshgoebel commented 1 year ago

The trick here would probably be to introduce a new mode rule that only matches the literal // (with no scope, so as not to color it)... we only want to prevent It from being mis-recognized by the regex mode rule.

meatball133 commented 1 year ago

Yeah, to be a valid regex it needs to be at least 1 character between the // otherwise it is invalid and is thereby integer divison

carlqt commented 8 months ago

Hi, I want to contribute but I don't know how to add crystal in tools/developer.html to test. Anyone can help me out?

joshgoebel commented 8 months ago

./build -t browser crystal

or additive:

./build -t browser :common crystal