Hi, I am trying to achieve the following goals to finally make a minimal case syntax highlighting file.
- Strings that matches "
#( |$|(#)+).*
" gets treated as if it was a comment.
- Strings that matches "
#@cli.*
" are treated as if they’re a comment.
- Strings that matches "
\$(-\d+|\w+|\d+)
" gets treated as if they’re accessed variables.
- Strings that matches "
\w+:
" are treated as if they’re commands names.
- 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.
#@gui
gets bolded.
- 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"
[
]>
<language
name="G'MIC"
version=".01"
kateversion="5.79"
section="Development Syntax Highlighting"
extensions="*.gmic"
mimetype="application/x-shellscript"
casesensitive="1"
author="Miguel Lopez (reptillia39@live.com)"
license="LGPL"
>
<highlighting>
<list name="control-flow">
<item>apply_timeout</item>
<item>check</item>
<item>check3d</item>
<item>do</item>
<item>done</item>
<item>if</item>
<item>elif</item>
<item>else</item>
<item>fi</item>
<item>exec</item>
<item>exec_out</item>
<item>for</item>
<item>foreach</item>
<item>l</item>
<item>local</item>
<item>mutex</item>
<item>noarg</item>
<item>onfail</item>
<item>parallel</item>
<item>progress</item>
<item>quit</item>
<item>repeat</item>
<item>return</item>
<item>rprogress</item>
<item>run</item>
<item>skip</item>
<item>while</item>
</list>
<list name="loop-control-flow">
<item>continue</item>
<item>break</item>
</list>
<contexts>
<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="(?<!^#)(?<!#\$)\$\$??(\{)?(?(1)-?\d+--?\d+(:\d+}|})|(-?\d+|\w+|!|>|<|\/|\||\*|#|\^))" 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"/>
</context>
</contexts>
<itemDatas>
<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" />
</itemDatas>
</highlighting>
</language>
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.