Implementing AutomaticOulining

SyntaxEditor for Windows Forms Forum

Posted 8 years ago by Radjesh Klauke - X-impress
Version: 4.0.0289
Avatar
Hi,

I'm trying to implement outlining after loading an HTML-file. I've looked in the help and the example. The example was... uuuh... Couldn't understand it, nor where/how to start. In the help I found that I need to add Outlining Members. How do I add them? Where do I need to begin? (besides that I need to call the autom.outlining)

I've included an example where I want to use it. http://www.mediafire.com/?ea4s2a1x4aglb12

Thanks in advance.

Comments (10)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Radjesh,

To get outlining wokring, you'd need to add this line to turn on automatic outlining:
.Document.Outlining.Mode = OutliningMode.Automatic
If you do that, then things like <style>...</style> will auto outline. Note that our sample outlining doesn't work on other tags though. Just script and style tags.

Hope that helps.


Actipro Software Support

Posted 8 years ago by Radjesh Klauke - X-impress
Avatar
Thanks. How or where do I add others?

[Modified at 11/21/2011 02:24 PM]
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You can see in the HtmlDynamicSyntaxLanguage.cs file in its GetTokenOutliningAction where it's matching pairs of tokens for automatic outlining. You can add more pairs there as you need.

If you are looking to do HTML tag highlighting, well that's a lot trickier since for that you need to match up tags based on tag name and HTML isn't always well formed either. For that sort of thing, you'd need a semantic parser for your language so that you would have an AST of the document to look at. Then you'd do outlining more like our Simple language sample does, where it uses AutomaticOutliningBehavior.SemanticParseDataChange and updates the outlining based on the AST data.


Actipro Software Support

Posted 8 years ago by Radjesh Klauke - X-impress
Avatar
Hi, thanks for the reply

I first need to know how to add the pairs properly, since I can;t get it to work. It seems that I'm forgetting something.
I added the following as a test in the "GetTokenOutliningAction":
Case "html_ulStart"
   outliningKey = "html_ul"
   tokenAction = OutliningNodeAction.Start
Case "html_ulEnd"
   outliningKey = "html_ul"
   tokenAction = OutliningNodeAction.End
and in the "SetOutliningNodeCollapsedText" the following:
Case "html_ul"
node.CollapsedText = "<ul></ul>"
But no collapsing for the <ul>. What am I missing?
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Radjesh,

Well as mentioned above, it will be difficult to get tag pair matching done unless you are using a parser and have an AST ready. The only reason the script and style tags collapse now is because they are language transitions to Javascript and CSS and our outliner will automatically outline language transitions.

If you look at our samples, the languageTokenKey is token.Language.Key + "_" + token.Key;

So you'd want your keys to be something like "HTML_ULStart" assuming you have a pattern in your language with TokenKey="ULStart". We don't define such a pattern though so you would have had to have modified our HTML sample to add it.


Actipro Software Support

Posted 8 years ago by Radjesh Klauke - X-impress
Avatar
Aha. I'll have a good look a it and let you know. Thanks so far.
Posted 8 years ago by Radjesh Klauke - X-impress
Avatar
Hmmmm... nope. App crashes. Could you have a look at the sample and tell me if I'm going into the right direction and/or wrong?

http://www.mediafire.com/?0fgwpb8wabdgew9

At line 92 of the html.xml I added a "childstate" and starting from line 270 the rest. After that I started to implement it in the HtmlDynamicSyntaxLanguage.
What am I doing wrong? Example?
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Radjesh,

The problem here is that you recursively do language transitions into the html.xml language definitions, which causes a stack overflow. I changed your language to handle this better but even so, it doesn't outline it since it's not doing a true language transition. It's just going to another state in the same language.

So sorry, but unfortunately you will only be able to get outlining working here if you make a parser that builds an AST and then use that AST data to build your outlining tree.


Actipro Software Support

Posted 8 years ago by Radjesh Klauke - X-impress
Avatar
Okay, thanks for the support
How to do that? (AST) Can't find anything in the "Help".

[Modified at 11/24/2011 02:54 AM]
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Radjesh,

Well to build ASTs you need to construct a semantic parser. It's more of an advanced topic and can be time consuming depending on how complex you want your parser to be.

We have a parser generator that helps you build grammar-based parsers. You can read our documentation under "Parser Generator Guide" and look at our samples for more information on that.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 7 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.