Convert tracwiki markup to HTML


This script converts Trac wiki markup to HTML. This was originally posted by Erik Bray on

Assumes that trac is installed in site-packages folder, or that you added the path to your trac folder to sys.path.

Note: The script will not work if trac is not installed locally. If that is the case, in most cases easy_install trac will install it.

Bugs/Feature Requests

Existing bugs and feature requests for TracWikiToHtmlConverterScript are here.

If you have any issues, create a new ticket.


0 / 1


Download the zipped source from here.


You can check out the script from here using Subversion, or browse the source with Trac.


#!/usr/bin/env python
# found on trac google group:
# Originally posted by Erik Bray on

import sys
from trac.test import EnvironmentStub, Mock, MockPerm
from trac.mimeview import Context
from import HtmlFormatter
from trac.web.href import Href

env = EnvironmentStub()
req = Mock(href=Href('/'), abs_href=Href(''),
           authname='anonymous', perm=MockPerm(), args={})
context = Context.from_request(req, 'wiki')

wiki = '= Trac Wiki to HTML conversion demo ='

print HtmlFormatter(env, context, wiki).generate()

Recent Changes

4990 by coldpizza on 2008-12-09 10:52:59
tests for trac2html conversion
4988 by coldpizza on 2008-12-09 10:25:59
a variation which can read a file name from command line and outputs HTML to the console, attaches standard Trac CSS and adds HTML header/footer blocks
4986 by coldpizza on 2008-12-09 10:21:45
tracwiki to html conversion script


Author: coldpizza?
Maintainer: coldpizza?

Last modified 8 years ago Last modified on Nov 11, 2015, 10:43:46 AM