简体   繁体   中英

Syntax Highlighting of an Embedded Language in Visual Studio 2012

I'm using C# and Visual Studio 2012 to implement syntax highlighting of a language embedded in html (much like ASP code inside <% %>). So far, I've found out that I need to use IProjectionBuffer to achieve this, but there are no examples of how to do this using MEF, apart from a somewhat vague description here: http://msdn.microsoft.com/en-us/library/dd885240.aspx#projection . I tried to assign spans of text from the ITextBuffer that is "imported" through MEF to an IProjectionBuffer , but it had no effect.

Does anybody have any ideas as to how to proceed?

There is a built in feature for this purpose I think. I used to deal with text highlighting in C# code with MEF with tags. I think you shold start with Text.Classification .

There is a lack of documentation sadly, but I think you should build a lexer or somthing similar for the lingual part MSDN:DLR (features) may can help you,

The DLR allows language implementers to avoid creating lexical analyzers, parsers, semantic analyzers, code generators, and other tools that they traditionally had to create themselves.

detect the delimiters, and color it through classification.

Here is an example project to customize C# code displaying.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM