zulip / zulip-flutter

Upcoming Zulip mobile apps for Android and iOS, using Flutter
Apache License 2.0
183 stars 174 forks source link

Handle codehilite elements with multiple classes #933

Closed PIG208 closed 1 week ago

PIG208 commented 1 month ago

It is totally possible for Pygments to generate HTML elements with more than one classes.

This is considered quite an edge case and only happens to some languages, such as PostgreSQL (see https://github.com/pygments/pygments/issues/2780). It currently renders as an unimplemented feature whenever a code block contains tokens with more than one classes.

See a minimal example here.

HTML of the unsupported message:

<pre>
  <span></span>
  <code>
    <span class="s s-Name">"</span>
  </code>
</pre>
PIG208 commented 1 month ago

Listed under #921.

gnprice commented 1 month ago

Other than PostgreSQL, this apparently happens with YAML. Here's a test message.

PIG208 commented 1 month ago

For these kind of messages, we should be able to safely apply the style of the most specific known class from the class list. These non-standard token types usually aren't likely to be handled by styles. We could also maintain a list of unexpected token types, but that does not seem necessary.