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

(Python) or"string" highlights the raw string instead of `or` operator

Open IamMusavaRibica opened this issue 1 year ago • 2 comments

Describe the issue Incorrect highlighting of python or operator preceded by string without whitespace, highlight.js treats the string as a raw string (with r prefix)

Which language seems to have the issue? Python

Are you using highlight or highlightAuto? highlight

Sample Code to Reproduce https://jsfiddle.net/beh3j1nw/

Expected behavior This is valid Python code

print(test()or'string')

image

IamMusavaRibica avatar May 29 '23 09:05 IamMusavaRibica

Probably just a matter of adding a \bor rule prior to the string rule... or would it be simpler to add \b to the string prefixes perhaps, forcing them to stand on their own?

joshgoebel avatar May 29 '23 13:05 joshgoebel

I have read the Python highlighting script and found the solution: string highlighting the prefixes such as (r, u, b, f) and I will fix it now. After solving it, I will submit my PR.

MohamedAli00949 avatar Oct 19 '23 05:10 MohamedAli00949