Simple and complex lists

The html4css1.HTMLTranslator docstring says:

This HTML writer has been optimized to produce visually compact lists (less vertical whitespace). HTML's mixed content models allow list items to contain "<li><p>body elements</p></li>" or "<li>just text</li>" or even "<li>text<p>and body elements</p>combined</li>", each with different effects. It would be best to stick with strict body elements in list items, but they affect vertical spacing in browsers (although they really shouldn't).

Here is an outline of the optimization:

The no_compact_lists setting (--no-compact-lists command-line option) disables list whitespace optimization.

In html4_strict, the algorithm to determine if a list is "simple" enough to be compacted includes field lists (in addition to ordered lists and unordered lists).

Simple lists

  1. This list is simple

  2. There should be no space beween items.

l1:

This list is simple

l2:

There should be no space beween items.

Simple nested lists

  1. This list is simple

    • There should be no space beween items.

    • There should be no space beween items.

l1:

This list is simple

l2:
  • There should be no space beween items.

  1. This list is simple

    1. There should be no space beween items.

l1:

This list is simple

l2:
  1. There should be no space beween items.

  1. This list is simple

  2. 11:

    There should be no space beween items.

l1:

This list is simple

l2:
11:

There should be no space beween items.

Combined paragraph and list in a list item

  • This list is simple

    1. Enumeration in first item

    2. second enumeration item

  • There should be no space beween items.

  1. This list is simple

    1. Enumeration in first item

    2. second enumeration item

  2. There should be no space beween items.

l1:

This list is simple

  1. Enumeration in first item

  2. second enumeration item

l2:

There should be no space beween items.

  • This list is simple

    • Bullet list in first item

    • Bullet list in first item

  • There should be no space beween items.

  1. This list is simple

    • Bullet list in first item

    • Bullet list in first item

  2. There should be no space beween items.

l1:

This list is simple

  • Bullet list in first item

  • Bullet list in first item

l2:

There should be no space beween items.

  • This list is simple

    11:

    this item contains a field list.

    12:

    this item contains a field list.

  • there should be no space beween items.

  1. This list is simple

    11:

    this item contains a field list.

    12:

    this item contains a field list.

  2. there should be no space beween items.

l1:

This list is simple

11:

this item contains a field list.

l2:

There should be no space beween items.

Complex lists

  • This list is not simple

  • Watch the space beween items

    It is caused by this paragraph

  1. This list is not simple

  2. Watch the space beween items

    It is caused by this paragraph

l1:

This list is not simple

l2:

Watch the space beween items

It is caused by this paragraph

  • This list is not simple

    second paragraph in first item

  • Watch the space beween items.

  1. This list is not simple

    second paragraph in first item

  2. Watch the space beween items.

l1:

This list is not simple

second paragraph in first item

l2:

Watch the space beween items.

  • This list is not simple

    • Watch the space beween items

    It is caused by this paragraph

  1. This list is not simple

    • Watch the space beween items

    It is caused by this paragraph

l1:

This list is not simple

l2:
  • Watch the space beween items

  • Watch the space beween items

It is caused by this paragraph

l1:

This list is not simple

l2:
  1. Watch the space beween items

  2. Watch the space beween items

It is caused by this paragraph