Re: [gedit-list] How to modify the formatting options for a single <keyword> in a syntax highliting definition for GEdit?
- From: Sergio Spina <sergio am spina gmail com>
- To: Jeffery To <jeffery to gmail com>
- Cc: Gedit mailing list <gedit-list gnome org>
- Subject: Re: [gedit-list] How to modify the formatting options for a single <keyword> in a syntax highliting definition for GEdit?
- Date: Thu, 5 Sep 2019 18:07:13 +0200
Many thanks! You were so kind. Sorry for the delay but I couldn't use a pc for a few days.
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 think this will do what you want:
<context id="bold-formatting-element">
<start>(<)(b)\b</start>
<include>
<context sub-pattern="0" where="start" style-ref="xml:tag"/>
<context sub-pattern="1" where="start" style-ref="xml:element-name"/>
<context sub-pattern="2" where="start" style-ref="formatting-elements"/>
<context id="bold-start-tag" style-ref="xml:tag" class="no-spell-check" once-_only_="true">
<start>\%{def:always-match}</start>
<end>/?></end>
<include>
<context sub-pattern="0" where="end" style-ref="xml:element-name"/>
<context ref="xml:entity"/>
<context ref="xml:character-reference"/>
<context ref="xml:unallowed-chars"/>
<context ref="xml:namespace"/>
<context ref="xml:attribute-name"/>
<context ref="xml:attribute-value"/>
<context style-ref="def:error" extend-parent="false">
<match>\S</match>
</context>
</include>
</context>
<context id="bold-end-tag" style-ref="xml:tag" class="no-spell-check" end-parent="true">
<start>(</)(b)\b</start>
<end>></end>
<include>
<context sub-pattern="1" where="start" style-ref="xml:element-name"/>
<context sub-pattern="2" where="start" style-ref="formatting-elements"/>
<context sub-pattern="0" where="end" style-ref="xml:element-name"/>
<context ref="xml:entity"/>
<context ref="xml:character-reference"/>
<context ref="xml:unallowed-chars"/>
<context ref="xml:namespace"/>
<context style-ref="def:error" extend-parent="false">
<match>\S</match>
</context>
</include>
</context>
<context id="bold-content" style-ref="bold">
<start>(?<!/>)(?!</b\b)</start>
<include>
<context end-parent="true">
<match>(?=</b\b)</match>
</context>
<context ref="lcs"/>
</include>
</context>
<context id="bold-self-closing-tag" end-parent="true">
<match>(?<=/>)</match>
</context>
</include>
</context>
<context id="lcs">
<include>
<context ref="bold-formatting-element"/>
<context ref="xml:xml"/>
</include>
</context>
You will also need to add a bold style.
Hope that helps,
Jeff
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]