python - 使用sphinx处理字符串

标签 python import python-sphinx

我想知道是否可以使用 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/

相关文章:

java - 哪种编写代码的方式更好?特定构造函数或导入

Python 共享属性父/子

python - 为什么我使用 scipy 将两个 CSR 矩阵相乘时会消耗这么多内存?

Magento 1.7 导入/导出挂起

python - 狮身人面像 : Linking a Lexer with a style sheet using pygments

python - 如何在 Sphinx 中为 Python 类/属性/常量/方法指定别名?

python - 在 sphinx 文档中嵌入 ipython notebook

python - 在 pandas 中按行搜索

Python C++ 包装器 : Convert multi-type struct to it's python representation (preferable dictionary)

Java:导入 RSyntaxTextArea 库?