On Thu, Jun 19, 2008 at 5:07 PM, Noah Kantrowitz <[EMAIL PROTECTED]> wrote:
>
>> -----Original Message-----
>> From: [email protected] [mailto:[EMAIL PROTECTED] On
>> Behalf Of Jani Tiainen
>> Sent: Thursday, June 19, 2008 2:02 PM
>> To: [email protected]
>> Subject: [Trac-dev] Producing HTML from Trac from python
>>
>>
>> How I can make HTML from Trac wiki markup?
>>
>> Preferably without opening any environments, databases and such.
>
> 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.
>

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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/trac-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to