Ticket #204 (new enhancement)

Opened 2 years ago

Last modified 2 years ago

Preserve/insert whitespace in output HTML

Reported by: mjjohnson Owned by:
Priority: minor Milestone:
Component: plugin Version: trunk
Keywords: whitespace Cc: mjjohnson.geo@…

Description

Currently WYMeditor outputs all its HTML on a single line, which makes it harder to hand-edit later. Additionally, even if whitespace is inserted while in code view, it gets stripped out. (This makes it especially annoying to enter HTML, switch to WYSIWYM, and then back to plain HTML to continue editing.)

I realize that WYMeditor's main focus is on creating valid HTML, but it doesn't have to touch the whitespace at all. In fact, it could even default to creating valid HTML with helpful whitespace: indentation, new lines, etc. I haven't looked to see what library you're using for validating the HTML, but as an example, html5lib (which is commonly used) by default does nothing at all to whitespace; by combining it with an XML parser, you can even insert good whitespace. (See, for example,  this StackOverflow question.)

Finally, I know that the main point of WYMeditor is to allow people to create valid HTML without having to know anything about it. It would still be nice, though, if it were usable by people who do occasionally want to dive into the HTML. Working with an entire HTML snippet on a single line is just painful, and unnecessary.

Change History

comment:1 Changed 2 years ago by mjjohnson

  • Cc mjjohnson.geo@… added
  • Keywords whitespace added

comment:2 Changed 2 years ago by mr_lundis

  • Owner jf.hovinne deleted
  • Component changed from editor to plugin
  • Milestone 0.5 deleted

Just "not touching" the whitespace won't do much good, as the content isn't generated with any whitespace to begin with. If the manually inserted whitespace would be preserved I think you'd just end up with a mess of different kinds of indentation almost as bad as the total lack of indentation/whitespace.

However I absolutely understand your problem, and I find myself getting annoyed by this from time to time as well. But I don't think this will make it in to 0.5. Although, it could easily be implemented as a plugin (compatible with 0.5) for 0.5.x or any other future release.

If anyone feels like picking this up, this StackOverflow thread could maybe provide a starting point:  http://stackoverflow.com/questions/376373/pretty-printing-xml-with-javascript

Note: See TracTickets for help on using tickets.