|
From: Trent M. <tr...@gm...> - 2008-02-07 18:58:54
|
> On Feb 4, 2008 7:50 PM, Blake Winton <bw...@la...> wrote:
> > Hi,
> >
> > uh, you don't know me, but I'm investigating switching a home-grown wiki
> > parser over to use Markdown syntax instead. Since everything else is
> > written in Python, I'm mainly considering python-markdown and
> > python-markdown2. I think you guys have the edge in terms of my being
> > able to add wiki links, and generically extend it,
>
> I'd say you nailed it. That about sums up the difference. With
> python-markdown2, you'd need to hack the core to add or change
> behavior. Personally, I'd much rather use python-markdown's extension
> api. In fact if you run into a few dead ends, let us know. We may be
> able to improve the api to make more things possible.
Blake,
I missed the start of this thread, so I may be mistaken at what you
are trying to do, but markdown2.py has a "link-patterns" feature that
you might be able to use for auto-linking WikiWords (I'm not sure if
that was the wiki syntax you are using):
>>> import re, markdown2
>>> link_patterns = [
... # Match a wiki page link LikeThis.
... (re.compile(r"(\b[A-Z][a-z]+[A-Z]\w+\b)"), r"/\1")
... ]
>>> processor = markdown2.Markdown(extras=["link-patterns"],
... link_patterns=link_patterns)
>>> wiki_page = """
... # This is my WikiPage!
...
... This is AnotherPage and YetAnotherPage.
... """
>>> print processor.convert(wiki_page)
<h1>This is my <a href="/WikiPage">WikiPage</a>!</h1>
<p>This is <a href="/AnotherPage">AnotherPage</a> and <a
href="/YetAnotherPage">
YetAnotherPage</a>.</p>
More details here:
http://code.google.com/p/python-markdown2/wiki/LinkPatterns
Cheers,
Trent
--
Trent Mick
tr...@gm...
|