我想知道是否可以使用 sphinx 在 python 中处理字符串。基本上,我想将包含重组文本的字符串传递给 sphinx,然后生成相应的 HTML 输出。我的意思是这样的
import sphinx.something
s = 'some restructured text'
html_out = sphinx.something(s)
但是,我找不到任何类似的内容。那么,这可能吗?如果可能,该怎么做?
最佳答案
我见过的最快的解决方案是:
from docutils.examples import html_body
def rst(rstStr):
return html_body(rstStr, input_encoding='utf-8',
output_encoding='utf-8').strip()
我对更好的解决方案感兴趣..
关于python - 使用sphinx处理字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9023861/