From: Waylan L. <wa...@gm...> - 2007-11-17 04:20:36
|
Some time ago I looked at bug 176338 [1] and lowered its priority significantly as the sample input was a far cry from markdown syntax. I recognized the need for a more graceful way to deal with the issue, but given the formatting of the text, it didn't seem all that important. Thing is, now I realize that the sample text attached to that ticket was skewing the issue. The bad syntax was just escalating the problem. The fact is, the current way `_process_section` works (it recursively calls itself on each block of remaining text), we can easily reach max recursion with perfectly good syntax. Therefore, I created a document the following way: import sys t = "" for i in range(sys.getrecursionlimit()): t += "Paragraph %d.\n\n" % i That's 1000 paragraphs one line each - as simple of markdown syntax as one could have. Even so: html = markdown.markdown(t) ... RuntimeError: maximum recursion depth exceeded I played with a few different numbers and 985 was the magic number. The maximum paragraphs a markdown document can have is 984. That's assuming no lists, blockquotes or anything else that necessarily goes deeper into recursion. While replacing recursion with a loop is probably easier said than done, do we care? In other words, are we ok limiting the possible length of documents we can process - with that limit becoming shorter the more complex the syntax used? If so, I'll just catch the exception and output a friendlier message. If not, we may have some work to do - although I'd suggest not holding up 1.7 for it. [1]: http://sourceforge.net/tracker/index.php?func=detail&aid=1763338&group_id=153041&atid=790198 -- ---- Waylan Limberg wa...@gm... |