1

Jean-Philippe Fleuryからのマークダウン用に gtksourceview 言語ファイルを編集しました。これが私の改良版です: https://gist.github.com/ZelphirKaltstahl/de2b725ef5adba0a150dd27a5f7b66dc

これは、同じく編集したスタイル ファイルで定義したマークダウン固有のスタイルを使用します

これらのファイルは、GEdit で使用します。

しかし、私はまだ本当に満足していません。propertiesでコメントがどのように見えるかを定義するためにこれらがありますmeta data。それらはすでに html コメントと一致していますが、tommorow_night-eightiesテーマはコメントに何らかの色を使用しています。これはマークダウン ファイルでは使用したくありませんが、他のソース コード ファイルでは使用したいと考えています。

問題を解決するために私が考えたのは、これらのプロパティにマイナス文字を追加することです.htmlコメントと一致しなくなり、htmlコメントに独自の正規表現を定義し、別の色を与えることを願っています.

すでに含まれているが、どういうわけか正しく機能していないリンクされた要点。HTML コメントは、メタ データのプロパティに従って一致し、強調表示され、正規表現html-block-commentは無視されます。

正規表現は次のとおりです。

<!--
  (literally this kind of comment!)
  somehow still not working!
-->
<context id="html-block-comment" style-ref="html-block-comment">
  <match extended="true">
    ^.*          # at the beginning of the line an arbitrary amount of any characters
    (            # begin capture group 1
      &lt;!--    # the begin marker of an html comment
      [^&gt;]*   # everything except &gt;
    --&gt;       # the end marker of an html comment
    )            # end of capturing group 1
    .*$          # an arbitrary amount of any characters until line end
  </match>
</context>

私はすでにそれをマークダウン構文にも含めています(一番下にあります):

<context id="markdown-syntax">
  <include>
    <!-- Markdown contexts. -->
    <context ref="atx-header"/>
    <context ref="setext-header"/>
    <context ref="horizontal-rule"/>
    <context ref="list"/>
    <context ref="code-block"/>
    <context ref="1-backtick-code-span"/>
    <context ref="2-backticks-code-span"/>
    <context ref="blockquote"/>
    <context ref="automatic-link"/>
    <context ref="inline-link"/>
    <context ref="reference-link"/>
    <context ref="link-definition"/>
    <context ref="inline-image"/>
    <context ref="reference-image"/>
    <context ref="underscores-emphasis"/>
    <context ref="asterisks-emphasis"/>
    <context ref="underscores-strong-emphasis"/>
    <context ref="asterisks-strong-emphasis"/>
    <context ref="backslash-escape"/>
    <context ref="line-break"/>

    <!-- Markdown Extra contexts. -->
    <context ref="setext-header-id-attribute"/>
    <context ref="definition-list"/>
    <context ref="fenced-code-block"/>
    <context ref="footnote-reference"/>
    <context ref="abbreviation"/>
    <context ref="table-separator"/>
    <context ref="backslash-escape-extra"/>

    <!-- Xiaolong added -->
    <context ref="math-span-inline"/>
    <context ref="math-span-block"/>
    <context ref="html-block-comment"/>
  </include>
</context>

lang ファイルの先頭にスタイル定義があります。

<styles>
  <!-- Markdown styles. -->
  <style id="header" _name="Header" map-to="def:type"/>
  <style id="horizontal-rule" _name="Horizontal Rule" map-to="def:type"/>
  <style id="code" _name="Code" map-to="def:identifier"/>
  <style id="blockquote-marker" _name="Blockquote Marker" map-to="def:shebang"/>
  <style id="label" _name="Label" map-to="def:preprocessor"/>
  <style id="attribute-value" _name="Attribute Value" map-to="def:constant"/>
  <style id="image-marker" _name="Image Marker" map-to="def:shebang"/>
  <style id="backslash-escape" _name="Backslash Escape" map-to="def:special-char"/>
  <style id="line-break" _name="Line Break" map-to="def:note"/>

  <!-- Xiaolong added styles -->
  <style id="list-marker" _name="List Marker" map-to="markdown:list-marker"/>
  <style id="math-inline" _name="Math Inline" map-to="markdown:single-math-marker"/>
  <style id="math-block" _name="Math Block" map-to="markdown:double-math-marker"/>
  <style id="url" _name="URL" map-to="markdown:url"/>
  <style id="link-text" _name="Link Text" map-to="markdown:link-text"/>
  <style id="emphasis" _name="Emphasis" map-to="markdown:emphasis"/>
  <style id="strong-emphasis" _name="Strong Emphasis" map-to="markdown:strong-emphasis"/>
  <style id="html-block-comment" _name="HTML Block Comment" map-to="markdown:html-block-comment"/>

  <!-- Markdown Extra styles. -->
  <style id="header-id-marker" _name="Header Id Marker" map-to="def:shebang"/>
  <style id="definition-list-marker" _name="Definition List Marker" map-to="def:shebang"/>
  <style id="footnote-marker" _name="Footnote Marker" map-to="def:shebang"/>
  <style id="abbreviation-marker" _name="Abbreviation Marker" map-to="def:shebang"/>
  <style id="abbreviation" _name="Abbreviation" map-to="def:preprocessor"/>
  <style id="table-separator" _name="Table Separator" map-to="def:statement"/>
</styles>

このスタイルはスタイル XML ファイルにマップされており、ここに次の定義があります。

<style name="markdown:html-block-comment" foreground="#303030" bold="false" italic="false"/>

だから私はそれをすべて整ったと思っていますが、明らかにそうではありません。

HTMLコメントの正規表現のみが使用されるようにするにはどうすればよいですか?

4

0 に答える 0