geditの不適切な動作に対するカスタム構文の強調

geditの不適切な動作に対するカスタム構文の強調

geditの場合は、いくつかの自然言語操作を実行するために作成したマークアップ類似言語のカスタム構文強調インジケータを作成しているので、キーワードを作成する必要はないので、単純なキーワードから始めたいと思いました。 。

XMLで以下を定義しました。

<language id="foo" _name="Foo" version="2.0" _section="Source">
  <metadata>
    <property name="mimetypes">text/x-c;text/x-csrc;image/x-xpixmap</property>
    <property name="globs">*.foo</property>
  </metadata>

  <styles>
    <style id="operator" _name="Operator" map-to="def:keyword" />
    <style id="member" _name="Member" map-to="def:type" />
  </styles>

  <definitions>

    <context id="members" style-ref="member">
      <keyword>ref</keyword>
      <keyword>alt</keyword>
      <keyword>pos</keyword>
      <keyword>num</keyword>
    </context>

    <context id="operators" style-ref="operator">
      <keyword>#</keyword>
      <keyword>$</keyword>
      <keyword>@</keyword>
      <keyword>[</keyword>
      <keyword>]</keyword>
      <keyword>:</keyword>
      <keyword>=</keyword>
      <keyword>:?</keyword>
      <keyword>&amp;</keyword>
    </context>

    <!--Main context-->
    <context id="opal" class="no-spell-check">
      <include>
        <context ref="members" />
        <context ref="operators" />
      </include>
    </context>

  </definitions>
</language>

構文強調が発生しますが、特定の奇妙な条件でのみ発生します。特にoperators強調表示を避けるには、コンテキスト内のすべてのキーワードの前にキーワード以外の文字を含める必要があります。

スクリーンショット

これを処理するために正規表現を使用する必要がありますか、それともXMLを混乱させていますか?そして、membersキーワードの強調表示にはなぜ問題がないのですか?

ベストアンサー1

おすすめ記事