raspu / Highlightr

iOS & OSX Syntax Highlighter.
MIT License
1.68k stars 265 forks source link

Non-deterministic rendering in fast renderer #51

Open kabiroberai opened 6 years ago

kabiroberai commented 6 years ago

When rendering nested classes, the fast renderer determines which style takes precedence in a non-deterministic manner.

Eg. xcode.css has the following definitions (simplified here for the sake of brevity):

.hljs-title {
  color: blue;
}

.hljs-class .hljs-title {
  color: purple;
}

The following JS snippet

class Foo

is converted to

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Foo</span></span>

In the aforementioned snippet, Foo should turn purple, however in reality the renderer randomly picks between blue and purple, and the color it picks varies between app launches.

raspu commented 6 years ago

Seriously? That's a really interesting issue! I will take a look at it when I find some time.