github-syntax-theme-generator icon indicating copy to clipboard operation
github-syntax-theme-generator copied to clipboard

Set `unicode-bidi: isolate` on tokens

Open robertbastian opened this issue 2 years ago • 0 comments

I'm not sure this is the right place to report this, but as underlying PrettyLight library is closed-source, it's the best I can do.

If tokens contain right-to-left text, any following ambiguous tokens (comma, digits, etc.) will be rendered right-to-left.

Example (code link):

Screenshot 2022-08-02 at 15 20 06

The string literal here contains the arabic waw followed by a space (and is followed by , 3u8). However the full sequence of waw, quotation mark, latin comma (outside the string literal token), space, digit 3 is rendered right-to-left, because the letter u is the first strong left-to-right character that flips the bidi algorithm again.

This can be fixed by setting the unicode-bidi: isolate CSS to not let a token's directionality leak outside of it. Setting that for .pl-s makes this render correctly (and as it does in VS Code):

Screenshot 2022-08-02 at 15 27 13

This property should be set on at least string and character literals, as well as identifiers, which in many languages can be arbitrary Unicode sequences, and comments. It probably doesn't hurt to set it on all token types.

robertbastian avatar Aug 02 '22 13:08 robertbastian