[reportlab-users] tag handling in paragraphs.

Henning von Bargen reportlab-users@reportlab.com
Fri, 30 May 2003 09:57:11 +0200

As mentioned in a previous posting,
the Paragraph class expects all markup tags to be lower case.

This is a bit of a problem if you have to feed markup 
from other sources (say, some simple HTML editor) to the paragraph class.

I tried around a bit and found a way to handle this.
Just an optional argument to the Paragraph constructor to make the 
parser case-insensitive.

The basic idea is to define a __getatrr__ method in the ParaParser class.
It sees if the attribute starts with "start_" or "end_"
and attrName.lower() != attrName and if self.caseInsensitive.
If so, it returns eval(attrName.lower())
[Ahh! And once again a situation where Python can show its power.]

Another thing here was that the _num function only works without units
and implies points.
I tweaked it to accept values with units as well (like "1cm").

I could post my modifications on Saturday/Sunday if anybody is interested.