def display_mediawiki(request, path, text): article = simpleparse(text) try: # Try to figure out a title by looking up svn properties caption = client.propget("svnweb:mediawiki:title", path).values()[0] except: caption = None if caption is None: # No explicit name, so we'll derive it from the filename caption = path.rpartition("/")[2] if "." in caption: caption = caption.rpartition(".")[0] article.caption = caption writer = MWXHTMLWriter() writer.xwriteStyle = mediawiki_xwriteStyle writer.xwriteArticleLink = mediawiki_xwriteArticleLink element = writer.write(article) result = ElementTree.tostring(element) result = """ <html><head><title>%s</title> <style type="text/css"> body {font-size: 13px; font-family: sans-serif; padding: 30px; background-color: #f9f9f9} .content {border: 1px solid #aaa; padding: 10px; padding-top: 0px; background-color: white} .content div[class~="mwx.paragraph"] {margin-bottom: 12px} .content > div > h1 {font-size: 24px; width: 100%%; border-bottom: 1px solid #aaa; margin-bottom: 12px; margin-top: 8px} .content > div > div > h2 {font-size: 19px; width: 100%%; border-bottom: 1px solid #aaa; margin-bottom: 8px} .content > div > div > div > h2 {font-size: 17px; margin-bottom: 7px; margin-top: 18px} .content > div > div > div > div > h2 {font-size: 15px; margin-bottom: 4px} .content > div > div > div > div > div > h2 {font-size: 13px; margin-bottom: 4px} span[class~="mwx.svnweb.bold"] {font-weight: bold} span[class~="mwx.svnweb.italic"] {font-style: italic} </style> </head><body> <div class="content"> """ % caption + result + """ </div></body></html> """ return "text/html", result