我想从有关Python编程的Word文档中创建一个HTML站点。我使用链字文档-> [pandoc]-> rst文件-> [sphinx]-> html站点。除了python代码示例之外,其他所有操作都正常:所有选项卡都丢失了,所有代码行都保持对齐,这使代码易于理解。
我该怎么做才能解决此问题?与中间重组文本文件相比,我更喜欢对原始Word文档执行操作。
如何重现问题(需要单词,pandoc,狮身人面像,重组文本的知识):
a)构建一个带有python程序的word文档[example.docx]。 Python代码需要标签。例如:
Python代码示例:
{{ *password *}}
b)使用控制台,键入以下命令
# ----------------------------------
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]
c)键入以下命令:
pandoc -f docx -t rst -i example.docx - t example.rst
d)生成的html看起来像这样:
我们可以看到[affiche] 1函数的行都在左侧对齐。对于python代码,这是不正确的;