//
you're reading...
.NET 2.0

Syntax Highlighter for ASP.NET redux redux

It has been a while since I worked on the Syntax Highlighter for ASP.NET project. I recently started working on it again and I’ve changed the direction I want to go. My initial plans — which mimic’d the original PHP version — was to have a class be responsible for highlighting each kind of language. That worked out fairly well, but it had a major draw back. Simply adding a new keyword required a new compile and recycled the AppDomain when you copied the new version up to the server.

The changes I currently have in the works:

  • Compiled for .NET 2.0 – a .NET 1.x compile should be possible after changing generic collection types back to non-generic ones
  • Language definitions are specified in an XML file. To go along with this the language definition has become much more configurable. Some ideas include:
    • Possible feature: All language parts can be specified in the definition. A language part has two flavor’s: The first is just a regular expression to match. Anything that matches is potentially assigned the part’s class name. The second flavor has a regular expression with a string format parameter and a list of words. The regular expression is run for each word and any matches are potentially assigned the part’s class name.

      Potentially because the assignment can be preempted by other classes, for example being embedded in a string or comment.

    • Currently implemented: Everything that is currently abstract in GenericLanguage is specified in the XML file. Essentially this is the strings it substitutes in its own regular expressions for matching. Comment symbols, string symbols, keywords, literals, etc.
    • This file will be stored in the new App_Data directory and parsed and stored the very first time it is used. The plan is to detect when the file has been updated and reparse it to avoid the recycling of the AppDomain. Of course if ASP.NET detects this and reparses anyway then something else will have to be done.
  • Each language part can specify its own CSS class name. This allows you to style a C++ comment and a C# comment differently without having to resort to extra tricks.
  • Additional parts have been added to the old class-based languaged definition: XML Comment, Preprocessor Symbol, and Literal.
  • The SyntaxHighlighter ASP.NET control has been split into two separate controls. One to highlight code snippets and another to highlight HTML files. This change was necessary because many of the properties that applied to code snippets did not apply to highlighting files. The SnippetHighlighter is still capable of highlighting files, but it won’t attempt to find pre blocks to highlight. Think of it this way: The SnippetHighlighter should be used to highlight a complete set of code, whether that code comes from a file or is specified in the Text property. The FileHighlighter (better name needed) is used to highlight an HTML file containing code inside pre blocks.

There is one other feature I have planned, but I’ll save that as a surprise. 😀

I hope to have this released by the end of the year; but I’m just working on it while I don’t feel like playing Dragon Quest 8 or NHL 2K6 (My ‘Wings are 12-2-0-0-0 🙂 )

Advertisements

About James

I am a Senior Developer/Consultant for InfoPlanIT, LLC. I previously spent over 7 years as a Product Manager for what eventually became ComponentOne, a division of GrapeCity. While there, I helped to create ActiveReports 7, GrapeCity ActiveAnalysis, and Data Dynamics Reports.

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archive

%d bloggers like this: