Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Allow method chaining without rebuilding the tree #46
Right now, if you chain methods (e.g.
I can see two ways of solving this. One is a total API rewrite, one is less complicated. I'm leaning toward the latter.
from bleach import Bleach text = Bleach(text) print text.clean()
It could store state of what's already been done (like cleaning, linkifying, etc) and either return text (as above) or return itself to allow chaining, e.g.:
# Implement __unicode__ and __str__, seems nicer than above. print Bleach(text).clean().linkify()
Instead of actual
Then the methods would be reworked to check for the tree before rebuilding it, and if found, they would just use the existing tree.
Pros and cons
The rewrite might make it easier to deal with the increasing complexity of
The less-crazy idea doesn't involve subclassing anything, ever. The API can stay the same and it can be a minor version change. I am guessing won't be too difficult to write some sort of