Subject:
Code Highlighting
I have been looking for a good way to insert some code highlighting into the pages related to programming, but as always, nothing seems to work the way I'd like it to work :)
A colleague of mine recently pointed me towards CodeHighlighter from Actipro, but as it seems it was not built for dynamic code generation. A solution to this would be to split the html and put the parts in LiteralControls and mix in the CodeHighlighters in between, but that's not something I'm interested in doing. If anyone knows a good tool that allows on-the-fly html generation, please leave a message.
ActiproSoftware.CodeHighlighter.
CodeHighlighter CH = new ActiproSoftware.CodeHighlighter.CodeHighlighter();
string B = Art.Body;
Match M = Regex.Match(B, @"\[code\=(?<lang>.*?)\](?<code>.*?)\[\/code\]", RegexOptions.Singleline);
while (M.Success)
{
string Lang = M.Groups["lang"].Value;
string Code = M.Groups["code"].Value;
//Set the language key
CH.LanguageKey = Lang;
//Set whether to allow outlining and line numbering
CH.OutliningEnabled = true;
CH.LineNumberMarginVisible = true;
CH.Text = Code;
B.Replace(M.Value, CH.Output);
M = M.NextMatch();
} Created On: [11/3/2007 3:35:43 PM] By: Nick Kusters Last Modified On: [11/3/2007 3:37:38 PM] By: Nick Kusters (1150 views over 990 days)