27

I enter the following in the HTML box of a stack snippet:

<div>
          <select>
              <option></option>
                  </select>
              </div>

Then I click Tidy, and the result is:

<div>
  <select>
              <option></option>
                  </select>
</div>

It fixed the indentation of <select> and </div>, but <option></option> and </select> are not correct.

9
  • 5
    OK, that's <select><option>hilarious</option><option>intriguing</option></select>.
    – BoltClock Mod
    Commented Apr 17, 2018 at 17:06
  • 14
    You just have to adjust your definition of tidy ...
    – rene
    Commented Apr 17, 2018 at 17:07
  • I wanted to compare this to the behavior over at JSFiddle but couldn't get that to actually tidy anything.
    – BSMP
    Commented Apr 17, 2018 at 18:05
  • @BSMP I just tried it there, it did exactly the same thing as Stack Snippet. jsfiddle.net/barmar/ekooxtt4
    – Barmar
    Commented Apr 17, 2018 at 19:20
  • 5
    It appears that StackOverflow uses js-beautify for the CSS/JS/HTML formatting in the editor. By default, that library explicitly excludes <select> from the list of elements that get formatted. The good news is that list is configurable.
    – Cᴏʀʏ
    Commented Apr 18, 2018 at 14:36
  • @Cᴏʀʏ: Heh... funny that it excludes select because it's phrasing content - that's exactly how I used it in my comment above. Inline, as part of a sentence. Running my comment through tidy now will break that sentence by isolating and indenting the select, resulting in a space between it and the punctuation mark. Having said that, I recognize that far fewer people use select elements inline than as blocks, so it's on me to be careful never to run all my markup through tidy...
    – BoltClock Mod
    Commented Apr 20, 2018 at 4:10
  • @BoltClock I guess it's for some kind of Mad Libs use of select?
    – Barmar
    Commented Apr 20, 2018 at 13:48
  • Hmm, I stand corrected. It looks like tidy preserves the lack of spacing between the end tag and any non-whitespace characters after all.
    – BoltClock Mod
    Commented Apr 20, 2018 at 15:40
  • @Barmar: Yeah, something like that.
    – BoltClock Mod
    Commented Apr 20, 2018 at 15:42

1 Answer 1

1

This will be fixed in the next build.

Exactly as Cᴏʀʏ pointed out, the formatter was explicitly excluding <select> tags.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .