[css-d] CSS parser for Microsoft .NET

2010-08-12 Thread Christopher Wells
This is to tell you that I have written a CSS parser component (a
programming library) for Microsoft .NET.

It implements parsing of a stylesheet, and also implements the
specificity and inheritance calculations to determine what CSS rules
and property values are applicable to each element in a DOM.

For further details, see http://www.modeltext.com/css/

You'll find it useful if you develop .NET software and have an
application in which you want to parse CSS.

It's notable in being one of only two CSS parsers for .NET that I know
of, the other one being
http://www.codeproject.com/KB/recipes/CSSParser.aspx

Regards,
Christopher Wells
__
css-discuss [cs...@lists.css-discuss.org]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/


Re: [css-d] The white-space property between blocks

2010-07-10 Thread Christopher Wells
On Tue, Jul 6, 2010 at 9:24 PM, Christopher Wells cwel...@gmail.com wrote:

 Are you saying then, about whitespace between blocks, that:

 Is that the way in which whitespace between blocks is removed? Is the
 whitespace only removed (or rather, hidden or not displayed) by the
 CSS/layout/rendering process, and not removed by the HTML/parsing/DOM
 process?

The following line from [Anonymous inline boxes][1] appears to confirm that:

White space content that would subsequently be collapsed away
according to the 'white-space' property does not generate any
anonymous inline boxes.

Thank you for your help.

Christopher


  [1]: http://www.w3.org/TR/CSS2/visuren.html#anonymous
__
css-discuss [cs...@lists.css-discuss.org]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/


[css-d] The white-space property between blocks

2010-07-06 Thread Christopher Wells
Is the CSS 'white-space' property supposed to be able to affect the
whitespace between block elements?

For example, in the document used as an example in [Whitespace in the
DOM][1] as follows, there is whitespace between the `/h1` and the
`p`:

!-- My document --
html
head
  titleMy Document/title
/head
body
  h1Header/h1
  p
Paragraph
  /p
/body
/html

This whitespace is normally removed; for example, [the XHTML spec says
that a conforming user agent must meet all of the following
criteria][2]:

 In elements where the 'xml:space'
 attribute is set to 'preserve', the
 user agent must leave all whitespace
 characters intact (with the exception
 of leading and trailing whitespace
 characters, which should be removed).
 Otherwise, whitespace is handled
 according to the following rules:

 * All whitespace surrounding block elements should be removed.
 * Leading and trailing whitespace inside a block element must be
 removed.
 * Line feed characters within a block element must be converted into a space
 (except when the 'xml:space' attribute
 is set to 'preserve').
 * A sequence of white space characters must be reduced to a single space
 character (except when the 'xml:space'
 attribute is set to 'preserve').

My questions are as follows:

* If I use the [CSS white-space property][3] on the `body`, should
this be able to preserve the whitespace between block elements (e.g.
between the `/h1` and the `p`)? Or is whitespace between blocks
always removed, with the white-space property only affecting
whitespace within blocks?

* The XHTML spec says that a `body` [cannot directly contain
PCDATA][4] (i.e. text). Does that mean that whitespace (being a kind
of text) that's a direct child of the `body` tag is always
insignificant/ignored, and cannot be enabled via CSS? If yes and
whitespace between the `/h1` and the `p` in the above example were
ignored because it's a direct child of the `body`, would/should that
whitespace still be ignored if there were a `div style=white-space:
pre` immediately within the `body` and enclosing all the other
elements?

* [The 'white-space' processing model][5] starts with, Any text that
is directly contained inside a block element (not inside an inline
element) should be treated as an anonymous inline element. What
should I understand about pure whitespace (whitespace with no text)?

* Is there a rule (and if so, where is this rule defined) about
removing whitespace within inline elements? For example in the
following sequence `pThe strong lazy /strong dog./p` should
the whitespace after the `strong` tag be removed? (The HTML 4 spec
has [a rule about this for line breaks][6]; I was wondering whether
this rule also applied to other, non-line-beak whitespace, and whether
this rule is mentioned/defined/allowed/assumed in any XHTML or CSS
specification.)

