Syntax Highlighting

only works _sometimes_

Page 1 of 1

6 Replies - 3635 Views - Last Post: 15 February 2009 - 05:01 PM

#1 pr4y  Icon User is offline

  • Location: 127.0.0.1
  • member icon

Reputation: 35
  • View blog
  • Posts: 621
  • Joined: 19-September 08

Syntax Highlighting

Posted 11 February 2009 - 04:19 PM

anyone else experiencing this? I have two computers, with 2 different operating systems, and they both do it.


Laptop specs:

Ubuntu 8.04
FireFox

----

Windows XP Pro SP2
FireFox

----



The problem is... when people use specific code like:

<?php

if ($things != $right){
    $help = $_POST['DIC'];
} else {
    $help = $not_needed;
}
?>





^ That code for example... say I click on a topic and am reading it for the first time. The code always looks fine the first time I load the page. But if I use Fast Reply, or even Add Reply, when I am redirected to the page... NONE of the syntax highlighting occurs. Also, whitespace disappears and the code appears left justified.

This is an annoying bug, just wasn't sure if anyone else was experiencing it or was aware of it for that matter.

Thanks guys!

Is This A Good Question/Topic? 0
  • +

Replies To: Syntax Highlighting

#2 pr4y  Icon User is offline

  • Location: 127.0.0.1
  • member icon

Reputation: 35
  • View blog
  • Posts: 621
  • Joined: 19-September 08

Re: Syntax Highlighting

Posted 15 February 2009 - 11:53 AM

anyone?
Was This Post Helpful? 0
  • +
  • -

#3 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3101
  • View blog
  • Posts: 19,140
  • Joined: 14-September 07

Re: Syntax Highlighting

Posted 15 February 2009 - 12:42 PM

Happens to me to, especially if I edit my post which has code in it.
Was This Post Helpful? 0
  • +
  • -

#4 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1868
  • View blog
  • Posts: 20,280
  • Joined: 17-March 01

Re: Syntax Highlighting

Posted 15 February 2009 - 01:04 PM

The syntax highlighter is from Google (i.e. google programmed it).

It has a bug where it does not treat VB comments correctly. (i.e. comments starting with a ' ).

Therefor, it's disabled for anything containing ' type comments.

The only time the syntax highlighter runs (it's javascript) is on page load. Since editing a page does not generate an onload event (just the ajax events that add another div or replace what was in the div to begin with) the syntax highlighter will not re-highlight a piece of code.

We've opted to use the Google syntax highlighter due to it's speed and small form factor. Compared to server side processing, or the old "syntaxhighlighter" javascript we used, the Google syntax highlighter is generally a better product, albeit with some bugs that they will hopefully work out in the next version.
Was This Post Helpful? 0
  • +
  • -

#5 pr4y  Icon User is offline

  • Location: 127.0.0.1
  • member icon

Reputation: 35
  • View blog
  • Posts: 621
  • Joined: 19-September 08

Re: Syntax Highlighting

Posted 15 February 2009 - 03:56 PM

Is the syntax highlighter hosted offsite? I was just wondering if it was a possible fix for DIC, or do we have to wait for Google to fix it?
Was This Post Helpful? 0
  • +
  • -

#6 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1868
  • View blog
  • Posts: 20,280
  • Joined: 17-March 01

Re: Syntax Highlighting

Posted 15 February 2009 - 04:04 PM

If someone wants to dig through the regex and fix it, they are more than welcome to.

This is it here:

<link href="/syntax/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="/syntax/prettify.js"></script>
Was This Post Helpful? 0
  • +
  • -

#7 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2251
  • View blog
  • Posts: 9,435
  • Joined: 29-May 08

Re: Syntax Highlighting

Posted 15 February 2009 - 05:01 PM

Skyhawk133,
There's nearly a general purpose syntax highlighter in the freelance\share your project forum.
The one I designed can highlight vb.net almost as perfectly as Visual Studio (aside from the speed).

What it needs is porting over to a more web friendly language.

This post has been edited by AdamSpeight2008: 15 February 2009 - 05:02 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1