You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(14) |
Aug
(5) |
Sep
|
Oct
|
Nov
|
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
(7) |
Apr
(6) |
May
(25) |
Jun
(11) |
Jul
|
Aug
(5) |
Sep
(5) |
Oct
(39) |
Nov
(28) |
Dec
(6) |
2008 |
Jan
(4) |
Feb
(39) |
Mar
(14) |
Apr
(12) |
May
(14) |
Jun
(20) |
Jul
(60) |
Aug
(69) |
Sep
(20) |
Oct
(56) |
Nov
(41) |
Dec
(29) |
2009 |
Jan
(27) |
Feb
(21) |
Mar
(37) |
Apr
(18) |
May
(2) |
Jun
(6) |
Jul
(6) |
Aug
(5) |
Sep
(2) |
Oct
(12) |
Nov
(2) |
Dec
|
2010 |
Jan
(12) |
Feb
(13) |
Mar
(10) |
Apr
|
May
(6) |
Jun
(5) |
Jul
(10) |
Aug
(7) |
Sep
(8) |
Oct
(7) |
Nov
(1) |
Dec
|
2011 |
Jan
|
Feb
|
Mar
(6) |
Apr
(5) |
May
(6) |
Jun
(15) |
Jul
(2) |
Aug
(6) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
(5) |
2012 |
Jan
(6) |
Feb
|
Mar
(2) |
Apr
(2) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(20) |
2013 |
Jan
|
Feb
|
Mar
(5) |
Apr
(1) |
May
(1) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(5) |
Oct
|
Nov
(2) |
Dec
|
2014 |
Jan
(10) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
(12) |
Sep
(9) |
Oct
(4) |
Nov
(8) |
Dec
(2) |
2015 |
Jan
(5) |
Feb
(5) |
Mar
(1) |
Apr
(1) |
May
(3) |
Jun
|
Jul
|
Aug
(9) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(2) |
Feb
(2) |
Mar
(9) |
Apr
(2) |
May
(6) |
Jun
|
Jul
|
Aug
(1) |
Sep
(7) |
Oct
(1) |
Nov
|
Dec
(1) |
2017 |
Jan
(9) |
Feb
|
Mar
(3) |
Apr
|
May
(14) |
Jun
|
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
(2) |
Dec
(5) |
2018 |
Jan
|
Feb
|
Mar
(3) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2019 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(1) |
Oct
(2) |
Nov
|
Dec
|
From: Waylan L. <wa...@gm...> - 2013-09-08 03:39:37
|
My first approach might be to use a treeprocessor, step through all `li` tags, and check for the appropriate string at the beginning of the li's text. If it exists, modify the `li` element as appropriate. The CodeHilite extension uses a similar approach to act on all `pre` elements, as does the HeaderID extension on h1-6 elements, and the Attribute List extension on the entire tree. The great thing about this approach it that it doesn't modify/reimplement Markdown's existing parsing and eliminates the need to mirror any updates/bug fixes to the basic syntax parsing. In fact, CodeHilite used to be a reimplementation (replacing the codeblock processor) which didn't work as good. Once I moved it to a treeprocessor, maintance got much easier. Another great thing about treeprocessors is that because all inlinePatterns are called from one of the builtin treeprocessors, you can have yours run either before or after inlinePatterns - giving you much more power to do exactly what you need without the extra baggage (like doing extra work to account for inline stuff you don't need). As I see it, preprocessors are great for a quick and dirty hack. But for a reliable, consistent long term solution, treeprocessors are where the real power in the API is. Just make sure you are comfortable working with ElementTree. ---- \X/ /-\ `/ |_ /-\ |\| Waylan Limberg On Sat, Sep 7, 2013 at 11:20 AM, Frederik Dohr <fd...@gm...> wrote: > Hi all, > > As mentioned elsewhere, I've created a checklists extension: > https://github.com/FND/markdown-checklist > > Right now that's just a simple preprocessor converting unordered lists > of a special type: > > * [ ] foo > * [ ] bar > > <ul> > <li><input type="checkbox" disabled> foo</li> > <li><input type="checkbox" disabled checked> bar</li> > </ul> > > However, I now want to add a class to such lists[1] - which renders my > preprocessor unsuitable. > > Since I'd rather avoid reinventing the wheel, I'd be grateful if someone > could point me to existing examples for customizing elements like that > (not in terms of markup, but extension code). > > > Thanks, > > Fred > > > [1] due to https://github.com/FND/markdown-checklist/issues/1 > > ------------------------------------------------------------------------------ > Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! > Discover the easy way to master current and previous Microsoft technologies > and advance your career. Get an incredible 1,500+ hours of step-by-step > tutorial videos with LearnDevNow. Subscribe today and save! > http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk > _______________________________________________ > Python-markdown-discuss mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-markdown-discuss |
From: Frederik D. <fd...@gm...> - 2013-09-07 15:20:33
|
Hi all, As mentioned elsewhere, I've created a checklists extension: https://github.com/FND/markdown-checklist Right now that's just a simple preprocessor converting unordered lists of a special type: * [ ] foo * [ ] bar <ul> <li><input type="checkbox" disabled> foo</li> <li><input type="checkbox" disabled checked> bar</li> </ul> However, I now want to add a class to such lists[1] - which renders my preprocessor unsuitable. Since I'd rather avoid reinventing the wheel, I'd be grateful if someone could point me to existing examples for customizing elements like that (not in terms of markup, but extension code). Thanks, Fred [1] due to https://github.com/FND/markdown-checklist/issues/1 |
From: Frederik D. <fd...@gm...> - 2013-09-05 05:59:41
|
> As you noted, #4 is discouraged and may go away in the near future. #3 > is reserved for extensions bundled with the markdown library only. So > that leaves you with #1 and/or #2. Thanks for the clarification, Waylan. I think I'll leave things as they are then. -- F. |
From: Waylan L. <wa...@gm...> - 2013-09-05 00:08:53
|
Fred, The answer is all explained in the [docs] under 'makeExtension'. The order of the options listed there is the prefered order: 1. import and pass an instance to Markdown 2. pass a string using dot notion 3. pass a name for extensions in the 'markdown.extensions' namespace 4. use mdx_* As you noted, #4 is discouraged and may go away in the near future. #3 is reserved for extensions bundled with the markdown library only. So that leaves you with #1 and/or #2. I would like to eliminate #2 as well, but then we cut off extension access on the command line. The point is, extension users should be told to import the extension and pass an instance to markdown -- with dot notation as a fallback. So when picking a name think about what works best in this line of Python: ```python from mymodule import MyExtClass ``` [docs]: http://pythonhosted.org/Markdown/extensions/api.html#makeextension ---- \X/ /-\ `/ |_ /-\ |\| Waylan Limberg On Wed, Sep 4, 2013 at 3:18 AM, Frederik Dohr <fd...@gm...> wrote: > Hi all, > > Recently I've written an extension for GitHub-style checklists: > https://github.com/FND/markdown-checklist > > I wasn't quite sure how best to name/package that extension though, > ultimately settling on "markdown_checklist.extension". > > A friendly contributor suggested to use "mdx_checklist" instead: > https://github.com/FND/markdown-checklist/pull/3 > I understand that method is outdated though? (See my comment there.) > > The source (`markdown:build_extension`) suggests that I should move my > extension into the `markdown.extensions` namespace. However, I'm not > convinced that's correct for third-party extensions, nor am I entirely > certain how best to do that (though I'm familiar with shared virtual > namespaces). Notably, the third-party extensions I looked at all seem to > use the "old-style" mdx_* scheme. > > Any guidance would be much appreciated! > > > Thanks, > > Fred > > ------------------------------------------------------------------------------ > Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! > Discover the easy way to master current and previous Microsoft technologies > and advance your career. Get an incredible 1,500+ hours of step-by-step > tutorial videos with LearnDevNow. Subscribe today and save! > http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk > _______________________________________________ > Python-markdown-discuss mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-markdown-discuss |
From: Frederik D. <fd...@gm...> - 2013-09-04 07:18:27
|
Hi all, Recently I've written an extension for GitHub-style checklists: https://github.com/FND/markdown-checklist I wasn't quite sure how best to name/package that extension though, ultimately settling on "markdown_checklist.extension". A friendly contributor suggested to use "mdx_checklist" instead: https://github.com/FND/markdown-checklist/pull/3 I understand that method is outdated though? (See my comment there.) The source (`markdown:build_extension`) suggests that I should move my extension into the `markdown.extensions` namespace. However, I'm not convinced that's correct for third-party extensions, nor am I entirely certain how best to do that (though I'm familiar with shared virtual namespaces). Notably, the third-party extensions I looked at all seem to use the "old-style" mdx_* scheme. Any guidance would be much appreciated! Thanks, Fred |
From: w. <wil...@fo...> - 2013-08-29 07:31:05
|
Thanks for your help. I took Dmitry Shachnev's advice and finally got what I wanted. import markdown from markdown.extensions.headerid import HeaderIdExtension def my_slugify(value, sep): return "100" md = markdown.Markdown(extensions=[HeaderIdExtension(configs=[('slugify', my_slugify)])]) print md.convert("#Head 1") which gives the correct output: <h1 id="100">Head 1</h1> |
From: Waylan L. <wa...@gm...> - 2013-08-29 00:51:39
|
Wilbur, As you need to pass in a reference to your slugify function, you can't use the sting based shortcut for passing in extension config settings (we would need to run the string through eval for that to work). Rather you need to use the [extension_configs] keyword which actually passes in a reference - not just a string. Of course, the extension_configs keyword is ugly to work with (it existed before I joined the project). As Dmitry points out, the best way is to create an instance of the extension with our custom settings and pass that instance in (no need for extension_configs). [extension_configs]: http://pythonhosted.org/Markdown/reference.html#extension_configs ---- \X/ /-\ `/ |_ /-\ |\| Waylan Limberg On Tue, Aug 27, 2013 at 9:07 AM, wilbur <wil...@fo...> wrote: > Hi, I tried to parse my markdown files with python-markdown's headerid > extension, with my custom slugify function: > > import markdown > > def my_slugify(value, sep): > return "100" > > md = markdown.Markdown(extensions=['headerid(slugify=my_slugify)']) > print md.convert("#Head 1") > > But I got this error: > > Traceback (most recent call last): > File "a.py", line 7, in <module> > print md.convert("#Head 1") > File "/usr/local/lib/python2.7/dist-packages/markdown/__init__.py", line > 296, in convert > newRoot = treeprocessor.run(root) > File > "/usr/local/lib/python2.7/dist-packages/markdown/extensions/headerid.py", > line 139, in run > id = slugify(''.join(itertext(elem)), sep) > TypeError: 'unicode' object is not callable > > I looked into headerid's source code. It seems that the headerid extension > just use the unicode object as a callable object: > > id = slugify(''.join(itertext(elem)), sep) > > So my question is how can I pass my custom slugify function to headerid? > Besides, my python version is 2.7.3 and python-markdown is 2.3.1. Thanks in > advance. > > > ------------------------------------------------------------------------------ > Introducing Performance Central, a new site from SourceForge and > AppDynamics. Performance Central is your source for news, insights, > analysis and resources for efficient Application Performance Management. > Visit us today! > http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk > _______________________________________________ > Python-markdown-discuss mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-markdown-discuss > |
From: Dmitry S. <mi...@gm...> - 2013-08-27 18:54:29
|
Try this: from markdown.extensions.headerid import HeaderIdExtension ... headerId = HeaderIdExtension([('slugify', my_slugify)]) md = markdown.Markdown(extensions=[headerId]) Initially I thought that extensions would accept dicts, but they seem to only support lists of tuples. On Tue, Aug 27, 2013 at 5:07 PM, wilbur <wil...@fo...> wrote: > Hi, I tried to parse my markdown files with python-markdown's headerid > extension, with my custom slugify function: > > import markdown > > def my_slugify(value, sep): > return "100" > > md = markdown.Markdown(extensions=['headerid(slugify=my_slugify)']) > print md.convert("#Head 1") > > But I got this error: > > Traceback (most recent call last): > File "a.py", line 7, in <module> > print md.convert("#Head 1") > File "/usr/local/lib/python2.7/dist-packages/markdown/__init__.py", line > 296, in convert > newRoot = treeprocessor.run(root) > File > "/usr/local/lib/python2.7/dist-packages/markdown/extensions/headerid.py", > line 139, in run > id = slugify(''.join(itertext(elem)), sep) > TypeError: 'unicode' object is not callable > > I looked into headerid's source code. It seems that the headerid extension > just use the unicode object as a callable object: > > id = slugify(''.join(itertext(elem)), sep) > > So my question is how can I pass my custom slugify function to headerid? > Besides, my python version is 2.7.3 and python-markdown is 2.3.1. Thanks in > advance. -- Dmitry Shachnev |
From: w. <wil...@fo...> - 2013-08-27 13:38:34
|
Hi, I tried to parse my markdown files with python-markdown's headerid extension, with my custom slugify function: import markdown def my_slugify(value, sep): return "100" md = markdown.Markdown(extensions=['headerid(slugify=my_slugify)']) print md.convert("#Head 1") But I got this error: Traceback (most recent call last): File "a.py", line 7, in <module> print md.convert("#Head 1") File "/usr/local/lib/python2.7/dist-packages/markdown/__init__.py", line 296, in convert newRoot = treeprocessor.run(root) File "/usr/local/lib/python2.7/dist-packages/markdown/extensions/headerid.py", line 139, in run id = slugify(''.join(itertext(elem)), sep) TypeError: 'unicode' object is not callable I looked into headerid's source code. It seems that the headerid extension just use the unicode object as a callable object: id = slugify(''.join(itertext(elem)), sep) So my question is how can I pass my custom slugify function to headerid? Besides, my python version is 2.7.3 and python-markdown is 2.3.1. Thanks in advance. |
From: Sepehr <sep...@gm...> - 2013-08-04 14:42:46
|
Based on *python markdown *I have written a tool to automatically generate HTML files from .md files (recursive), and upload them to your ftp server TODO list: - Adding normalizr.css to html pages - Adding theme capability - Enable more customizations Check it out ... https://bitbucket.org/sepul/pymdwiki/overview -- Sepehr |
From: Jay L. <lb...@re...> - 2013-07-25 09:38:40
|
*facepalm* Sorry, it's been so long since I had to write HTML I forgot how named anchors work. HeaderId is what I want. --jay On Wed, Jul 24, 2013 at 10:24 PM, Waylan Limberg <wa...@gm...> wrote: > Jay, > > The TOC Extension already has a config setting (anchorlink) which > defaults to off. According to the commit history, it has been there > since the extension was first added to Markdown. > > If you just want ids automatically assigned to headers, I would > suggest the HeaderId [1] Extension which does just that. In fact, the > TOC extension imports the id assignment functionality from the > HeaderId extension - but has no anchors. > > [1]: http://pythonhosted.org/Markdown/extensions/header_id.html > ---- > \X/ /-\ `/ |_ /-\ |\| > Waylan Limberg > > > On Wed, Jul 24, 2013 at 10:59 AM, Jay Luker <lb...@re...> wrote: >> Hi all, >> >> I'm wanting to use the TOC extension to generate anchor links for >> section headers to facilitate linking to sections of a document. (I'm >> not actually using the TOC itself yet, but I might eventually). I find >> the current behavior of wrapping the anchor tag around the header text >> odd, and I'm kind of scratching my head at who would want that. What >> is the use case for headers that link to themselves? >> >> Anyhow, I was going to propose maybe a new config option to control >> this. Happy to submit a pull request. >> >> Thanks, >> --jay >> >> ------------------------------------------------------------------------------ >> See everything from the browser to the database with AppDynamics >> Get end-to-end visibility with application monitoring from AppDynamics >> Isolate bottlenecks and diagnose root cause in seconds. >> Start your free trial of AppDynamics Pro today! >> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk >> _______________________________________________ >> Python-markdown-discuss mailing list >> Pyt...@li... >> https://lists.sourceforge.net/lists/listinfo/python-markdown-discuss |
From: Waylan L. <wa...@gm...> - 2013-07-25 02:24:49
|
Jay, The TOC Extension already has a config setting (anchorlink) which defaults to off. According to the commit history, it has been there since the extension was first added to Markdown. If you just want ids automatically assigned to headers, I would suggest the HeaderId [1] Extension which does just that. In fact, the TOC extension imports the id assignment functionality from the HeaderId extension - but has no anchors. [1]: http://pythonhosted.org/Markdown/extensions/header_id.html ---- \X/ /-\ `/ |_ /-\ |\| Waylan Limberg On Wed, Jul 24, 2013 at 10:59 AM, Jay Luker <lb...@re...> wrote: > Hi all, > > I'm wanting to use the TOC extension to generate anchor links for > section headers to facilitate linking to sections of a document. (I'm > not actually using the TOC itself yet, but I might eventually). I find > the current behavior of wrapping the anchor tag around the header text > odd, and I'm kind of scratching my head at who would want that. What > is the use case for headers that link to themselves? > > Anyhow, I was going to propose maybe a new config option to control > this. Happy to submit a pull request. > > Thanks, > --jay > > ------------------------------------------------------------------------------ > See everything from the browser to the database with AppDynamics > Get end-to-end visibility with application monitoring from AppDynamics > Isolate bottlenecks and diagnose root cause in seconds. > Start your free trial of AppDynamics Pro today! > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk > _______________________________________________ > Python-markdown-discuss mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-markdown-discuss |
From: Jay L. <lb...@re...> - 2013-07-24 14:59:59
|
Hi all, I'm wanting to use the TOC extension to generate anchor links for section headers to facilitate linking to sections of a document. (I'm not actually using the TOC itself yet, but I might eventually). I find the current behavior of wrapping the anchor tag around the header text odd, and I'm kind of scratching my head at who would want that. What is the use case for headers that link to themselves? Anyhow, I was going to propose maybe a new config option to control this. Happy to submit a pull request. Thanks, --jay |
From: Hendra <hen...@gm...> - 2013-06-24 00:47:33
|
Even when the extension is initialized like the one in this example? http://pythonhosted.org/Markdown/extensions/api.html#makeextension import markdown import myextension configs = {...} myext = myextension.MyExtension(configs=configs) md = markdown.Markdown(extensions=[myext]) In that snippet, `configs` is passed, but it seems possible to initialize MyExtension without any argument. On Sun, Jun 23, 2013 at 9:34 PM, Waylan Limberg <wa...@gm...> wrote: > Actually, the way the Markdown class calls extensions, None will never > be passed as a value for configs. Markdown always sets a default value > to pass in, so technically, your extension doesn't need to worry about > setting a default value. > > Otherwise you would be correct. `foo = dict(arg) or {}` would throw an > error if arg was None. > ---- > \X/ /-\ `/ |_ /-\ |\| > Waylan Limberg > > > On Sun, Jun 23, 2013 at 1:19 AM, Hendra <hen...@gm...> wrote: > > > > Ah, I see.. Pretty nasty gotcha.. > > But then, in that case, in the wikilinks example, shouldn't the > assignment > > be this way: > > > > if configs is None: > > configs = {} > > else: > > configs = dict(configs) > > > > Wouldn't dict(None) throw a TypeError as well? And since the constructor > of > > the WikiLinkExtension doesn't have default value for the `configs` > > parameter, does that mean it must always receive an argument? > > Or did I misunderstood the whole extension API itself? > > > > > > On Sun, Jun 23, 2013 at 12:34 PM, Waylan Limberg <wa...@gm...> > wrote: > >> > >> A dict is a mutable object, so you should never assign it as a default > >> to an argument. See this [1] for one of the many explanations out > >> there. > >> > >> We avoid the TypeError with a line like this inside a function/method: > >> > >> foo = arg or {} > >> > >> The above is shorthand for: > >> > >> if arg: # If arg is None this evaluates to false > >> foo = arg # only use arg when a value was passed in > >> else: > >> foo = {} # avoid a TypeError here > >> > >> Now the only way to get a TypeError is if the user passes in a bad > >> type -- unless that type would evaluate to false -- in which case the > >> default would be used. > >> > >> This is basic Python. Eventually you'll get it. In fact, I couldn't > >> remember what the reason was offhand. I knew it was wrong to assign a > >> dict as a default, but had to do a search to remember why. > >> > >> [1]: http://effbot.org/zone/default-values.htm > >> ---- > >> \X/ /-\ `/ |_ /-\ |\| > >> Waylan Limberg > >> > >> > >> On Sat, Jun 22, 2013 at 11:15 PM, Hendra <hen...@gm...> wrote: > >> > 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 > > > > > > > > > > -- > > Best Regards, and Thank you, > > Hendra > -- Best Regards, and Thank you, Hendra |
From: Waylan L. <wa...@gm...> - 2013-06-23 13:34:49
|
Actually, the way the Markdown class calls extensions, None will never be passed as a value for configs. Markdown always sets a default value to pass in, so technically, your extension doesn't need to worry about setting a default value. Otherwise you would be correct. `foo = dict(arg) or {}` would throw an error if arg was None. ---- \X/ /-\ `/ |_ /-\ |\| Waylan Limberg On Sun, Jun 23, 2013 at 1:19 AM, Hendra <hen...@gm...> wrote: > > Ah, I see.. Pretty nasty gotcha.. > But then, in that case, in the wikilinks example, shouldn't the assignment > be this way: > > if configs is None: > configs = {} > else: > configs = dict(configs) > > Wouldn't dict(None) throw a TypeError as well? And since the constructor of > the WikiLinkExtension doesn't have default value for the `configs` > parameter, does that mean it must always receive an argument? > Or did I misunderstood the whole extension API itself? > > > On Sun, Jun 23, 2013 at 12:34 PM, Waylan Limberg <wa...@gm...> wrote: >> >> A dict is a mutable object, so you should never assign it as a default >> to an argument. See this [1] for one of the many explanations out >> there. >> >> We avoid the TypeError with a line like this inside a function/method: >> >> foo = arg or {} >> >> The above is shorthand for: >> >> if arg: # If arg is None this evaluates to false >> foo = arg # only use arg when a value was passed in >> else: >> foo = {} # avoid a TypeError here >> >> Now the only way to get a TypeError is if the user passes in a bad >> type -- unless that type would evaluate to false -- in which case the >> default would be used. >> >> This is basic Python. Eventually you'll get it. In fact, I couldn't >> remember what the reason was offhand. I knew it was wrong to assign a >> dict as a default, but had to do a search to remember why. >> >> [1]: http://effbot.org/zone/default-values.htm >> ---- >> \X/ /-\ `/ |_ /-\ |\| >> Waylan Limberg >> >> >> On Sat, Jun 22, 2013 at 11:15 PM, Hendra <hen...@gm...> wrote: >> > 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 > > > > > -- > Best Regards, and Thank you, > Hendra |
From: Hendra <hen...@gm...> - 2013-06-23 05:19:55
|
Ah, I see.. Pretty nasty gotcha.. But then, in that case, in the wikilinks example, shouldn't the assignment be this way: if configs is None: configs = {} else: configs = dict(configs) Wouldn't dict(None) throw a TypeError as well? And since the constructor of the WikiLinkExtension doesn't have default value for the `configs` parameter, does that mean it must always receive an argument? Or did I misunderstood the whole extension API itself? On Sun, Jun 23, 2013 at 12:34 PM, Waylan Limberg <wa...@gm...> wrote: > A dict is a mutable object, so you should never assign it as a default > to an argument. See this [1] for one of the many explanations out > there. > > We avoid the TypeError with a line like this inside a function/method: > > foo = arg or {} > > The above is shorthand for: > > if arg: # If arg is None this evaluates to false > foo = arg # only use arg when a value was passed in > else: > foo = {} # avoid a TypeError here > > Now the only way to get a TypeError is if the user passes in a bad > type -- unless that type would evaluate to false -- in which case the > default would be used. > > This is basic Python. Eventually you'll get it. In fact, I couldn't > remember what the reason was offhand. I knew it was wrong to assign a > dict as a default, but had to do a search to remember why. > > [1]: http://effbot.org/zone/default-values.htm > ---- > \X/ /-\ `/ |_ /-\ |\| > Waylan Limberg > > > On Sat, Jun 22, 2013 at 11:15 PM, Hendra <hen...@gm...> wrote: > > 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 > -- Best Regards, and Thank you, Hendra |
From: Waylan L. <wa...@gm...> - 2013-06-23 04:34:41
|
A dict is a mutable object, so you should never assign it as a default to an argument. See this [1] for one of the many explanations out there. We avoid the TypeError with a line like this inside a function/method: foo = arg or {} The above is shorthand for: if arg: # If arg is None this evaluates to false foo = arg # only use arg when a value was passed in else: foo = {} # avoid a TypeError here Now the only way to get a TypeError is if the user passes in a bad type -- unless that type would evaluate to false -- in which case the default would be used. This is basic Python. Eventually you'll get it. In fact, I couldn't remember what the reason was offhand. I knew it was wrong to assign a dict as a default, but had to do a search to remember why. [1]: http://effbot.org/zone/default-values.htm ---- \X/ /-\ `/ |_ /-\ |\| Waylan Limberg On Sat, Jun 22, 2013 at 11:15 PM, Hendra <hen...@gm...> wrote: > 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 |
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 |
From: Waylan L. <wa...@gm...> - 2013-06-22 14:29:41
|
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 > |
From: Hendra <hen...@gm...> - 2013-06-22 13:27:18
|
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? P.S. I am very sorry if this ended up as a double post, I wasn't sure if the mail was sent correctly the first time round. -- Best Regards, and Thank you, Hendra |
From: Christophe G. <chr...@gm...> - 2013-06-22 13:11:51
|
On Sat, Jun 22, 2013 at 3:03 PM, Hendra <hen...@gm...> wrote: > 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() ). Hi, guessing is not enough! Are you sure it is a list? Sorry to give Python basics: Lists have no .items(), and dicts' items are returned as a list, you can check with >>> [].items() and >>> {}.items(). Have a try using `type` to check the type accurately. chri |
From: Hendra <hen...@gm...> - 2013-06-22 13:03:40
|
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 |
From: Waylan L. <wa...@gm...> - 2013-05-02 00:55:56
|
Jake, As explained in the API docs [1], every processor is set to run in a certain order. If you insert your preprocessor before all others, then it is being run first. Without seeing your code, it is hard to know for sure, but my guess it that perhaps your preprocessor is inserting the code block as raw html (in <pre><code> tags). If so, then your code blocks are being treated as raw html and stored in the htmlStash until they are swapped back in by a postprocessor. In other words, they never see treeprocessors and therefore never get exposed to codehilite. Instead, you preprocessor should be inserting the code block using markdown formatting (indented at least four spaces). Then markdown will process the code block as usual. I hope that helps. Waylan [1]: http://pythonhosted.org/Markdown/extensions/api.html#integrating_into_markdown On Tue, Apr 30, 2013 at 10:21 AM, Jake Vanderplas <ja...@gm...> wrote: > Hello, > I'm trying to write an extension that will allow literal includes of files > in markdown, and do syntax highlighting if they contain code. > > I managed to get a preprocessor working which takes a suitably-annotated > filename, and replaces it with markdown which should then be interpreted by > the codehilite extension. I was surprised, though, when I found that the > output of my preprocessor is never processed by codehilite. It seems that > codehilite is modifying the text *before* my preprocessor modifies it: is > this the case? Is there any way to make sure a new extension preprocesses > the document before sending the result to another extension? > > Thanks for any help, > Jake > > ------------------------------------------------------------------------------ > Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET > Get 100% visibility into your production application - at no cost. > Code-level diagnostics for performance bottlenecks with <2% overhead > Download for free and get started troubleshooting in minutes. > http://p.sf.net/sfu/appdyn_d2d_ap1 > _______________________________________________ > Python-markdown-discuss mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-markdown-discuss > -- ---- \X/ /-\ `/ |_ /-\ |\| Waylan Limberg |
From: Jake V. <ja...@gm...> - 2013-04-30 14:21:17
|
Hello, I'm trying to write an extension that will allow literal includes of files in markdown, and do syntax highlighting if they contain code. I managed to get a preprocessor working which takes a suitably-annotated filename, and replaces it with markdown which should then be interpreted by the codehilite extension. I was surprised, though, when I found that the output of my preprocessor is never processed by codehilite. It seems that codehilite is modifying the text *before* my preprocessor modifies it: is this the case? Is there any way to make sure a new extension preprocesses the document before sending the result to another extension? Thanks for any help, Jake |
From: Ivan M. <ph...@gm...> - 2013-03-24 12:49:54
|
OK, I understand how this is out of scope for the project. I'll look into your suggestions. Thanks guys, Ivan On Sun, Mar 24, 2013 at 2:48 AM, Waylan Limberg <wa...@gm...> wrote: > Ivan, > > This is way out of scope for Markdown. That said, I don't see why an > extension wouldn't be able to do something like that. I don't really > recommend this approach, but I suppose an inline pattern would do the > trick. > > Another approach, and one I know some have used successfully, is to > pass the markdown text through a template system first (like Jinja) - > which replaces the variables - then pass it through the markdown > parser. Or maybe they passed it through markdown first, then the > template system. I'm sure one or the other could work depending upon > the needs of the specific project. Personally, this would be my > approach - rather than an extension to markdown. > > > On Sat, Mar 23, 2013 at 6:34 PM, Ivan Mirić <ph...@gm...> wrote: > > Hi, > > > > Is there a chance of adding the ability to access Python variables from > > Markdown? > > > > As seen here (https://github.com/ipython/ipython/issues/2958), the > `{{}}` > > syntax would be great. > > > > If this is not in the pipeline as a built-in Python-Markdown feature, how > > difficult would it be to write an extension for it? If someone points me > in > > the right direction, I might attempt it myself. > > > > Thanks, > > > > Ivan > > > > > ------------------------------------------------------------------------------ > > Everyone hates slow websites. So do we. > > Make your web apps faster with AppDynamics > > Download AppDynamics Lite for free today: > > http://p.sf.net/sfu/appdyn_d2d_mar > > _______________________________________________ > > Python-markdown-discuss mailing list > > Pyt...@li... > > https://lists.sourceforge.net/lists/listinfo/python-markdown-discuss > > > > > > -- > ---- > \X/ /-\ `/ |_ /-\ |\| > Waylan Limberg > |