syntax-highlighting: parameters for included highlighting rules

Milian Wolff mail at
Thu Jul 18 10:12:06 BST 2019

Hey all,

has anyone ever thought about a way to make the declarative XML syntax 
highlighting rules configurable somehow? Case in point:

in QML, this is valid:

property string foo: (true ? "line 1
                              line 2" : "line 1
                                        line 2")

While in QML this is not:

var foo = (true ? "line 1
                   line 2" : "line 1
                             line 2")

I.e. QML supports multi-line string literals. JavaScript on the other hand 
does not support this. We handle this for top-level strings in the QML 
highlighter, but do not catch the strings nested within a Conditional block, 
Object or any other deeper levels of the syntax tree.

I don't see any easy way to solve this. One idea I have (no clue if this is 
even possible) would be something like:

<IncludeRules context="Normal##JavaScript">
    <SetEntity name="StringLineEndContext" value="#stay" />

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd"
  <!ENTITY StringLineEndContext value="#pop" />
<context attribute="String" lineEndContext="&StringLineEndContext;" 

Sadly, it doesn't seem to be trivially possible to overwrite entities through 
QXmlStreamReader, but the QXmlStreamEntityResolver would allow resolving 
undeclared entities. So maybe we'd need to add some prefix to where we use the 
entity and then either use the entity from a parent include's SetEntity value, 
or fall back to the current file's non-prefixed identify value...

Other ideas or suggestions?

Milian Wolff
mail at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the KWrite-Devel mailing list