From: Hendra <hen...@gm...> - 2013-06-23 03:15:58
|
I see,, thanks, that helps a lot. Should've checked out that one. Another question, hope this doesn't sound stupid. Why is the default argument value for `configs` that is passed to the `makeExtension` is `None`, instead of `{}`? wouldn't that cause a TypeError? On Sat, Jun 22, 2013 at 10:29 PM, Waylan Limberg <wa...@gm...> wrote: > Hendra, > > Take a look at the wikilinks extension [1]. It makes extensive use of > configs. Note that some defaults are set first (line 95) in a dict. > Then the user provided settings are forced to a dict (line 101) > (`dict()` will convert a list of tuples to a dict or if passed a dict, > will simply return it). Finally, the settings are iterated over (line > 103), overriding the already set defaults (104). > > So, to answer your question, either a list of tuples or a dict can be > passed in as settings. Either way, it will be stored as a dict if you > use the config methods on the `markdown.extensions.Extension` class. > Of course, as you are subclassing, you can override config handling if > you want to make it work however you would like. > > Hope that helps. > > [1]: > https://github.com/waylan/Python-Markdown/blob/master/markdown/extensions/wikilinks.py > ---- > \X/ /-\ `/ |_ /-\ |\| > Waylan Limberg > > > On Sat, Jun 22, 2013 at 9:03 AM, Hendra <hen...@gm...> wrote: > > Hi, > > I am trying to write a simple extension for the python markdown API, but > I > > am having some problem with setting the config. From the doc: > > > > import markdown > > import myextension > > configs = {...} > > myext = myextension.MyExtension(configs=configs) > > md = markdown.Markdown(extensions=[myext]) > > > > It seems like I would have to pass the config in a dict, but when I try > to > > initialize the extension with the name of the extension, it receives the > > config as a list (I am guessing from config.items() ). > > > > Looking around the source of the extensions here: > > > https://github.com/waylan/Python-Markdown/tree/master/markdown/extensions, > > it seems like in most of them, configs is a list. So, which is the right > > one? > > > > > > -- > > Best Regards, and Thank you, > > Hendra > > > > > ------------------------------------------------------------------------------ > > This SF.net email is sponsored by Windows: > > > > Build for Windows Store. > > > > http://p.sf.net/sfu/windows-dev2dev > > _______________________________________________ > > Python-markdown-discuss mailing list > > Pyt...@li... > > https://lists.sourceforge.net/lists/listinfo/python-markdown-discuss > > > -- Best Regards, and Thank you, Hendra |