2

If I've got something like:

var x = <div><span>hello</span><span>world</span></div>

and add it to some other expression, it gets rendered as:

<div>
  <span>hello</span>
  <span>world</span>
</div>

But in HTML, the whitespace between </span> and <span> is significant.

Is there a way to turn off the auto-indentation that E4X does?

I'm using Rhino JS, but obviously a standard mechanism would be preferred.

Ken
  • 1,159
  • 1
  • 9
  • 13

1 Answers1

1

Yes, just set XML.prettyIndent = 0. If you want to turn off pretty printing entirely, just set XML.prettyPrinting = false. You can read about more switches on the MDC E4X tutorial.

Eli Grey
  • 35,104
  • 14
  • 75
  • 93
  • I'd grant the +200 here, but when I click that, SO gives me the JS alert box, and when I click OK it shows the orange warning div that says simply "(click on this box to dismiss)". – Ken Jan 17 '11 at 15:22
  • Mods can't do jack about bounties and awarding points, but I have used my moderator wand to grant you three wishes, as long as they are doable within a reasonable time frame, at a good price point, and I don't have to actually grant them. –  Jan 18 '11 at 14:22
  • Eli: Right, it was deducted when I created the bounty (I had 223 before this). Or does a bounty of 200 mean I lose 200 points, and then later also have the option of transferring 200 *more* points from me to someone? Is that what the empty error-message-box was trying to tell me? – Ken Jan 18 '11 at 15:32
  • I don't know, it must've been some bug. – Eli Grey Jan 19 '11 at 20:17