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

Stephan Diehl stephan.diehl at gmx.net
Mon Sep 24 05:57:01 EDT 2007


Robin Becker wrote:

> Stephan Diehl wrote:

[...]
Robin, I believe you've send this only to me and not to the list...


>>

>>

> Looking in the code it seems the tag of the parent is passed in to the

> bulletMaker as are the parent attributes. Are you sure the option ought

> not to be on the ol? To me setting the initial value seems better on the

> container. ie

>

> <ol initialValue="3">

> <li>an item</li>

> <li>another item</li>

> </ol>

>

> the value attribute on li seems as if it could either be an override or

> a reset. Again I'm not a serious user of para so I'm not going to worry.

> If nobody else objects I'll put this in as a reset on the li tag.


Unfortunatelly, html sticks that option onto the li tag and not the ol.
I'd say, if in doubt, stick to an existing standard.
So, yes, it should be on the li tag.


>

> I'm a bit worried about the code that tests for spaceBefore. I suggest

> using the following patch which keeps the property of being "first"

> separate from the count (which is only needed by ol otherwise). If we

> keep the existing count based approach you will get variable spacing if

> you set the count back to 1. I don't think you should be relying on that

> behaviour.

>

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

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

> @@ -1798,15 +1798,16 @@

> indent = stringWidth("XXX", "Courier", size)

> atts["leftIndent"] = str(indent)

> self.count = 0

> + self._first = 1

>

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

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

> + if not self._first:

> + # forget space before for non-first elements

> + atts["spaceBefore"] = "0"

> + else:

> + self._first = 0

> typ = self.typ

> tagname = self.tagname

> - #print "makeBullet", tagname, typ, count

> - # forget space before for non-first elements

> - if count>1:

> - atts["spaceBefore"] = "0"

> if bl is None:

> if tagname=="ul":

> if typ=="disc": bl = chr(109)

> @@ -1817,12 +1818,16 @@

> if not atts.has_key("bulletFontName"):

> atts["bulletFontName"] = "ZapfDingbats"

> elif tagname=="ol":

> - if typ=="1": bl = repr(count)

> + if 'value' in atts:

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

> + else:

> + self.count += 1

> + if typ=="1": bl = str(self.count)

> elif typ=="a":

> - theord = ord("a")+count-1

> + theord = ord("a")+self.count-1

> bl = chr(theord)

> elif typ=="A":

> - theord = ord("A")+count-1

> + theord = ord("A")+self.count-1

> bl = chr(theord)

> else:

> raise ValueError, "ordered bullet type %s not

> implemented" % repr(typ)

>

>




More information about the reportlab-users mailing list