Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Definition of HTML whitespace rules?

I'm looking for this definition to make my HTML renderer conform a bit better. Currently it's guessing which whitespace to keep, which to collapse and what to throw. The SGML standard is hard to find and the HTML standard doesn't seem to treat the subject with the required depth for my needs.

Currently my renderer parses the HTML into a tree and then does a recursive layout pass to position all the elements and their content. I'm experimenting with throwing some whitespace out in the parse stage, i.e. not emitting whitespace only text chunks in certain circumstances. Which kinda works for the majority of cases, but there are a fair few edge cases that are getting hard to deal with.

(I'm also working on an editor subclass of the HTML control, and layout time solutions are proving to be a bit problem in the editor, hence me working on getting them into the parse stage. The layout information isn't available till reflow time, which is some time after you have edited the document.)

Fire away with linkage/flames.

like image 347
fret Avatar asked Sep 15 '09 08:09

fret


Video Answer


2 Answers

I think the section 9.1 White space in the HTML 4 specification is what you’re looking for.

like image 151
Gumbo Avatar answered Sep 30 '22 15:09

Gumbo


So I think the closest I'm going to get for an answer on this is here: http://www.w3.org/TR/CSS2/text.html#white-space-model

like image 22
fret Avatar answered Sep 30 '22 14:09

fret