David Goodger | 1 Nov 04:01 2004

Re: Re: Transitions

[Felix Wiemann]
 > I think I was confused by the name "FinalChecks".  Should it be
 > renamed to "Final", or "FinalTransforms"?

I don't see a problem with the name.  It is a transform, but it
doesn't need to have the word "Transform" in its name; most don't.
And it does final checks.

[David Goodger]
 >> Several transition tests will have to be moved to
 >> test_transforms, but that's not a big deal.
 >
 > I just activated transforms for test_transitions.py (with
 > ParserTransformTestCase), so we don't need to move things.

I don't like that, because that makes
test/test_parser/test_rst/test_transitions.py test more than just the
parser; it now tests a transform too.  In fact, more than just one; it
tests all the parser transforms.  That makes it a functional test
suite, wich isn't appropriate.  The correct place for these tests is
in test/test_transforms/test_final_checks.py; added (thanks for moving
the transform code).  I also removed the ParserTransformTestCase.

There's a problem with the structure model as it stands:

<!ENTITY % structure.model
    " ( ( (%body.elements; | topic | sidebar)+,
          (transition, (%body.elements; | topic | sidebar)+ )*,
          ( (%section.elements;), (transition?, (%section.elements;) 
)* )? )
(Continue reading)

David Goodger | 3 Nov 21:14 2004

change to definition lists

I just checked in support for multiple classifiers in definition list
items.  Example:

     term : classifier one : classifier two
         Definition

Could users of LaTeX and other formats please verify that the
output is correct?  Thanks.

--

-- 
David Goodger <http://python.net/~goodger>
Aleksey Gurtovoy | 7 Nov 01:05 2004

Path for proper handling of :Authors:

The attached tiny path implements the DocInfo transformation for the 
":Authors:" field as per 
http://docutils.sourceforge.net/docs/ref/doctree.html#authors,
making the following warning obsolete:

    'Bibliographic field "%s" incompatible with extraction: '
    'it must contain either a single paragraph (with authors '
    'separated by one of "%s"), multiple paragraphs (one per '
    'author), or a bullet list with one paragraph (one author) '
    'per item.'

--
Aleksey Gurtovoy
MetaCommunications Engineering
Attachment (frontmatter.py.diff ): application/octet-stream, 473 bytes
Jason Diamond | 7 Nov 05:09 2004

html writer not outputting lone paragraphs correctly

Hi.

I might have discovered a bug in the HTML writer when trying to write 
documents containing a single paragraph.

 >>> import docutils.core
 >>> docutils.core.publish_parts('foo', writer_name='html')['body']
u'<div class="document">\nfoo</div>\n'
 >>> docutils.core.publish_parts('foo\n\nbar', writer_name='html')['body']
u'<div class="document">\n<p>foo</p>\n<p>bar</p>\n</div>\n'

Notice the first example doesn't wrap "foo" with a p tag. But with more 
than one paragraph, as in the second example, it is wrapped in a p tag.

This is using the latest CVS code.

-- Jason

-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
David Goodger | 7 Nov 05:30 2004

Re: Path for proper handling of :Authors:

[Aleksey Gurtovoy]
> The attached tiny path implements the DocInfo transformation for the 
> ":Authors:" field as per 
> http://docutils.sourceforge.net/docs/ref/doctree.html#authors,

Sorry, I don't see the relevance of that link.  Could you explain
please?

> making the following warning obsolete:
> 
>     'Bibliographic field "%s" incompatible with extraction: '
>     'it must contain either a single paragraph (with authors '
>     'separated by one of "%s"), multiple paragraphs (one per '
>     'author), or a bullet list with one paragraph (one author) '
>     'per item.'

I don't see how your patch helps.  Could you provide example input
showing a case where this makes a difference?

--

-- 
David Goodger <http://python.net/~goodger>
Jason Diamond | 7 Nov 05:39 2004

Re: html writer not outputting lone paragraphs correctly

Wow. You're quick.

David Goodger wrote:

> One person's bug is another person's feature. ;-)
>
> In this case, it's a feature.
> docutils.writers.html4css1.HTMLTranslator.visit_paragraph contains
> this comment:
>
>         # Omit <p> tags if this is an only child and optimizable.
>
> This is done to minimize extraneous vertical whitespace that many
> browsers add with <p> tags, although they really shouldn't.  Because
> of the way browsers render HTML, the Docutils HTML writer treats HTML
> as dumb markup (to a degree).
>
> Was this behavior causing any trouble?

