html5.vim icon indicating copy to clipboard operation
html5.vim copied to clipboard

Handle lack of optional closing tags

Open MarkLodato opened this issue 13 years ago • 6 comments

Many common tags in HTML5, such as <p> and <li>, do not require a closing tag, but the current indent file cannot handle this case. For example,

<ul>
  <li>a
  <li>b
  <li>c

gets turned into

<ul>
  <li>a
    <li>b
      <li>c

MarkLodato avatar Oct 24 '12 13:10 MarkLodato

I guess <p> tag need a closing tag. And I think write HTML in a good style is better. No need to support those tags except some tags only have one tag without closing tag.

stardiviner avatar Oct 25 '12 10:10 stardiviner

Closing optional tags is not universally considered "good style," and besides, the editor is not supposed to impose arbitrary style choices. It should simply interpret the specification correctly.

MarkLodato avatar Oct 25 '12 13:10 MarkLodato

There is no way to detect is this omit close tag or other case. Suggestion?

othree avatar Jan 30 '13 17:01 othree

It is a bit challenging, but I think you could probably cover the most common cases:

  • inside a <p>, the following start at the same level: <p>, <ol>, <ul>, <dl>, <div> (and others, I think)
  • a <li> closes the previous <li>
  • a <dt> or <dd> closes the previous <dt> or <dd>
  • an <option> closes the previous <option>

MarkLodato avatar Jan 30 '13 18:01 MarkLodato

Thanks for suggestion. Looks possible but I can't give a promise.

othree avatar Feb 06 '13 09:02 othree

My indentation is now borked if I close <li>

    <ol>
    <li>Item1</li>
  <li>Item2</li>
</ol>

mindfulmonk avatar Oct 19 '13 19:10 mindfulmonk