如何通过链 pandoc -> sphinx 将 Word 文档转换为 html 文件并保留文档代码示例的选项卡
How to convert a Word document into an html file through the chain pandoc -> sphinx and keeping the tabs of the document's code examples
我想从有关 Python 编程的 Word 文档创建一个 HTML 站点。我用链词文档->[pandoc]->第一个文件->[sphinx]->html站点。除了 python 代码示例外,一切正常:所有选项卡都丢失了,所有代码行都左对齐,这导致代码易于理解。
我该怎么做才能解决这个问题?比起中间的重组文本文件,我更愿意对原始 word 文档进行操作。
如何重现问题(需要 word、pandoc、sphinx、restructuredtext 知识):
a) 构建一个 word 文档 [example.docx],其中包含一个 python 程序。 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 代码不正确;
对于那些感兴趣的人,我找到了一个解决方案:我给了代码,样式 [Source Code] 现在 html 看起来像这样:
我想从有关 Python 编程的 Word 文档创建一个 HTML 站点。我用链词文档->[pandoc]->第一个文件->[sphinx]->html站点。除了 python 代码示例外,一切正常:所有选项卡都丢失了,所有代码行都左对齐,这导致代码易于理解。
我该怎么做才能解决这个问题?比起中间的重组文本文件,我更愿意对原始 word 文档进行操作。
如何重现问题(需要 word、pandoc、sphinx、restructuredtext 知识):
a) 构建一个 word 文档 [example.docx],其中包含一个 python 程序。 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 代码不正确;
对于那些感兴趣的人,我找到了一个解决方案:我给了代码,样式 [Source Code] 现在 html 看起来像这样: