Open sigmundch opened 9 years ago
It would be nice to have proper indentation as well
It would be nice to have proper indentation as well
that's a bit more tricky. outerHTML currently follows spec for all nodes. Document
does not actually have outerHTML (in spec), so it seemed okay to add a newline as part of how document prints itself, and it wouldn't have any effect when you parse it back (text after document doesn't count). But indentation would actually change tree structure, resulting in extra text nodes.
If you want a pretty printer, it's not hard to do, CodeMarkupVisitor probably serves as a good example: https://github.com/dart-lang/html5lib/blob/master/lib/dom_parsing.dart#L56
It's just worth noting that changing indentation could in theory break the application.
and perhaps we should remove outerHTML from document, and add a different printer API, so we don't have non-standard APIs on the DOM nodes.
sounds good, +1 for a separate printer api
seems to be commonly the case that you want it when dumping code to a file.