PreviousTracker indexSee it online !

(231/231) 3615189 - HTML syntax highlighting error: & in href

I've got an img element with an href inside it that contains an & character for a second URL parameter. It's a Google Maps static image API call, a la https://developers.google.com/maps/documentation/staticmaps. This breaks the subsequent syntax highlighting. I've installed the latest HTML edit mode, but it's still happening.

I'm on jEdit 5.1.0 server mode, running on Java 1.7.0_45.

Submitted wobl - 2013-11-07 - 09:06:50z Assigned nobody
Priority 5 Category text area and syntax packages
Status Pending Group minor bug
Resolution None Visibility No

Comments

2013-11-07 - 13:20:53z
kpouer
I don't understand, you just have to encode & as & and it is solved right ?
2013-11-07 - 14:28:29z
marchaefner
Yes, encoding would resolve the issue (and not confuse the XML plugin). But HTML5 (and all major browsers) do actually allow unencoded ampersands. The slightly horrible details: http://www.w3.org/TR/html5/syntax.html#consume-a-character-reference

Syntax highlighting should handle that situation better. A fix is underway. But it will not completely cover the specification, because I won't put 2125 named character references in the mode file, or any for that matter...

(Another issue would be the XML plugin that seems to insist on encoded ampersands.)
2013-11-07 - 21:40:35z
kerik-sf
The recommendation states that it is allowed for "historical reasons".
The XML plugin should not encourage these broken cases.
When syntax highlighting is broken a careless insertion of copy-pasted url is detected.
2013-11-08 - 11:53:41z
marchaefner
A fixed version can be found at https://raw.github.com/marchaefner/jEdit-modes/master/html.xml

Unencoded ampersands (that don't seem to be the start of an SGML character entity) are now marked as INVALID and don't impact subsequent highlighting.

This compromise between HTML5 and previous versions, which are all highlighted with this mode, hopefully addresses all concerns. (I retract any points I may have made about the XML plugin, it's working fine enough.)

Patch #3614699 will be updated shortly.

Attachments

2013-11-07 - 09:06:51z
wobl
jedit bug.PNG

Line after img element should have normal highlighting; it doesn't.