2

I got a problem to add a new language to gtksourceview (used by gedit).

I want to add the Django's template language and something does not work :
I am not able to make %} stop the syntactic coloring.

Here is a snippet :

<context id="dtl-block" end-at-line-end="true">
    <start>{%</start>
    <end>%}</end>
    <include>
        <context sub-pattern="0" where="start" style-ref="preprocessor"/>
        <context sub-pattern="0" where="end" style-ref="preprocessor"/>
        <context ref="string"/>
        <context ref="chaine"/>
        <context ref="keywords"/>
        <context ref="filters"/>
        <context ref="operators"/>
        <context ref="variable"/>
    </include>
</context>

This snippet color correctly my code, but it does not stop at %}. It continues coloring after %}, so there is something wrong.

I made a snippet which is working :

<context id="variable-block" end-at-line-end="true">
    <start>{{</start>
    <end>}}</end>
    <include>
        <context sub-pattern="0" where="start" style-ref="preprocessor"/>
        <context sub-pattern="0" where="end" style-ref="preprocessor"/>
        <context ref="variable"/>
    </include>
</context>

It is working very well.

{{ and }} works, but %} does not.

I tried with html entities and with a backslash (\) and it does not work.

Does somebody know what could be the problem ?

Thanks.

antoyo
  • 11,097
  • 7
  • 51
  • 82
  • It would be nice if you could share your gtksourceview language syntax file somewhere (or maybe you already do?). – JanC Aug 24 '10 at 06:30
  • Yes, I did share it. You can find it in the first post of this (french) thread : http://www.siteduzero.com/forum-83-541444-p1-utilisez-gedit-pour-vos-projets-django.html You have to click on "(cliquez pour afficher)" to view it. The explanations are in french (so use Google Translation if you need it). I’m glad you find it useful. – antoyo Aug 29 '10 at 14:06

2 Answers2

1

I found the problem :

in another context, there was a % in a regexp, so the %} was not interpreted.

antoyo
  • 11,097
  • 7
  • 51
  • 82
1

Just use extend-parent="false" as context attribute

shaman.sir
  • 3,198
  • 3
  • 28
  • 36
  • Ok, got it. However, I suppose, my answer can be a solution in cases with similar symptoms but another reasons, so I ask to leave it here) – shaman.sir Sep 04 '11 at 21:30