Skip to content

Improve translation of pygments styles into urwid #1434

Open
@neiljp

Description

@neiljp

This work would represent a clean fix for #1431, which was temporarily fixed by pinning pygments at ~=2.15.1 in #1433. However, it could also heavily simplify our need for overrides in the themes.

As per #1433, the bug could be worked around by using our pygments override option, which manually converts the pygments bold italic style into the urwid-compatible bold, italics.

However, instead of using overrides for this, we should aim to automatically convert pygments styles into urwid-compatible versions. Based on the above, we likely want to consider at least:

  • converting spaces between combined entries to include a comma
  • converting italic to italics

Instead of manually testing directly with an upgraded version of pygments, initial indications are that we can remove an override from an existing style. If when you do so ZT gives an error, you can compare that string with the removed override to see what differs - and if an automatic translation could replace it. Once we have at least the comma insertion (first task above) we could therefore add

  • a runtime check comparing the (translated) pygments style to any override value given, and give a warning if it is redundant (and can be removed)

Once existing themes are simplified and we have an improved translation in place:

  • explore updating pygments to >=2.16.x, and whether all themes continue to work

As with the majority of PRs, each automatic conversion and new functionality should be accompanied by an updated or new test.

A possible extension or early work, would be to explore writing a test that fails with an invalid pygments style (eg bold italic). That should limit the impact of something like #1431 in future, since we should expect a failure in our tests, not just at runtime.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions