highlight.js icon indicating copy to clipboard operation
highlight.js copied to clipboard

(Crystal) formats integer divison incorrectly

Open meatball133 opened this issue 1 year ago • 4 comments

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

meatball133 avatar Mar 03 '23 21:03 meatball133

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.

joshgoebel avatar Mar 04 '23 07:03 joshgoebel

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

meatball133 avatar Mar 04 '23 08:03 meatball133

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?

carlqt avatar Oct 20 '23 05:10 carlqt

./build -t browser crystal

or additive:

./build -t browser :common crystal

joshgoebel avatar Oct 20 '23 18:10 joshgoebel