Syntax Highlighting Test

Thursday, June 25th, 2009 at 8:12

Below is some JavaScript code to see if the syntax highlighting is working.

$(document).ready(function() {
  $('.with-default').focus(function() {
    if($(this).val() == $(this).attr('default')) {
      $(this).val('').removeClass('with-default');
    }
  }).blur(function() {
    if($(this).val() == '') {
      $(this).val($(this).attr('default')).addClass('with-default');
    }
  });
});

Now fingers crossed that it works…

  • basp
    BTW, I checked and syntax highlighting is already supported for you guys. Just place the code inside a <pre class="brush:brushname"> tag replacing brushname with one of the aliases in the table at http://code.google.com/p/syntaxhighlighter/wiki/Languages.

    The one below has class="brush:csharp" and although it is not as fancy as I hoped it would be it seems reasonably functional:



    public interface IFoo
    
    {
    public IEnumerable<Bar> Bars
    {
    get;
    set;
    }

    public abstract Bar ExecuteOnce(string message);

    public IEnumerable<Bar> ExecuteManyManyManyTimes(int times, string message) {
    var theBar = new Bar();
    for(var i = 0; i < times; i++) {
    var theBars = Bars.Where(bar => bar != theBar).Select(bar => bar.Fubar());
    foreach(var bar in theBars)
    {
    yield return bar;
    }
    }
    }
    }

    Just keep in mind to replace those < and >'s with &lt; and &gt; respectively otherwise your comment still won't look right.



    Basic markup is apparently also allowed (quite a lot of tags actually) but please be gentle.

  • @Danthar: I will try to allow for more markup in the comment box as well as some info on how to use it but I have a deep passion for rich text boxes on the web as they never work really well, are too slow, prone to produce evil markup and usually a bitch to to work with. You know I hate Word (and word processing programs in general) to begin with so why bother to reproduce something like that on the web? I'd rather educate my readers in the virtues of markup languages because everyone knows they are the only way forward, right?
  • Danthar
    Now give us c# syntax highlighting!. And a rich edit textbox to type our comments in!
  • Danthar
    Its alive!!!
blog comments powered by Disqus