I made the following language definition for GEdit, an XML dialect aimed to keep the log of measurements. I made it as a modification of the DocBook language definition.
----- File: lcs.lang -----
<?xml version='1.0' encoding='utf-8'?>
<language id="lcs" _name="LCs" version="2.0" _section="Markup">
<metadata>
<property name="mimetypes">application/lcs+xml</property>
<property name="globs">*.lcs</property>
<property name="block-comment-start"><!--</property>
<property name="block-comment-end">--></property>
</metadata>
<styles>
<style id="header-elements" _name="Header Elements" map-to="def:keyword"/>
<style id="formatting-elements" _name="Formatting Elements" map-to="def:keyword"/>
<style id="structural-elements" _name="Structural Elements" map-to="def:keyword"/>
</styles>
<definitions>
<context id="header-elements" once-_only_="true" style-ref="header-elements">
<suffix>\b(?!\s*=)</suffix>
<keyword>mt</keyword>
<keyword>la</keyword>
<keyword>ti</keyword>
<keyword>sd</keyword>
<keyword>cd</keyword>
</context>
<context id="formatting-elements" once-_only_="true" style-ref="formatting-elements">
<suffix>\b(?!\s*=)</suffix>
<keyword>p</keyword>
<keyword>b</keyword>
<keyword>i</keyword>
<keyword>br</keyword>
<keyword>X</keyword>
<keyword>ol</keyword>
<keyword>ul</keyword>
<keyword>li</keyword>
<keyword>h1</keyword>
<keyword>h2</keyword>
<keyword>h3</keyword>
</context>
<context id="structural-elements" once-_only_="true" style-ref="structural-elements">
<suffix>\b(?!\s*=)</suffix>
<keyword>lcs</keyword>
<keyword>cc</keyword>
<keyword>ls</keyword>
<keyword>le</keyword>
<keyword>da</keyword>
<keyword>un</keyword>
<keyword>re</keyword>
<keyword>co</keyword>
<keyword>ex</keyword>
<keyword>no</keyword>
</context>
<context id="lcs-tags">
<include>
<context ref="header-elements"/>
<context ref="formatting-elements"/>
<context ref="structural-elements"/>
<context ref="xml:element-name" original="true"/>
</include>
</context>
<replace id="xml:element-name" ref="lcs-tags"/>
<context id="lcs">
<include>
<context ref="xml:xml"/>
</include>
</context>
</definitions>
</language>
----- End of file: lcs.lang -----
As you can see, there's a context named *formatting-elements*.
Then I made a syntax highlighting definition, as a modification of a well-known public file.
----- File: militargreen.xml -----
<?xml version="1.0" encoding="UTF-8"?>
<style-scheme id="militargreen" _name="MilitarGreen" version="1.0">
<author>Joe Bordello</author>
<_description>Good for XML/PHP at night</_description>
<color name="White" value="#FFFFFF"/>
<color name="BrightGrey" value="#DDDDDD"/>
<color name="Grey" value="#BBBBBB"/>
<color name="Black" value="#000000"/>
<color name="PetrolGrey" value="#669988"/>
<color name="GreenBlack" value="#223322"/>
<color name="GreenGrey" value="#334433"/>
<color name="Green" value="#99EE00"/>
<color name="GreenYellow" value="#CCFF88"/>
<color name="Yellow" value="#FFFF00"/>
<color name="DarkYellow" value="#EEEE66"/>
<color name="Orange" value="#FFCC00"/>
<color name="Blue" value="#99CCFF"/>
<color name="Red" value="#DD2200"/>
<color name="LightRed" value="#EE5533"/>
<color name="BrightRed" value="#EE7766"/>
<color name="Purple" value="#EE99FF"/>
<color name="DeepPurple" value="#DD66EE"/>
<color name="unknown" value="#FF88FF"/>
<style name="text" foreground="White" background=""> <style name="selection" foreground="Black" background=""> <style name="cursor" foreground="White"/>
<style name="current-line" background=""> <style name="line-numbers" foreground="Black" background=""> <style name="right-margin" background="">
<style name="bracket-match" foreground="White" background="" bold="true"/>
<style name="search-match" foreground="Black" background="">
<style name="def:comment" foreground="BrightGrey" background="" italic="true"/>
<style name="def:note" foreground="LightRed" bold="true" italic="false"/>
<style name="def:preprocessor" foreground="Purple"/>
<style name="def:error" foreground="Yellow" background="" bold="true"/>
<style name="def:underlined" underline="false"/>
<style name="def:decimal" foreground="Purple" bold="true"/>
<style name="def:floating-point" foreground="Purple" bold="true"/>
<style name="def:boolean" foreground="Purple" bold="true"/>
<style name="def:base-n-integer" foreground="Blue" bold="true"/>
<style name="def:string" foreground="Green"/>
<style name="def:special-char" foreground="BrightRed" bold="true"/>
<style name="def:identifier" foreground="Blue"/>
<style name="def:keyword" foreground="Orange" bold="true"/>
<style name="def:type" foreground="Orange"/>
<style name="def:statement" foreground="DarkYellow"/>
<style name="def:function" foreground="Blue"/>
<style name="def:shebang" foreground="BrightRed" bold="true"/>
<style name="def:builtin" foreground="Blue" italic="true"/>
<style name="def:constant" foreground="BrightRed" bold="true" italic="true"/>
<style name="def:special-constant" foreground="Blue" italic="true"/>
<style name="bracket-mismatch" background="" italic="true"/>
<style name="def:doc-comment-element" background="" italic="true"/>
<style name="def:complex" background="" italic="true"/>
<style name="def:character" background="" italic="true"/>
</style-scheme>
----- End of file: militargreen.xml -----
All it works as expected.
Now I want to modify the syntax definition so that the keywords in the "formatting elements" context are formatted in a special way: for example: the statement
<b>phrase one</b>
in GEdit should appear with the words "phrase one" in bold face while the statement
<i>phrase two</i>
in GEdit should appear with the words "phrase two" in italic face.
How can I set up such a modifications?