My thoughts on kateschema to theme converter

Or how I spent a weekend.

With the latest changes in ksyntaxhighlighting library the old themes (they are called “kateschema”) will become obsolete and one will have to either use some new theme and hope it will fit or try to adapt the old one and spent hours doing so.

The old format is a bit complicated, the settings for one language can vary depending on the current file type. In other words you could have different settings if you opened CSS file directly or when styles were used in HTML. This looks like a nice feature to have which allowed users to tweak everything but also added a huge overhead when doing changes to the theme. So one has to decide how to export these changes, I decided to take 2 approaches:

  • First come first serve - whatever setting is read first for given data type, that is used
  • main type rules - In other words it would prefer settings stored for that standalone data type and will overwrite any previously read ones

Another huge drawback while writing this script was lack of documentation which forced me to go through the source code to find answers to my questions, which took a lot of time and energy. A huge part of the script is comprised of dictionaries which are used to convert old settings to new one.

I also got a bit of help from the developer Christoph Cullmann on reddit.
There you can see how big spammer I actually can be, at least I managed to somehow finish it.

In the end I managed to convert my theme with some drawback compared to old solution. In new version you cant define default style for something by using the theme. These defaults are set by syntax highlighting definitions. So the “default” values are almost always not met and will restore setting to some theme keyword defined in syntax file (well, nothing to do here from my side).

The script was than pushed to the frameworks/syntax-highlighting repository.

I was too tired to do some proper user interface and such it is very crude. In general you need to supply 2 arguments:

  1. Theme name
  2. kateschema file

And the results will be printed to the stdout, it is up to user to save it into the file or whatever.

In the end, the script did the job for me and I can have same colors (for time being until I fix or change the theme) as I have on old one.
I use it to convert exported theme with all the mess around (16k lines) and I got a nice theme as a result together with messy custom styles. But there is nothing to do with that, I did not wish to lay with theme for hours to make it looks nice again.

So these are my messy thoughts about this script, it works but it is not perfect. It can be used as an example for your own (hope better) creation.

Articles from blogs I follow:

Why is your open source project still hosted on GitHub?

Perhaps the younger generation don't know anything about the past "evils" of Microsoft and naively believe that Microsoft is now the good friend to open source, but the truth is that all Microsoft acquisitions of open source projects is a busi…

via unixdigest.com May 22, 2025

StarFive VisionFive v2 and FreeBSD

This week I powered up the StarFive VisionFive v2 board that I have. I figured I would give FreeBSD another whirl on it, in the vague hope that RISC-V boards are a more cohesive family than ARM boards were five years ago. tl;dr: I didn’t get it to work as…

via [bobulate] May 20, 2025

Steve Ballmer was an underrated CEO

There's a common narrative that Microsoft was moribund under Steve Ballmer and then later saved by the miraculous leadership of Satya Nadella. This is the dominant narrative in every online discussion about the topic I've seen and it's a commo…

via danluu.com October 28, 2024

Generated by openring