Welcome to MSDN Blogs Sign in | Join | Help

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.

Published Wednesday, January 12, 2005 7:34 AM by Mikhail Arkhipov (MSFT)

Comments

# re: What's wrong with VS HTML editor parser?

Invivo software has developed a component called "WebDesigner" that wraps the MSHTML editing platform. It has some cool features including -

1. Code preservation.
2. Rendering custom tags.
3. Rendering include pages for jsp documents
For more information visit - www.invivosoft.com

Note: I work for Invivo software.

Thanks
Namrata
Tuesday, January 18, 2005 11:32 AM by Namrata
New Comments to this post are disabled
 
Page view tracker