jgm / skylighting

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions
191 stars 61 forks source link

Cannot switch context in WordDetect #2

Closed lwrage closed 7 years ago

lwrage commented 7 years ago

I have a highlighting configuration for AADL which works with kate and highlighting-kate, but not with skylighting. AADL allows the embedding of sub-languages each of which may have different keywords. In my configuration I use the keyword annex to switch to context Annex and there the sub-langugage name emv2 to switch to the EMV2 context that highlights emv2 specific keywords.

When processed with skylighting the keyword annex is missing from the html output and emv2 keywords are not highlighted. It seems that context switch in a WordDetect rule doesn't work.

The configuration: https://gist.github.com/lwrage/fa17916a6c61696c8e543b3bd6a93e89 Test input file: https://gist.github.com/lwrage/78d6414d8a562299937f262d36ba30af Outputs form highlighting-kate and skylighting: https://gist.github.com/lwrage/2576c79e1fed879761b5fe1c5693b6d5

jgm commented 7 years ago

For ease of reference, part of the original:

    properties
      p => "a string";
    annex emv2 {**
      use types ErrorLibrary;
      component error behavior
        transitions
          system  -[ ip{noerror} ]-> same;

Skylighting:

    <span class="kw">properties</span>
      p =&gt; <span class="st">&quot;a string&quot;</span>;
     emv2 {**
      use types ErrorLibrary;
      component error behavior
        transitions
          <span class="kw">system</span>  -[ ip{noerror} ]-&gt; same;

Highlighting-kate:

    <span class="kw">properties</span>
      p =&gt; <span class="st">&quot;a string&quot;</span>;
    <span class="kw">annex</span> <span class="kw">emv2</span> {**
      <span class="kw">use</span> <span class="kw">types</span> ErrorLibrary;
      <span class="kw">component</span> <span class="kw">error</span> <span class="kw">behavior</span>
        <span class="kw">transitions</span>
          system  -[ ip{<span class="fu">noerror</span>} ]-&gt; <span class="bu">same</span>;

Note that the word annex is completely dropped!

jgm commented 7 years ago

Running with --trace:

Loaded syntax definition for AADL
Keyword MATCHED Just (KeywordTok,"package")
Keyword MATCHED Just (KeywordTok,"public")
Keyword MATCHED Just (KeywordTok,"system")
Keyword MATCHED Just (KeywordTok,"features")
Keyword MATCHED Just (KeywordTok,"in")
Keyword MATCHED Just (KeywordTok,"data")
Keyword MATCHED Just (KeywordTok,"port")
Keyword MATCHED Just (KeywordTok,"end")
Keyword MATCHED Just (KeywordTok,"system")
Keyword MATCHED Just (KeywordTok,"implementation")
Keyword MATCHED Just (KeywordTok,"subcomponents")
Keyword MATCHED Just (KeywordTok,"system")
Keyword MATCHED Just (KeywordTok,"properties")
DetectChar MATCHED Just (StringTok,"\"")
CONTEXT STACK ["String","Normal"]
DetectChar MATCHED Just (StringTok,"\"")
CONTEXT STACK ["Normal"]
Keyword MATCHED Just (KeywordTok,"system")
Keyword MATCHED Just (KeywordTok,"end")
Keyword MATCHED Just (KeywordTok,"end")
Keyword MATCHED Just (KeywordTok,"end")
jgm commented 7 years ago

One thing I notice is that the WordDetect is not matching annex. When you change WordDetect to StringDetect, annex gets matched as a keyword. Probably this is a bug in skylighting's detection of word boundaries.

jgm commented 7 years ago

Released a new version where this is fixed. THanks for the report!