Reputation: 9658
I'm using scintilla Editor for syntax highlighting for a MarkDown Editor.
scintilla.Styles[Style.Markdown.Default].ForeColor = Color.Blue;
scintilla.Styles[Style.Html.Comment].ForeColor = Color.Gray;
scintilla.Styles[Style.Markdown.Header1].ForeColor = Color.Green;
scintilla.Styles[Style.Markdown.Header2].ForeColor = Color.Green;
scintilla.Styles[Style.Markdown.Header3].ForeColor = Color.Green;
scintilla.Styles[Style.Markdown.Header4].ForeColor = Color.Green;
scintilla.Styles[Style.Markdown.Header6].ForeColor = Color.Green;
scintilla.Styles[Style.Markdown.HRule].ForeColor = Color.Purple;
scintilla.Styles[Style.Markdown.Header5].ForeColor = Color.Green;
scintilla.Lexer = Lexer.Markdown;
Apparently, it doesn't support Markdown.Comment, which I want to be gray. In the comment I may even want to have CSS or Xml Code. Anyways, I want to use two types of highlighting. One is for the Markdown as it is and another is for the comments or inside the comments.
I didn't find any source indicating multiple syntax highlighting. However there are documents for custom syntax highlighting. Do I need a custom one, or can I use a combination of settings to achieve my goal?
Upvotes: 5
Views: 1841
Reputation: 9636
Unfortunately you'll need to either implement a custom lexer, or use an entire different library, since the built-in Markdown lexer does not support comments or multiple syntax highlighting (as the comment at the top of the source file indicates, it does not even support coloring of embedded HTML). And since in this case Scintilla.NET is a mere wrapper around the native library, it won't expose additional functionality for Markdown.
If you take a look at the built-in HTML lexer, you will see that it implements multiple highlighting support for various embedded languages like PHP and JavaScript; the same approach would be required for the Markdown implementation.
Some options you have for working around this problem:
Upvotes: 2