ms-word - 如何通过链 pandoc -> sphinx 将 Word 文档转换为 html 文件并保留文档代码示例的选项卡
问题描述
我想从一个关于 Python 编程的 Word 文档创建一个 HTML 站点。我使用链字文档 -> [pandoc] -> rst 文件 -> [sphinx] -> html 站点。一切正常,除了 python 代码示例:所有选项卡都丢失了,所有代码行都左对齐,这导致代码易于理解。
我能做些什么来解决这个问题?我更愿意对原始 word 文档进行操作,而不是对中间的 restructuredtext 文件进行操作。
如何重现问题(需要单词、pandoc、sphinx、restructuredtext 知识):
a) 构建一个包含 python 程序的 word 文档 [example.docx]。Python 代码需要标签。例如 :
Python代码示例:
# ----------------------------------
def affiche(chaine):
# affiche chaine
print("chaine=%s" % chaine)
# ----------------------------------
def afficheType(variable):
# affiche le type de variable
print("type[%s]=%s" % (variable, type(variable)))
# ----------------------------------
def f1(param):
# ajoute 10 à param
return param + 10
# ----------------------------------
def f2():
# rend 3 valeurs
return "un", 0, 100
# -------------------------------- programme principal ------------------------------------
# ceci est un commentaire
# variable utilisée sans avoir été déclarée
nom = "dupont"
# un affichage écran
print("nom=%s" % nom)
# une liste avec des éléments de type différent
liste = ["un", "deux", 3, 4]
b) 使用控制台,键入以下命令
pandoc -f docx -t rst -i example.docx - t example.rst
c) 键入以下命令:
sphinx-quickstart
make html
d) 生成的 html 如下所示:
我们可以看到 [affiche] 1函数的行都在左侧对齐。这对于 python 代码是不正确的;