Google colab中的pandoc命令

时间:2018-09-16 01:48:14

标签: latex markdown jupyter pandoc google-colaboratory

我是降价新手。我想用python代码编写一个报告,我想添加标题,作者和日期。我尝试使用此代码

---
title: My Title
author: My author
---

但这不起作用。谁能建议解决这个问题的方法。

1 个答案:

答案 0 :(得分:0)

仅就语法而言,它应该是正确的markdown格式,并且pandoc应该能够格式化它。尝试使用以下代码:

import pypandoc

mytext = """
---
title: My Title
author: My author
--- """

pypandoc.convert_text(mytext,'pdf',format='markdown',
                               outputfile="output.pdf",
                               extra_args=['--pdf-engine','pdflatex'])

它应为您提供类似于以下内容的output.pdf:

enter image description here