Understanding <contexts> in KDE Syntax Highlighting .xml codes

Hi, I am trying to achieve the following goals to finally make a minimal case syntax highlighting file.

  1. Strings that matches " #( |$|(#)+).* " gets treated as if it was a comment.
  2. Strings that matches " #@cli.* " are treated as if they’re a comment.
  3. Strings that matches " \$(-\d+|\w+|\d+) " gets treated as if they’re accessed variables.
  4. Strings that matches " \w+: " are treated as if they’re commands names.
  5. Any texts under control-flow list gets highlighted as long as they’re outside any characters between “” and of course, taking into account of / being used as escape character.
  6. #@gui gets bolded.
  7. Anything between “” gets highlighted.

All of them must be configurable.

EDIT: My current KDE Syntax Highlighting code is in last post.

Ok, I did what I could for now. I’d still like to resolve the harder part which is highlighting a large section of code with quotation mark, and #@gui codes.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd"

    section="Development Syntax Highlighting"
    author="Miguel Lopez (reptillia39@live.com)"
        <list name="control-flow">
        <list name="loop-control-flow">
            <context attribute="Normal Text" lineEndContext="#pop" name="BashOneLine" fallthroughContext="Command">
                <RegExpr attribute="CLI Header" context="#stay" String="#@cli.*" beginRegion="Fold"/>
                <RegExpr attribute="Command Names" context="#stay" String="^\+?([a-zA-Z0-9_]*)+\s?:( |$)" beginRegion="Fold"/>
                <RegExpr attribute="Accessed-Variables" context="#stay" String="(?&lt;!^#)(?&lt;!#\$)\$\$??(\{)?(?(1)-?\d+--?\d+(:\d+}|})|(-?\d+|\w+|!|&gt;|&lt;|\/|\||\*|#|\^))" beginRegion="Fold"/>
                <RegExpr attribute="Comments" context="#stay" String="(\w|^|\s)(#\w+$|#\s+.*|#+$|#--+.*|#@gmic)"/>
                <keyword attribute="Control Flow"  context="#stay" String="control-flow" />
                <keyword attribute="Loop Control Flow"  context="#stay" String="loop-control-flow" />
                <RegExpr attribute="Error" context="#stay" String="\berror\b" beginRegion="Fold"/>
            <itemData name="Normal Text" defStyleNum="dsNormal" />
            <itemData name="CLI Header" defStyleNum="dsDocumentation" />
            <itemData name="Command Names" defStyleNum="dsFunction" />
            <itemData name="Accessed-Variables" defStyleNum="dsVariable" />
            <itemData name="Comments" defStyleNum="dsComment" />
            <itemData name="Control Flow" defStyleNum="dsKeyword" />
            <itemData name="Loop Control Flow" defStyleNum="dsAlert" />
            <itemData name="Error" defStyleNum="dsError" />


EDIT: The final thing I want to do is to highlight every section of code between quotation mark, and that factors into escape character. And doing this while preserving highlights of other code.

So far, I have this:

Ok, I finally figured it out how syntax highlighting works. That being said, I have issues getting regex matching on multiple lines and from what I see, that’s a big limitation of KDE Kate. I will have to use other workaround.