Freigeben über


What's wrong with VS HTML editor parser?

Parsing HTML for editing purposes is quite different from parsing it by the book. VS HTML parser has a quite a few deviations that allow us to better support statement completion and validation. Look at this bug which we usually see every release since VS 2002 (that's when the code was added). Consider the following markup:

<a b="c" d="e">

User positions caret right after "c", hits backspace twice and invokes statement compeltion for attribute b by hitting Ctrl+Space. The markup looks now like

<a b=" d="e">

If we parse by the book and consider " d=" to be a value for b, statement competion will then replace " d=" by the new value, significantly damaging user code. Since this is much more common editing scenario that having sequence

=[whitespace]

at the end of the attribute value, we give it higher priority.

The issue ofny manifests itself when attribute value ends with an equal sign or with an equal sign followed by a whitespace. <a b="c=d"> actually works fine. The workaround is either to avoid trailing = (try to use : instead) or encode = as an entity: &#61;

We are looking into building a better parser in the future, of course.

Comments

  • Anonymous
    January 18, 2005
    The comment has been removed