I'm using docutils as part of a blog/wiki engine. For entries that 
contain a single paragraph, I don't get any p tags and so don't have any 
way to refer to the paragraph via CSS.

I noticed this when creating an index page which contains multiple 
entries. Each entry is wrapped in its own div tag but I expected all the 
text in each div to be wrapped in p tags but saw that they weren't in 
some cases.

So I might not call it "trouble" but it could be annoying for me later 
on. I was more annoyed by the inconsistency at this point. (Yes, I'm anal.)
(Continue reading)

David Goodger | 7 Nov 06:02 2004

Re: html writer not outputting lone paragraphs correctly

[Jason Diamond]
 > Wow. You're quick.

If you're lucky ;-)

 > So I might not call it "trouble" but it could be annoying for me
 > later on. I was more annoyed by the inconsistency at this
 > point. (Yes, I'm anal.)

HTML itself is full of inconsistencies.  Accept that, and free your
mind. ;-)

However, it would be easy enough to add an option to disable such
optimizations.  There's already a --no-compact-lists option; we could
add a --no-compact-paragraphs option too.

--

-- 
David Goodger <http://python.net/~goodger>
David Goodger | 7 Nov 05:26 2004

Re: html writer not outputting lone paragraphs correctly

[Jason Diamond]
> I might have discovered a bug in the HTML writer when trying to write 
> documents containing a single paragraph.
...
> Notice the first example doesn't wrap "foo" with a p tag. But with more 
> than one paragraph, as in the second example, it is wrapped in a p tag.

One person's bug is another person's feature. ;-)

In this case, it's a feature.
docutils.writers.html4css1.HTMLTranslator.visit_paragraph contains
this comment:

         # Omit <p> tags if this is an only child and optimizable.

This is done to minimize extraneous vertical whitespace that many
browsers add with <p> tags, although they really shouldn't.  Because
of the way browsers render HTML, the Docutils HTML writer treats HTML
as dumb markup (to a degree).

Was this behavior causing any trouble?

--

-- 
David Goodger <http://python.net/~goodger>
Jason Diamond | 7 Nov 05:29 2004

Re: html writer not outputting lone paragraphs correctly

Jason Diamond wrote:

> I might have discovered a bug in the HTML writer when trying to write 
> documents containing a single paragraph.

Maybe this is intentional.

Here's what I found on HTMLTranslator in html4css1.py:

    def visit_paragraph(self, node):
        # Omit <p> tags if this is an only child and optimizable.
        if (not isinstance(node.parent, nodes.compound) and
            (node.attributes in ({}, {'class': 'first'}, {'class': 'last'},
                                 {'class': 'first last'})) and
            (self.compact_simple or
             self.compact_p and (len(node.parent) == 1 or
                                 len(node.parent) == 2 and
                                 isinstance(node.parent[0], nodes.label)))):
            self.context.append('')
        else:
            self.body.append(self.starttag(node, 'p', ''))
            self.context.append('</p>\n')

That if condition is pretty intense. Would some refactoring help here?

The doc comment for HTMLTranslator mentions this:

    - In non-list contexts, omit <p> tags on a paragraph if that
      paragraph is the only child of its parent (footnotes & citations
      are allowed a label first).
(Continue reading)

Aleksey Gurtovoy | 7 Nov 11:48 2004

Re: Path for proper handling of :Authors:


David Goodger writes:
> [Aleksey Gurtovoy]
> > The attached tiny path implements the DocInfo transformation for the 
> > ":Authors:" field as per 
> > http://docutils.sourceforge.net/docs/ref/doctree.html#authors,
> 
> Sorry, I don't see the relevance of that link.  Could you explain
> please?

It's only slightly relevant, sorry for the confusion. I was 
referring to this part of the linked fragment:

   ((author, organization?, address?, contact?)+)

which of course doesn't have to do anything with the front end.

> 
> > making the following warning obsolete:
> > 
> >     'Bibliographic field "%s" incompatible with extraction: '
> >     'it must contain either a single paragraph (with authors '
> >     'separated by one of "%s"), multiple paragraphs (one per '
> >     'author), or a bullet list with one paragraph (one author) '
> >     'per item.'
> 
> I don't see how your patch helps.  Could you provide example input
> showing a case where this makes a difference?

Sure. Given this document:
(Continue reading)


Gmane