//
you're reading...
General

Syntax Highlighter’s taste of XML

Just thought I’d post what I just finished coding up….so far this is outside of the working project; but I will reintegrate this soon and start work on recoding the finding/highlighting part to use the new stuff. With the way this is set up I can’t think of languages that won’t work well with it; but I’m sure some exist.

A copy of the current output of my LanguageDefinition.xml file follows the break, and it was generated using the XmlSerializer and an instance of my LanguageDefinition class. I’ve slightly edited the output to remove the XML namespace stuff from the LanguageDefinition element since it was making the content too wide.

<?xml version="1.0"?>
<LanguageDefinition languageNames="c#,cs,csharp">
  <languageParts>
    <languagePart name="keywords" cssClass="keyword" order="1">
      <regex>(?<=\b) ( {0} ) (?=\b)</regex>
      <regexOptions>Multiline IgnorePatternWhitespace</regexOptions>
      <words>
        <word>as</word>
        <word>auto</word>
        <word>base</word>
        <word>break</word>
        <word>case</word>
        <word>catch</word>
        <word>const</word>
        <word>continue</word>
        <word>do</word>
        <word>else</word>
        <word>event</word>
        <word>explicit</word>
        <word>extern</word>
        <word>finally</word>
        <word>fixed</word>
        <word>for</word>
        <word>foreach</word>
        <word>goto</word>
        <word>if</word>
        <word>implicit</word>
        <word>in</word>
        <word>internal</word>
        <word>lock</word>
        <word>namespace</word>
        <word>operator</word>
        <word>out</word>
        <word>override</word>
        <word>params</word>
        <word>private</word>
        <word>protected</word>
        <word>public</word>
        <word>readonly</word>
        <word>ref</word>
        <word>return</word>
        <word>sealed</word>
        <word>stackalloc</word>
        <word>static</word>
        <word>switch</word>
        <word>this</word>
        <word>throw</word>
        <word>try</word>
        <word>unsafe</word>
        <word>using</word>
        <word>virtual</word>
        <word>void</word>
        <word>while</word>
        <word>bool</word>
        <word>byte</word>
        <word>char</word>
        <word>class</word>
        <word>decimal</word>
        <word>delegate</word>
        <word>double</word>
        <word>enum</word>
        <word>float</word>
        <word>int</word>
        <word>interface</word>
        <word>long</word>
        <word>object</word>
        <word>sbyte</word>
        <word>short</word>
        <word>string</word>
        <word>struct</word>
        <word>uint</word>
        <word>ulong</word>
        <word>ushort</word>
        <word>checked</word>
        <word>is</word>
        <word>new</word>
        <word>sizeof</word>
        <word>typeof</word>
        <word>unchecked</word>
        <word>get</word>
        <word>set</word>
        <word>add</word>
        <word>remove</word>
        <word>value</word>
        <word>where</word>
      </words>
    </languagePart>
    <languagePart name="literals" cssClass="cs-literals" order="2">
      <regex>(?<=\b) ( {0} ) (?=\b)</regex>
      <regexOptions>Multiline IgnorePatternWhitespace</regexOptions>
      <words>
        <word>null</word>
        <word>true</word>
        <word>false</word>
        <word>default</word>
      </words>
    </languagePart>
    <languagePart name="preprocessor" cssClass="cs-preprocessor" order="3">
      <regex>(?<=\b) ( {0} ) (?=\b)</regex>
      <regexOptions>Multiline IgnorePatternWhitespace</regexOptions>
      <words>
        <word>#elif</word>
        <word>#else</word>
        <word>#endif</word>
        <word>#endregion</word>
        <word>#error</word>
        <word>#define</word>
        <word>#if</word>
        <word>#line</word>
        <word>#pragma</word>
        <word>#region</word>
        <word>#undef</word>
        <word>#warning</word>
      </words>
    </languagePart>
  </languageParts>
</LanguageDefinition>
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: