CodeHighlighter Cross-Browser compatibility

CodeHighlighter for ASP.NET Forum

Posted 18 years ago by Ryan - Camalot Designs
Avatar
I recently noticed an issue with firefox 1.5.0.1 and Code Outlining. The generated code to collapse/expand a region uses something like
  cf_108_186_Open_Text.style.display='none';
this does not work in firefox, in order for it to work I had to find the text and replace it with
  document.getElementById('cf_108_186_Open_Text').style.display='none';
this should work in all current browsers.

Here is the sample code that i used to change the output of the CodeHighlighter
  private void transformFormattedCode(string code) {
    Regex rex = new Regex(@"(?:\s+)([a-zA-Z]*_.*?_(?:Closed|Open)_(?:Image|Text)*)",
      RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase);
    code = rex.Replace (code, new MatchEvaluator (objectReplaceMatch));
  }

  private string objectReplaceMatch(Match m) {
    return m.Result ("document.getElementById('$1')");
  }
by the way, I love this product and the SyntaxEditor...

Comments (1)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Good call Ryan... we'll make this change for the next release. Thanks for the info!


Actipro Software Support

The latest build of this product (v4.0.59) was released 13 years ago, which was after the last post in this thread.