__main__.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:markdown_for_academia 作者: MarkdownForAcademia 项目源码 文件源码
def main(input_file, output='', to='', extra_args=None):
    """
    the main process
    :param input_file: the path of input mdac file
    :param output: the output file full path
    :param to: the output format of the file
    :param extra_args: a list of extra arguments provided to pandoc
    """
    if to:
        logging.warning('it is recommend to include command line arguments in'
                        'your mdac file meta')

        # get the file name if no file name is specified
        if not output:
            output = __get_output_filename__(input_file=input_file,
                                             config={},
                                             output_format=to)

        compile_function = __get_compile_function__(to)

        with open(input_file, 'r', encoding='utf-8') as f:
            input_content = f.read()

        pre_compile_res = pre_compile(input_content)

        compile_res = compile_function(pre_compile_res)

        pypandoc.convert_text(source=compile_res,
                              outputfile=output,
                              format='md',
                              to=to,
                              extra_args=extra_args)

    else:
        __compile_with_reg_data__(input_file)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号