[HTML/XML] Highlighting start/end tags

SyntaxEditor for WPF Forum

Posted 7 months ago by Ethem Acar
Version: 23.1.3
Avatar

Hi,

Example picture what I'm expecting:

https://snipboard.io/m2G0Fz.jpg

Current situation:

https://snipboard.io/Urhd4w.jpg

Comments (3)

Posted 7 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Do you mean that when you have the caret over a start or end tag, you would like it and the matching paired tag to be highlighted as well?


Actipro Software Support

Posted 7 months ago by Ethem Acar
Avatar

Hello,

Yes, I'm actually so used to that because most editors have it:

Notepad++
Visual studio code

etc.

Example from visual studio code:

https://snipboard.io/7a5lmV.jpg

Posted 7 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

We don't have that feature built-in at the moment but I can log it as a suggestion.  To do it yourself for now, you might be able to create a custom IStructureMatcher implementation for XML.  Register that with the syntax language, then also register a DelimiterHighlightTagger service. 

Here is code similar to our Getting Started #14 sample:

language.RegisterStructureMatcher(new XmlStructureMatcher());
language.RegisterService(new TextViewTaggerProvider<DelimiterHighlightTagger>(typeof(DelimiterHighlightTagger)));

Your XmlStructureMatcher class would probably just want to implement IStructureMatcher directly and not inherit a base class since it would be using completely custom logic.  Its Match method would have to look at the document's parse data and find a matching tag.  The TextSnapshotOffset can get you to the snapshot, document, parse data, etc. like this:

if (snapshotOffset.Snapshot.Document is ICodeDocument document) {
	var parseData = document.ParseData;
	// ...
}

I hope that helps give you some starter pointers if you want to try writing one yourself.


Actipro Software Support

The latest build of this product (v24.1.2) was released 5 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.