[prev in list] [next in list] [prev in thread] [next in thread]
List: kwrite-devel
Subject: Re: kate syntax highlighting, end of context with indentation
From: jules <jules () scarabecus ! fr>
Date: 2014-06-21 21:36:57
Message-ID: 2403178.klV931GYYI () homer
[Download RAW message or body]
Le vendredi 23 mai 2014 09:43:38, vous avez écrit :
> thx a lot!
>
> this do the trick and I better understand how works contexts, now i need to
> find out how apply an IncludeRules ##JavaScript only on the determine code
> block, but i ll try a bit by myself.
>
> > it is to use dynamic contexts that capture the indent level
>
> what about "dynamic="true" keyword? in which case should we use?
>
> Le jeudi 22 mai 2014, 16:12:32 Matthew Woehlke a écrit :
> > On 2014-05-19 20:10, jules wrote:
> > > im trying to make a new syntax file for the "jade template engine", and
> > > i
> > > can't find a viable solution for the case where the end of scope is only
> > > indentation.
> >
> > Take a look at ReStructuredText, which has a similar need. The way I did
> > it is to use dynamic contexts that capture the indent level with
> > look-ahead rules that match the indent followed by any non-space
> > character to pop the context.
after a few weeks of distance, i returned to the subject with fresh eyes...
With ReStructuredText, you try to capture the indent level in this part:
(...)
<RegExpr attribute="Code" String="::$" context="CodeBlock" />
(...)
<context name="CodeBlock" attribute="Code" lineEndContext="#stay">
<RegExpr attribute="Code" String="^\s" context="Code" />
</context>
<context name="Code" attribute="Code" lineEndContext="#stay">
<RegExpr attribute="Normal" String="^\S" lookAhead="true"
context="#pop#pop" />
</context>
but it seems just equal to the last regex -> changing context when a
line doesn't start with some kind of white space, and this is doing the same
result for me:
<RegExpr attribute="Code" String="::$" context="Code" />
</context>
<context name="Code" attribute="Code" lineEndContext="#stay">
<RegExpr attribute="Normal" String="^\S" lookAhead="true" context="#pop"
/>
</context>
the test case:
(with : RegExpr attribute="Code" String="script."...)
html
body
#head.center
h1 test
script.
console.log('test');
var i = 6;
for (i; i>1; i--) {
console.log(i);
}
div <==== context not switch
p blabla
so, i returned to the dynamic rules and to the capture regex idea, and or i
discovered a bug, or i missed something. If i do that:
<RegExpr attribute="Code" String="sc(ri)pt." context="Code" dynamic="true" />
i should capture "ri", and i should use it like that in according to the
manual
<context name="Code" attribute="Code" lineEndContext="#stay">
<RegExpr attribute="Normal" String="^%1" context="#pop"
/>
html
body
#head.center
h1 test
script.
console.log('test');
var i = 6;
for (i; i>1; i--) {
console.log(i);
}
ri <==== should be detected?! but it is not!
div
p blabbla
what I didn't understand?
thx
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic