HTML Syntax Highlighter

Post a reply

Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: HTML Syntax Highlighter

Re: HTML Syntax Highlighter

Post by _ » Sun Mar 25, 2012 9:28 pm

Hi.

I saw that you have updated the CSS syntax highlighter.

When you can, can you add it to the HTML syntax highlighter?

Thanks again for the prompt reply and fix.
Best regards.

Re: HTML Syntax Highlighter

Post by robert » Wed Feb 08, 2012 4:31 am

The latest batch of regex fixes have been pushed; back to just needing CSS updates.

Re: HTML Syntax Highlighter

Post by _ » Tue Feb 07, 2012 1:38 am

Hi.

Thanks again for the prompt reply and fix.

Tested with latest trunk revision (398).

The following regular expression literals are not highlighted.
Code: Select all
var a = "";
var b = "c";
var c = (a === b ? /^b$/ : /^a$/i);
var d = {w: /^d$/, y: /^abc$/};
var e = [/^d$/, "abc"];

return /^C$/i.test(b);


Best regards.

Re: HTML Syntax Highlighter

Post by robert » Mon Feb 06, 2012 5:46 pm

Regex highlighting for JavaScript has been added (more important since it breaks highlighting). I don't know if it's 100% accurate, but I believe it matches the behavior in Eclipse's JS editor and should be sufficient 99% of the time. CSS-in-HTML is still not there yet.

Re: HTML Syntax Highlighter

Post by _ » Sun Feb 05, 2012 9:53 pm

Hi.

Once again thanks for your prompt reply and fix.

One enhancement request to the JavaScript syntax highlighting:
- Add syntax highlight/awareness of regular expression literals (i.e. /^a$/i), as sometimes it breaks the syntax highlighting of the code following the regular expression literals (e.g. mostly when it has double quote or single quote characters).


Regarding the CSS syntax highlighting it would be great to have more highlighting in the properties and values.

Some issues of the current CSS highlighting:
- The syntax colour of the "someid" id selector is the same as the value of the property "color";
- The value of the property "color" of the "someclass" class selector is not highlighted correctly (i.e. "(").
Code: Select all
#someid {
    color: #3f3f3f;
}
.someclass {
    color: rgb(0,255,0);
}


Best regards.

Re: HTML Syntax Highlighter

Post by robert » Sun Feb 05, 2012 5:53 am

I've fixed the JS issue, and updated the plain JavaScript TokenMaker to behave like that used when highlighting HTML. The only thing left you asked for is CSS highlighting in HTML. Can you please try out the current CSS syntax style and let me know if it meets your needs? You've provided some great feedback for other languages so far, and if there are any tweaks you're going to want for CSS, it'd be better to know them now than to wait until it's been added into HTML, JSP, and PHP (unfortunately it's not really possible to share syntax highlighting code amongst different syntax styles, so it must be copy-and-pasted, so I'd like to make sure the current CSS support is sufficient before proceeding).

Re: HTML Syntax Highlighter

Post by _ » Sun Feb 05, 2012 12:41 am

Hi.

Thanks again for your prompt fix and reply.
Glad you didn't take the easy way.

Tested with the latest trunk revision (394).
The following HTML isn't highlighted correctly, validated with http://validator.w3.org/.
The closing tag "</script>" shouldn't be highlighted as comment but as the end of the script.

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Some Title</title>
        <script language="JavaScript" type="text/javascript">// <![CDATA[
            /*
        // ]]></script>
    </head>
    <body>
        <div id="a">
            <div id="b">
                Some content.
            </div>
        </div>
    </body>
</html>

Some enhancement requests:
- Could you add CSS syntax highlighting to the HTML syntax highlighter?
- Could you change the JavaScript syntax highlighter to be equal to the JavaScript of the HTML syntax highlighter?, as the JavaScript of the HTML syntax highlighter has more "highlighting".

Best regards.

Re: HTML Syntax Highlighter

Post by robert » Thu Feb 02, 2012 3:46 am

Fixed in SVN commit 392. Should now properly colorize multi-line strings (ending with '\'), and detect errors when there are invalid unicode or \xNN escapes.

Let me know if you find any more problems!

Re: HTML Syntax Highlighter

Post by robert » Tue Jan 31, 2012 1:59 pm

Thanks, will fix this ASAP. Was ready to upload a "fix" that no longer differentiated between valid and invalid string literals, but then decided to not take the easy way out. :D

Re: HTML Syntax Highlighter

Post by _ » Mon Jan 30, 2012 2:22 pm

Hello.

Thank you for your prompt fix and reply.

Tested with the latest trunk revision (391).
The strings assigned to the variables x, y and z are incorrectly highlighted as errors.

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>Some Title</title>
  <script language="JavaScript" type="text/javascript">// <![CDATA[
    var x = "\\";
    var y = "\x01";
    var z = "\a \/";
  // ]]></script>
</head>
<body>
  <div id="a">
    <div id="b">
      Some content.
    </div>
  </div>
</body>
</html>


Best regards.

Top

cron