Click here to Skip to main content
11,641,971 members (62,089 online)
Click here to Skip to main content
Add your own
alternative version

Multiple Language Syntax Highlighting, Part 1: JScript

, 12 Mar 2003 242.8K 5.9K 170
Makes automaticaly highlighting source code in web page a reality (for C,C++,JScript, VBScript, XML)
<?xml version="1.0" encoding="ISO-8859-1"?>
<highlight needs-build="yes" save-build="no">
    <!-- families of keywords -->
        <!-- C keywords -->
        <keywordlist id="kwc">
        <!-- C++ keywords -->
        <keywordlist id="kwcpp">
        <!-- C++ preprocessor keywords -->
        <keywordlist id="kwpreprocessor" pre="#">
        <!-- STL keywords -->
        <keywordlist id="kwstl" pre="std::">
    <!-- Languages syntax specification -->
        <!-- C++ language specification -->
        <language id="cpp">
            <!-- Code contexts: default (most common) is code. -->
            <contexts default="code">
                <!-- basic source code context -->
                <context id="code" attribute="code">
                    <!-- /* block of comment */ -->
                    <detect2chars attribute="hidden" context="blockdoc" char="/" char1="*" />
                    <!-- // line of comment -->
                    <detect2chars attribute="hidden" context="linedoc" char="/" char1="/" />
                    <!-- " " literals -->
                    <!--				<regexp attribute="literal" context="code" expression='"(.|\\"|\\\r\n)*?((\\\\)+"|[^\\]{1}")' /> -->
                    <regexp attribute="literal" context="code" expression="&quot;(.|\\&quot;|\\\r\n)*?((\\\\)+&quot;|[^\\]{1}&quot;)" />
                    <!-- keyword c -->
                    <keyword attribute="reservedkeyword" context="code" family="kwc" />
                    <!-- keyword c++ -->
                    <keyword attribute="reservedkeyword" context="code" family="kwcpp" />
                    <!-- keyword stl -->
                    <keyword attribute="reservedkeyword" context="code" family="kwstl" />
                    <!-- preprocessor keywords -->
                    <keyword attribute="reservedkeyword" context="code" family="kwpreprocessor" />
                <!-- block comment /* ... �*/ -->
                <context id="blockdoc" attribute="blockdoc">
                    <!-- finish line of comment, start block -->
                    <detect2chars attribute="hidden" context="code" char="*" char1="/" />
                <!-- line comment // ... -->
                <context id="linedoc" attribute="linedoc">
                    <!-- finish line of comment, start block -->
                    <detect2chars attribute="hidden" context="blockdoc" char="/" char1="*" />
                    <!-- finish line of comment end of line -->
                    <linecontinue attribute="hidden" context="code" />

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Jonathan de Halleux
United States United States
Jonathan de Halleux is Civil Engineer in Applied Mathematics. He finished his PhD in 2004 in the rainy country of Belgium. After 2 years in the Common Language Runtime (i.e. .net), he is now working at Microsoft Research on Pex (

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150731.1 | Last Updated 13 Mar 2003
Article Copyright 2003 by Jonathan de Halleux
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid