v923z
v923z

Reputation: 1247

Process string using sphinx

I was wondering whether it is possible to process a string in python, using sphinx. Basically, I would like to pass a string containing restructured text to sphinx, and then generate the corresponding HTML output. I meant something like this

import sphinx.something
s = 'some restructured text'
html_out = sphinx.something(s)

However, I could not find anything along these lines. So, is this possible, and if so, how would one do this?

Upvotes: 2

Views: 306

Answers (1)

Bud P. Bruegger
Bud P. Bruegger

Reputation: 1091

The quickest solution I've seen is:

from docutils.examples import html_body

def rst(rstStr):
return html_body(rstStr, input_encoding='utf-8', 
                 output_encoding='utf-8').strip()

I'd be interested myself in better solutions..

Upvotes: 2

Related Questions