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:

Calamares towards 3.3.11

I’m going to change up the Calamares release process a little. It’s been slow going as a community-maintained project – which isn’t to say that that is a bad thing. Just slow. I’ve decided to make releases marginally more predictable than “when [ade] has …

via [bobulate] October 24, 2024

There is only one reason why Microsoft Windows is the dominating operating system on the PC desktop

The Internet is filled with blog posts, articles on tech media, and videos on YouTube about why Linux is not the main operating system on the PC desktop. "5 reasons why", "10 reasons why", bla, bla, bla. But they are all wrong.

via unixdigest.com August 24, 2024

Signing Android Apps Using a YubiKey (on NixOS)

In my spare time, I currently develop two Android apps using Flutter: AniTrack, a simple anime and manga tracker based on my own needs, and Moxxy, a modern XMPP client. While I don't provide release builds for AniTrack, I do for Moxxy. Those are signed u…

via PapaTutuWawa's Blog July 24, 2023

Generated by openring