Syntax color in Html

saechira

New member
Joined
May 9, 2008
Messages
1
Programming Experience
Beginner
Hello,

I have a source code file . I need to display the content in a webpage along with the coloring syntax of that language.Is there any class specifically to do this in vb.net. Kindly Let me know if there is any other way to get this done.

thanks
 
Try the attached MarkupColorizer class I wrote. It uses a few regex expressions and regular string parsing to analyze the markup string. Span elements are used to format output with color, optionally with Style or CSS Class. There are also some other options like backcolor, font, changing each element color and option to generate only body or full document. I don't think there are many bugs left, note that scripts usually need to be escaped by common practice. Here is a usage example:
VB.NET:
Using mc As New MarkupColorizer
    mc.TableColor(MarkupColorizer.Colors.Comment) = Color.SeaGreen 'change a default element color
    mc.DocumentBackColor = Color.LightYellow 'change document backcolor
    mc.UseCSScolor = True 'span class formatting
    Dim encoded As String = mc.Colorize(htmlcontent)

End Using
'htmlcontent' is a string containing original markup, 'encoded' is the returned color encoded document that you may have different uses for.
 

Attachments

  • vbnet20-MarkupColorizer.zip
    2.9 KB · Views: 22
Back
Top