Page 1 of 1

Help me test my syntax highlighter

Posted: Fri Oct 28, 2011 11:41 am
by jraede
I decided that it would help me to document projects to have a syntax highlighter that worked for more than one language at once, so after searching for a while (I'm willing to bet that someone knows of one that I didn't find, but hey, it turned out pretty well), I made one myself. It separates and highlights HTML, JavaScript, PHP, and CSS.

It's still in alpha stages and I would love if people who work with a lot of code could help me test it out.

Check it out at http://www.tavorinteractive.com/syntax-highlighter/

Thanks!

Re: Help me test my syntax highlighter

Posted: Fri Oct 28, 2011 12:49 pm
by twinedev
Tried the following, it lost some of it...

Code: Select all

<html>
<head><title>Test here</title></head>
<body>
  <h1><?= $heading ?></h1>
  <? $var = 'Hello'; ?>
  <table>
   <tr>
     <td><?php echo $var;,"</td></tr>"; ?>
  </table>
</body>
</html>

Re: Help me test my syntax highlighter

Posted: Fri Oct 28, 2011 1:55 pm
by jraede
K, I gotta add the <? ?> shorthand syntax. Did it lose anything else besides what was in those tags?

Edit: I guess I can test that as well, going over it now.

Edit 2: whoops, forgot to make it recognize table tags as valid HTML. Knew I missed something big. Thanks for the heads up

Re: Help me test my syntax highlighter

Posted: Fri Oct 28, 2011 3:39 pm
by flying_circus
Looks like it also struggles on certain matches.

For example: print and int

The "pr" part of print is one color while the "int" part is another. I assume this is because it found the keywork "int" and thought it was a declaration or cast.

Overall though, it looks great. Seems to work pretty fast in my limited use. Nice work :)

Re: Help me test my syntax highlighter

Posted: Fri Oct 28, 2011 5:25 pm
by jraede
Updated with all valid HTML tags and <? ?> PHP shorthand. I'm working on a solution for pr(int) and other such problems, it should be good to go soon. I also found a bug in which something like

Code: Select all

$string = "The string is '".$variable."'.";
...would first parse the stuff in between the single-quotes, thinking it's a normal string, and then the stuff in the double quotes, so the variable would get colorized as if it's in a string.

@flying_circus, thanks for checking it out, glad you like it.