Python markdown转epub (格式间转换)

import pypandoc


def readme():
    """
    转化文件的格式。
    convert(source, to, format=None, extra_args=(), encoding='utf-8', outputfile=None, filters=None)
    parameter-
        source:源文件
        to:目标文件的格式,比如html、rst、md等
        format:源文件的格式,比如html、rst、md等。默认为None,则会自动检测
        encoding:指定编码集
        outputfile:目标文件,比如test.html(注意outputfile的后缀要和to一致)
    """
    return pypandoc.convert_file(source_file='./keep pure, keep smile/springcloud(六):配置中心git示例 - 纯洁的微笑 - 博客园.md',
                                 to='epub3',
                          format='md', extra_args=['--base-header-level=2'],outputfile='1.epub')


readme()

# 查看格式
# print(pypandoc.get_pandoc_formats()[1])

发布了139 篇原创文章 · 获赞 24 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/mbh12333/article/details/103721636