Kevin Altis mentioned using reST for a Wiki. There might be others of you considering it, also, so here're some instructions on how to steal my code and use it in your own Python based reST Wiki projects. Try My CodeMy code is for a private Wiki tool running under PyDS. If you want to give it a shot, grab the latest CVS snapshot of PyDS and WikiTool. Examine My CodeInstalling all the predicates for PyDS can be a pain, so if you'd rather just look at the transform that resolves stray links versus other pages, you can examine StructuredText.py and WikiTool.py directly. Adapt My CodeIn StructuredText.py, HTMLFragmentTranslator gets you HTML fragments rather than whole documents. If you'd rather get the whole thing, discard the translator and HTMLFragmentWriter and just use docutils.writers.html4css1.Writer as your writer in renderText. StrayLinkResolver uses TargetVisitor to visit targets, then fixes any strays. You'll want to throw out findTools, and then change resolveStrayLink so that it returns the appropriate URI for a given stray. It should actually return a tuple: (cssclass, uri), where the CSS class can be used to adapt the appearance of the link depending on where it came from (cached link from another article, title of another article, InterWiki link, etc). The SubstitutionTransform lets you maintain a database of substitutions to use across all your documents. Throw away __init__, rename fakeResolver to just resolver, and hack transform to call self.resolver instead of resolver. Finally, Reader pulls all these transforms together as a customised docutils reader, and renderText renders text to a document. Latin1StringIO is a hack to work around the rest of PyDS' inability to handle Unicode, so you'll want to hack renderText to use docutils.io.StringIO instead. last change 2003-05-27 14:39:28 |
Garth is testing PyDS rather more extensively than at first he thought he would. |
© 2004, Garth T Kidd