[reportlab-users] starting ol list item numbering from other value than '1'

Stephan Diehl stephan.diehl at gmx.net
Fri Sep 21 07:41:00 EDT 2007

Robin Becker wrote:

> Stephan Diehl wrote:

>> Hi,


>> while using reportlab, I come across the usecase that I wanted to

>> start numbering of a ordered list (using the platypus.para Paragraph)

>> from another number than one. The syntax would be like the html

>> equivalent, such that

>> <ol>

>> <li value="3">an item</li>

>> <li>another item</li>

>> </ol>


> .........


>> Index: para.py

>> ===================================================================

>> --- para.py (revision 3143)

>> +++ para.py (working copy)

>> @@ -1800,6 +1800,8 @@

>> self.count = 0


>> def makeBullet(self, atts, bl=None):

>> + if self.tagname == 'ol' and 'value' in atts:

>> + self.count = int(atts['value']) - 1

>> count = self.count = self.count+1

>> typ = self.typ

>> tagname = self.tagname

> .......

> Thanks for the patch, but I'm a bit confused. Your example puts the

> value in the li element, but the patch seems to assume it will be on the

> containing ol. If you put a value in the <li> then it won't be needed on

> the ol etc etc. In fact bot ideas are possible, but what do others

> think. I don't get to use para much so I'm not really an expert. The

> other Paragraph class has more extensive features for sequences eg

> resetting chaining etc etc.

I'm quite sure that the details I gave are correct. Please have a look
at the 'Para.compile_ul' method to see that the 'makeBullet' method will
be called with every 'li' element encountered (and self.tagname is still
whatever list type is was, in this case 'ol')

This is of course supposed to be compatible with html.


More information about the reportlab-users mailing list