From: Yuri T. <qar...@gm...> - 2008-12-04 19:43:08
|
I tried running python markdown the recently released py3k and after two commits it only requires 2to3 and one manual fix. The recommended method for maintaining a library that should work as both 2.x and 3.x is to maintain it in 2.x and rely on automatic conversion with 2to3 with no further manual changes. So, we should think of how to fix up our code so that it works with 2.x and then converts into 3.0-compliant code when we run 2to3. Get the newest version from git, then run 2to3: 2to3 -w markdown 2to3 -w markdown.py 2to3 -w test-markdown.py After that you need to make one change manually, in markdown/inlinepatterns.py: -import htmlentitydefs +from html import entities as htmlentitydefs After that, the script seems to work for all test cases except "para-with-hr". The test-markdown.py itself is broken in 3.0, though, when it comes to saving the results to a file. As a quick fix, you can disable this: test-markdown.py: - htmlDiffFile.write(diffsBuffer.decode("utf8")) + #htmlDiffFile.write(diffsBuffer.decode("utf8")) Some of the extensions fail too, though those problems might actually be in test-markdown.py Let's not worry about the extensions working with 3.0 for our 2.0 release, though. I'll try to fix up the test script, though it perhaps would be ok to have a different version of it for 3.0. I am not planning on committing the output of 2to3 to avoid confusion. At least for now, anyone who wants to use markdown with python 3.0 should get the latest version from git and run 2to3 on it themselves. - yuri -- http://sputnik.freewisdom.org/ |