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:

Richard Stallman's political discourse on sex

Richard Stallman, the founder of the Free Software Foundation, has been subject to numerous allegations of misconduct. He stepped down in 2019, and following his re-instatement in 2021, a famous open letter was published in which numerous organizations and i…

via Drew DeVault's blog November 25, 2023

Upgrading to FreeBSD 14 - how to fix a broken BIOS bootcode

A lot of people running ZFS zroot have managed to break their FreeBSD systems upgrading from 13.2 to the new 14.0 release because of a broken BIOS bootcode. In this tutorial I'll show you how you can fix that without having to reinstall.

via unixsheikh.com November 22, 2023

C++ Guidelines

C++ is definitely a language that has Lots of Ways to do It – kind of like Perl’s TIMTOWTSAC. A consequence is that when writing code, you need to think about which way to do things. When context-switching between projects, employers, or what-have-you, yo…

via [bobulate] November 21, 2023

Generated by openring