From: Yuri T. <qar...@gm...> - 2008-10-13 08:43:05
|
I made a whole bunch of changes to the code, most of them just a matter of refactoring, but some affect the functionality too. In terms of refactoring, the biggest change is splitting Markdown class into three and making most of their methods private. I think this will make it easier to understand the code: you can now study one class at a time. Two of those three classes are still a little messy, but at least the messiness is contained. So, we now have: 1. MarkdownParser - parses pre-processed Markdown source into an ElementTree. Usage: tree = MarkdownParser.parseDocument(markdown_string) The only other exposed methods are parseChunk() and detectTabbed(). I am tempted to hide them as well, but at the moment they are needed by some extensions. 2. InlineProcessor - runs inline patterns on an ElementTree Usage: InlineProcessor(patterns).applyInlinePatterns(tree) This is the only exposed method. I also folded into this the InlineStash class. 3. Markdown - puts it all together. Usage: Markdown(extensions).convert(markdown_string) Markdown(extensions).convertFile(input_file_path, output_path_or_stream, encoding) markdownFromFile() function still exists, but only has two lines now. Another change, which does affects functionality, is that I incorporated Ben's treap implementation as a way of organizing pre-processors, patterns, etc. This kills two birds: we now have a better way of organizing those things, and this should also fix the problem reported by Eric Abrahamsen last week, which required a major change anyway. This breaks many extensions, and also breaks one non-extension test. But 2.0 is about as good of a chance as we will get for breaking backwards compatibility. I updated the footnotes extension as an example of how to use the new system. - yuri -- http://sputnik.freewisdom.org/ |