|
From: Waylan L. <wa...@gm...> - 2008-10-13 17:26:59
|
On Mon, Oct 13, 2008 at 9:33 AM, Waylan Limberg <wa...@gm...> wrote:
> As a sidenote, I'm intrigued by the MarkdownParser class. One could
> conceivably replace that class with their own which works differently
> internally - as long as it has the same public methods and returns an
> etree instance. This really opens up the possibility of
> overriding/changing the core stuff. Cool!
Well, maybe not so cool. By making all (most) of the methods truly
private it makes moneypatching more difficult. I realize it's not that
hard to use a subclass rather than monkeypatch, but what happens when
two extensions each create their own subclass changing a different
method? With monkeypatches, we just used the same instance and all was
good.
Now, thats not so easy. Sure, it's possible, but definitely feels more
hacky. For example, the CodeHilite extension has to do this:
md.parser._MarkdownParser__processCodeBlock = __hiliteCodeBlock
instead of this:
md._processCodeBlock = _hiliteCodeBlock
Or does someone have any suggestions of how to resolve different
extensions all using different subclasses of MarkdownParser without
each extension being specifically aware of the others? I don't see how
mixins would work here either. Or am I missing something obvious?
--
----
Waylan Limberg
wa...@gm...
|