开发者

Add a new language to gtksourceview (Django's template language for gedit)

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.

Her开发者_如何学编程e 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.


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


I found the problem :

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