I'm more interested in what I'm supposed to understand from the
(present and/or future CSS and/or HTML and/or XHTML) specs than I am
in knowing how well if at all the various browser versions implement
those specs.



  [1]: https://developer.mozilla.org/en/whitespace_in_the_dom
  [2]: 
http://www.w3.org/TR/2000/WD-xhtml-modularization-2105/conformance.html#s_conform_user_agent
  [3]: http://www.w3.org/TR/CSS2/text.html#white-space-prop
  [4]: 
http://www.w3.org/TR/2001/REC-xhtml-modularization-20010410/abstract_modules.html#s_structuremodule
  [5]: http://www.w3.org/TR/CSS2/text.html#white-space-model
  [6]: http://www.w3.org/TR/html401/appendix/notes.html#notes-line-breaks
__
css-discuss [cs...@lists.css-discuss.org]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/


Re: [css-d] The white-space property between blocks

2010-07-06 Thread Christopher Wells
On Tue, Jul 6, 2010 at 2:03 PM, Philippe Wittenbergh e...@l-c-n.com wrote:

 16.6.1 The 'white-space' processing model provides the answer
 http://www.w3.org/TR/CSS21/text.html#white-space-model
 (second list)

Are you saying then, about whitespace between blocks, that:

1. Whitespace between blocks is like text, in that it's treated as an
anonymous inline element (even if the DOM doesn't permit
non-whitespace text in this location, e.g. between a ul and a li).

2. That whitespace between blocks is usually (unless white-space has
a non-default value) then condensed to a single space.

3. The browser begins to render the single space, by laying it out as
a line on its own (between the two blocks)

4. The space is removed during the line layout (because it's at the
beginning of the line)

5. The line now contains nothing, so the line layout is aborted and/or
the line is given zero height?

Is that the way in which whitespace between blocks is removed? Is the
whitespace only removed (or rather, hidden or not displayed) by the
CSS/layout/rendering process, and not removed by the HTML/parsing/DOM
process?

I used to think that whitespace was also removed by the parser before
it reaches the DOM, e.g. as described in item 9 of the [XHTML Family
User Agent Conformance][1] specification but apparently I was wrong,
and it is not removed by the parsing from the DOM: [Why is xml:space
set to 'preserve' on all elements of XHTML?][2] for XHTML2 explains
that 'all elements are set to xml:space=preserve in XHTML2,
otherwise the CSS 'whitespace' property would have no effect'.

 * Is there a rule (and if so, where is this rule defined) about
 removing whitespace within inline elements? For example in the
 following sequence `pThe strong lazy /strong dog./p` should
 the whitespace after the `strong` tag be removed? (The HTML 4 spec
 has [a rule about this for line breaks][6]; I was wondering whether
 this rule also applied to other, non-line-beak whitespace, and whether
 this rule is mentioned/defined/allowed/assumed in any XHTML or CSS
 specification.)

 Again, refer to 16.6.1, more particularly, the first ordered list, point 4.2

So the following are all valid and display identically:

   `pThe strong lazy /strong dog./p`

   `pThe stronglazy/strong dog./p`

   `pThestrong lazy /strongdog./p`

And the reason why they're the same is that the consecutive spaces are
collapsed (even when they belong to different/adjacent inline text
runs).

Do text nodes in the parsed DOM still contain all the original
whitespace characters? For example, do the text nodes have values like
The  and  lazy ?

Do the DOM Node.normalize() and Document.normalizeDocument() have any
effect on the whitespace: do they trim, collapse or remove extraneous
whitespace from the text nodes?

Thanks,
Christopher
---
Christopher Wells
http://www.modeltext.com/html/



  [1]: 
http://www.w3.org/TR/2000/WD-xhtml-modularization-2105/conformance.html#s_conform_user_agent
  [2]: http://www.w3.org/MarkUp/2004/xhtml-faq#xmlspace
__
css-discuss [cs...@lists.css-discuss.org]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/