google colab中的pandoc命令

问题描述 投票:0回答:1

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

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

但这不起作用。任何人都可以建议如何排序这个问题。

latex markdown jupyter pandoc google-colaboratory
1个回答
0
投票

只是通过语法,它应该是正确的降价格式,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

© www.soinside.com 2019 - 2024. All rights reserved.