What is Dysh?

Dysh (Dynamic source highlighter) Project is a set of JavaScript functions that allows the syntax highlight of source code on the fly, with ease of use, and totally customizable through CSS.

How many programming/scripting languages will Dysh support?

Our goal is to support as many programming/scripting languages as possible.

What is the development process status?

The development process is in alpha status, and all we have for now is an (possibly incomplete and buggy) function that highlights C/C++ source code.

How does it work?

All you have to do to use Dysh in a web page is:

  1. Load the JavaScript and CSS files with something like

    <head>
    ...
    <link rel="stylesheet" href="dysh/dysh_cpp.css" type="text/css" />
    <script type="text/javascript" src="dysh/dysh_cpp.js"></script>
    ...
    </head>

  2. Put a span with unique id in the place you want your code to appear.

    <span id="uniqueid">
    </span>

  3. Put your code in a variable and call one of the Dysh functions you loaded.

    <span id="uniqueid">
    <script type="text/JavaScript">

    var mycode = "Your code goes here";

    dysh_highlight_cpp_code( mycode, "uniqueid" );

    </script>
    </span>

Your source code will appear just in the place you put it but now with its syntax highlighted after the CSS scheme you loaded.

Take a look at the sample below.

If you cannot see any source code below, its probably because your browser is not compliant with W3C DOM specification. Try Firefox or any other W3C compliant browser.

You can take a look at the source code of this page if you wish.

Caveat

As you may know, JavaScript will not accept something like

var mycode =
"#ifndef _IO_H_
#define _IO_H_

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */";

if you want the code to be formated as in the sample above, you have to do this (depends on the line ends used by your system)

var mycode =
"#ifndef _IO_H_\n\
#define _IO_H_\n\
\n\
#ifdef __cplusplus\n\
extern \"C\" {\n\
#endif /* __cplusplus */";

i.e., you have to tell explicitly where your lines end (with the "\n" in this case) and tell that your string will continue next line ("\").

Another point you may have noticed is that the double quotes are escaped

extern \"C\" {\n\

you should do this with single and double quotes.

There are many tools and ways to apply those changes to your code. If you wish you can use our utility.

How can I help?

If you are interested and want to help us, you can do this in three ways:

  1. Writing code
    You can write code for supporting other programming languages that we do not support yet.

  2. Writing style sheets
    You can write a style sheet with a syntax highlight scheme you would like to see supported by Dysh.

  3. Testing
    You can help us submiting bugs you found.

Anyway, mail me at marcio <dot> paim <at> gmail <dot> com.

SourceForge.net Logo