[reportlab-users] Relative indents, nested lists and reST

Andy Robinson reportlab-users@reportlab.com
Wed, 28 May 2003 14:41:55 +0100


Sidnei,

I got overworked this month and did not get around
to looking at your patch - I am very sorry about this.
I have passed it onto a colleague and we'll try to
deal with it in the next week.  How are things progressing
on the PDF writer?

We have also had contact from our local university, who
have many Masters' students looking to do 3 months
of full time work on some summer project.  It occurred
to me that maybe such a resource could be useful
on this stuff.  Can you think of any ways in which
someone with god programming experience but fairly new
to Python, could make a positive contribution?

Thanks,

Andy Robinson

> -----Original Message-----
> From: reportlab-users-admin@reportlab.com
> [mailto:reportlab-users-admin@reportlab.com]On Behalf Of Sidnei da Silva
> Sent: 02 May 2003 14:37
> To: reportlab-users@reportlab.com
> Subject: Re: [reportlab-users] Relative indents, nested lists and reST
> 
> 
> On Fri, May 02, 2003 at 12:14:05AM +0100, Andy Robinson wrote:
> | I won't have much time to look at paragraph implementations
> | until the weekend, but coding seemed more fun than working 
> | tonight :-)  I added one think which I think will really help
> | (and would be quite hard to plug in if you don't know
> | our main loop). 
> | 
> | There is now a concept of "relative indentation" or
> | "context-sensitive indentation" in Platypus.  One thing
> | reST and HTML rendering need is nested lists.  There is
> | a runnable example in
> |   reportlab/test/test_platypus_indents.py
> | which produces
> |   reportlab/test/test_platypus_indents.pdf
> | 
> | 
> | Let's say you want to do this in Platypus:
> | 
> | - level 1 bullet
> | - level 1 bullet again
> |    - level 2 bullet
> |    - level 2 bullet again
> |    Definition:
> |       Paragraph at this level of nexting
> | 
> | You would have to make a style for 'level 1 bullet para',
> | 'level 2 bullet para' etc, track how indented you need to
> | be and dynamically select the right style.  What's missing 
> | is the ability to say "indent all stuff below here by 36 points" 
> | as you enter a list, and dedent again afterwards as you exit it.
> | If you are rendering HTML, you would do this when you saw the
> | <ul> and </ul>, and then use just one style for the bullets.
> | 
> | I added an Indenter ActionFlowable, and modified the main
> | loop slightly.  Indenter takes RELATIVE arguments which
> | modify the left and right margin of the frame, until the
> | next Indenter appears. So you can now do this:
> | 
> | story.append(Indenter(left=36, right=0) )
> | story.append('bullet point 1', bulletStyle) )
> | story.append('bullet point 2', bulletStyle) )
> | story.append(Indenter(left=36, right=0) )
> | story.append('nested bullet point 1', bulletStyle) )
> | story.append(Indenter(left=-72, right=0) )
> | 
> | To do this, frames have two new private attributes
> | _leftExtraIndent and _rightExtraIndent, and these are
> | set by an Indenter.  They 'carry over' from one 
> | frame to the next (and AFAICT work OK when switching
> | templates).
> | 
> | reST and HTML rendering will need a bunch of other stuff too
> | but I hope this helps...
> 
> Indeed it helps! Though the new para.py supports <ul> and friends, its
> output its not nice or controllable. Im still struggling to make it
> use different bullets for different levels of identation.
> 
> Ive did a initial cleanup on the para.py module, mostly style cleaning
> and whitespace. Attached im sending the diff. 
> 
> Here you can see a very raw sample of the current state of the writer:
> 
> http://dev.x3ng.com.br/Members/sidnei/rstIntro.pdf
> 
> There is still a lot of work to do, specially on the template and
> footnotes, but Im getting there :)
> 
> Next thing on my tasklist is update the writer to use the new Indenter
> flowable.
> 
> -- 
> Sidnei da Silva (dreamcatcher) <sidnei@x3ng.com.br>
> X3ng Web Technology <http://www.x3ng.com.br>
> GNU/Linux user 257852
> Debian GNU/Linux 3.0 (Sid) 2.4.18 ppc
> 
> COBOL is for morons.
> 		-- E.W. Dijkstra
>