Improving Syntax Highlighting Files

When building the KSyntaxHighlighting framework, the syntax highlighting xml files are compiled into the KSyntaxHighlighting library. In order to do so, we have a small little helper program that generates an index of all xml files. This indexer also validates the xml files against the XML Schema, and performs some more sanity checks.

Review request D10621 tries to extend the indexer even further and suggest optimizations for our highlighting files. For instance, the rule

 <AnyChar context="#stay" String="&space;" attribute="Normal Text" />

should be replaced by the faster rule

 <DetectChar context="#stay" char="&space;" attribute="Normal Text" />

Similarly, the rule

 <RegExpr attribute="Normal" context="conditionNot" String="\bnot\b" lookAhead="true" insensitive="true"/>

should be replaced by the much faster rule

 <WordDetect attribute="Normal" context="conditionNot" String="not" lookAhead="true" insensitive="true"/>

The proposed patch above generates more than 1500 suggestions to improve our highlighting files, so a lot of work. Help would be very much appreciated. So if you would like to contribute to KDE and are looking for simple work to do, then feel free to get started by sending improved highlighting files to us via phabricator.kde.org (click “Code Review” on the left, and then “Create Diff” on the top right – or even better use arc to automatically manage your patches). Oh, and please increase the version number in the xml files whenever you provide a patch 🙂

5 thoughts on “Improving Syntax Highlighting Files”

  1. If these suggestions are already equivalent to the original and correct, why should humans do this work? Just let the program rewrite to more efficient rules automatically when the library is generated.

  2. There appears to be a bug in the JavaScript highlighter used by Kate.

    When a commented section is pasted into Kate while JavaScript highlighting is active the pasted text gets corrupted.

    For example:

    /*
    Test
    */

    Becomes

    /*
    T e*st
    */

    I’m using

    Kubuntu 17.10
    Kate 17.04.3
    KDE Frameworks 5.43.0
    Qt 5.9.1 (built against 5.9.1)
    The xcb windowing system

    This does not happen when PHP/HTML/CSS/BASH highlighting are in use or when plain unhighlighted text is used.

    1. This is a totally wrong place to report bugs. The required developers will not read this, since they are not aware of this discussion here. Sorry.

Leave a Reply