Preferably without opening any environments, databases and such.
--
Jani Tiainen
Not easily. At the very least you need to make a fake Request object that
the href setup correctly so links can be rendered. Macros may require the
env object, so if you set it to None, some things may break.
--Noah
It would be nice if this were somehow easier. Not sure how though.
Here's a simple little script I was using for this purpose:
#!/usr/bin/env python
import sys
from trac.test import EnvironmentStub, Mock, MockPerm
from trac.mimeview import Context
from trac.wiki.formatter import HtmlFormatter
from trac.web.href import Href
env = EnvironmentStub()
req = Mock(href=Href('/'), abs_href=Href('http://www.example.com/'),
authname='anonymous', perm=MockPerm(), args={})
context = Context.from_request(req, 'wiki')
print HtmlFormatter(env, context, sys.stdin.read()).generate()
Of course, if you want actual web pages you'll have to add the
appropriate HTML headers and footers. And as Noah said, some wiki
macros may not work with this.
Erik
Well I was trying to make wiki preview for offline editor. You could
download wiki page(s)) to your computer and edit them as you wish, take
a preview before pushing changes back to Trac.
It would nice to have simpler way to render at least core markup, and
leave macros unrendered...
--
Jani Tiainen
It would be pretty easy to subclass Formatter, and just replace the
method that handles macro rendering with a noop. In that case the code
Erik gave should work fine for most cases. There are also custom syntax
providers to worry about, which you can't as easily disable last I
looked. I would have to stare at the code again to see where those hook in.
--Noah