From: David W. <wo...@cs...> - 2008-02-21 20:59:12
|
On 21-Feb-08, at 3:34 PM, Waylan Limberg wrote: > On Thu, Feb 21, 2008 at 2:33 PM, David Wolever > <wo...@cs...> wrote: >> At the moment, a list extension names is passed to Markdown(), and >> the Markdown class is responsible for loading them. >> This makes it harder to pragmatically load extensions. > Harder in what way? At the moment, you've got to put your extension in a module called mdx_eggs. In the case of DrProject (and, I believe, Trac... But there are doubtless others), each component provides its own syntax (among other things), so it is preferable to have a loop like: for provider in wiki_syntax_providers: extensions.append(provider.get_wiki_syntax()) where get_wiki_syntax() returns an object which is passed directly to Markdown: Markdown(extensions=extensions).convert("...") >> I have written a patch (attached) so that a list of extension >> modules >> will be passed to Markdown(). > One concern I have it that, unless I missed it, you have completely > removed the `extension_configs` arg. You only allow key=value pairs > separated by commas. The `extension_configs` arg makes it possible to > easily set configs programicly or even pass in complex python data > structures. The assumption, which I guess I didn't make clear, what that the extensions passed to Markdown were "ready to go" -- they are just waiting for a call to extendMarkdown(). So, if you were to be using the abbreviation extension, the code would look something like this: abbr = __import__("abbr") abbr = abbr.makeExtension(("abbrs", (("RAM", "random access memory"), ("SSH", "secure shell")))) Markdown(extensions = [abbr]).convert("I use SSH to check my free RAM") Alternately, the load_extension function could be modified to take a "config" parameter... |