Sublime Forum

Error in HTML support grammar!

#1

Sublime ships with an error in the HTML language grammar.

Try this:

<img src="foo" alt='that\'s all folks' />
And you’ll see it doesn’t know about escaped punctuation inside quotes.

The problem can be fixed with a few small changes to HTML.tmLanguage – is this available on github? Can’t find it.

0 Likes

#2

[quote=“fcgrx”]Sublime ships with an error in the HTML language grammar.

Try this:

<img src="foo" alt='that\'s all folks' />
And you’ll see it doesn’t know about escaped punctuation inside quotes.

The problem can be fixed with a few small changes to HTML.tmLanguage – is this available on github? Can’t find it.[/quote]

As far as I know, you shouldn’t use single quotes in HTML attributes. In fact, from my experience it’s actually slower to use single quotes (by milliseconds).

What happens if you use double quotes instead?

0 Likes

#3

[quote=“Eduan”]
As far as I know, you shouldn’t use single quotes in HTML attributes. In fact, from my experience it’s actually slower to use single quotes (by milliseconds).

What happens if you use double quotes instead?[/quote]

Single quotes are fully allowed and completely supported. w3schools.com/html/html_attributes.asp
(i will separately investigate the claim that single quotes take longer to process)

If you change to double quotes it’s broken just the same.

<img src=“carltonfisk.jpg” alt=“Carlton “Pudge” Fisk” />

0 Likes

#4

I wasn’t under the impression that backslash escaping was possible in HTML, though I now know it is supported by browsers despite not being in any spec I can find.

I’d recommend using the relevant HTML character entity instead; these work in Sublime Text and are definitely part of spec.

If you’re still keen on adding support for this, the tmLanguages in Sublime Text are based on the bundles from Textmate, the original source of which you can find here;
github.com/textmate/html.tmbund … HTML.plist - the plist extension should be swapped for tmlanguage for use with Sublime Text)

I’m not sure how quickly, if ever, it would trickle downstream to ST, though.

0 Likes