stitch.py 文件源码

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

项目:stitch 作者: pystitch 项目源码 文件源码
def convert(source: str, to: str, extra_args=(),
            output_file: str=None) -> None:
    """
    Convert a source document to an output file.

    Parameters
    ----------
    source : str
    to : str
    extra_args : iterable
    output_file : str

    Notes
    -----
    Either writes to ``output_file`` or prints to stdout.
    """
    output_name = (
        os.path.splitext(os.path.basename(output_file))[0]
        if output_file is not None
        else 'std_out'
    )

    standalone = '--standalone' in extra_args
    self_contained = '--self-contained' in extra_args
    stitcher = Stitch(name=output_name, to=to, standalone=standalone,
                      self_contained=self_contained)
    result = stitcher.stitch(source)
    result = json.dumps(result)
    newdoc = pypandoc.convert_text(result, to, format='json',
                                   extra_args=extra_args,
                                   outputfile=output_file)

    if output_file is None:
        print(newdoc)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号