Sublime Forum

Syntax highlighting problem

#1

First time user here :smile:

It seems that any syntax highlighting after this HTML is suspended:

<div id=content>

And is resumed after the matching closing tag.

See the attached screenshot.

I’m using a fresh install of whatever the latest version is (just downloaded a half hour ago), on Windows 7 x64 SP1.


0 Likes

#2

I’m just going to make a wild guess here. It very well could be waaaaay off. Try putting quotes around the attribute values

<div class="article">
  <div id="content">
  ...
  </div>
</div>

I’m wondering if the regex expects quotes to be there.

0 Likes

#3

That works around the problem.

But without quotes is perfectly valid HTML, so I won’t change it just for the sake of working around a bug in my editor.

0 Likes

#4

If that indeed addresses the issue, it’s not a bug in the editor. It’s the HTML syntax definition that is written in such a way as to expect quotes. If you are adept at regular expressions, you can edit it to not require them.

0 Likes

#5

It’s generally considered bad practice to not quote attribute values. What happens when your value has whitespace? Or if you want to add several classes to an element? Double-quotes make the attribute-value relationship unambiguous.

Larger discussion here: stackoverflow.com/questions/6495 … attributes

0 Likes

#6

This one is static and will never have whitespace or quotes. Besides it’s perfectly well specified what exactly must be quoted and what can remain unquoted. Furthermore, this validator will tell you what’s valid or not, and will work in every browser that came out in the past 40 years. What’s more, the syntax highlighter is clearly named “HTML”, not “XHTML”. Lastly, these kind of responses are usually made by people who are simply uncomfortable with unquoted attributes anyway. No offense.

So I don’t see a problem.

About the regex. Well, yes i am okay with regexes, it’s just that I’m not going to adapt internal config files. They would be overwritten in the next version. It’s a fix that should be in the next version of the application, not in my local config.

0 Likes

#7

You’re welcome to ignore my advice, I don’t mind.

Regarding the syntax files, it’s unlikely the change will be made in the official packages. This isn’t a new problem, and hasn’t been addressed so far as I know.
The syntax definitions are compatible with Textmate, which does have a github repo for it’s syntax files. You can push your changes there if you want.

0 Likes