I've edited the gtksourceview language file for markdown from Jean-Philippe Fleury. Here is my improved version: https://gist.github.com/ZelphirKaltstahl/de2b725ef5adba0a150dd27a5f7b66dc
This one uses markdown specific styles, which I defined in an also edited style file: https://gist.github.com/ZelphirKaltstahl/f45be7bcedbc895df2439dd252d28c7b
These files I use for GEdit.
However, I am not yet satisfied really. There are these properties
for defining what a comment looks like in the meta data
. They already match html comments, but the tommorow_night-eighties
theme uses some color for the comments, which I don't want to use in markdown files, but want to use in other source code files.
What I though of for solving the issue is to add a minus character to those properties, hoping, that then they will not match html comments anymore and defining my own regex for html comments and giving that another color.
In the linked gists that is already included, but somehow not working properly. The html comments still are matched and highlighted according to the properties in the meta data and my regex html-block-comment
is ignored.
The regex is:
<!--
(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
<!-- # the begin marker of an html comment
[^>]* # everything except >
--> # the end marker of an html comment
) # end of capturing group 1
.*$ # an arbitrary amount of any characters until line end
</match>
</context>
I am also already including it in markdown syntax (at the very bottom):
<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>
and there is a style definition at the top of the lang file:
<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>
This style is mapped to the style XML file, where I have the definition:
<style name="markdown:html-block-comment" foreground="#303030" bold="false" italic="false"/>
So I am thinking I got it all in place, but apparently this it not so.
How can I make it so that only my regex for html comment is used?