Last change
on this file since 8 was
4,
checked in by simon, 19 years ago
|
Initial import of Trac XML wiki processor (or a quickly hacked Docbook
processor).
|
File size:
592 bytes
|
Rev | Line | |
---|
[4] | 1 | import trac.util |
---|
| 2 | import libxml2, libxslt |
---|
| 3 | |
---|
| 4 | def execute(hdf, text, env): |
---|
| 5 | stylesheet = env.get_config('docbook', 'stylesheet') |
---|
| 6 | if not stylesheet: |
---|
| 7 | raise trac.util.TracError('DocBook stylesheet not configured.') |
---|
| 8 | else: |
---|
| 9 | style = libxslt.parseStylesheetDoc(libxml2.parseFile(stylesheet)) |
---|
| 10 | doc = libxml2.parseDoc(text) |
---|
| 11 | result = style.applyStylesheet(doc, None) |
---|
| 12 | html = style.saveResultToString(result) |
---|
| 13 | style.freeStylesheet() |
---|
| 14 | doc.freeDoc() |
---|
| 15 | result.freeDoc() |
---|
| 16 | return html[html.find('<body>')+6:html.find('</body>')].strip() |
---|
Note: See
TracBrowser
for help on using the repository browser.