当前位置: 首页>>代码示例>>Python>>正文


Python pypandoc.convert方法代码示例

本文整理汇总了Python中pypandoc.convert方法的典型用法代码示例。如果您正苦于以下问题:Python pypandoc.convert方法的具体用法?Python pypandoc.convert怎么用?Python pypandoc.convert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pypandoc的用法示例。


在下文中一共展示了pypandoc.convert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getLongDescription

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def getLongDescription():
    """Provides the long description"""
    try:
        import pypandoc
        converted = pypandoc.convert('README.md', 'rst').splitlines()
        no_travis = [line for line in converted if 'travis-ci.org' not in line]
        long_description = '\n'.join(no_travis)

        # Pypi index does not like this link
        long_description = long_description.replace('|Build Status|', '')
    except Exception as exc:
        print('pypandoc package is not installed: the markdown '
              'README.md convertion to rst failed: ' + str(exc), file=sys.stderr)
        # pandoc is not installed, fallback to using raw contents
        with io.open('README.md', encoding='utf-8') as f:
            long_description = f.read()

    return long_description 
开发者ID:SergeySatskiy,项目名称:codimension,代码行数:20,代码来源:setup.py

示例2: parse_description

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def parse_description(markdown=True):
    """
    Parse the description in the README file
    """
    if markdown: return parse_markdown()

    try:
        from pypandoc import convert

        readme_file = f'{PACKAGE_ROOT}/docs/index.rst'
        if not path.exists(readme_file):
            raise ImportError
        return convert(readme_file, 'rst')

    except ImportError:
        return parse_markdown() 
开发者ID:alpha-xone,项目名称:xbbg,代码行数:18,代码来源:setup.py

示例3: long_description

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def long_description():
    """Reads and returns the contents of the README.

    On failure, returns the project long description.

    Returns:
      The project's long description.
    """
    cwd = os.path.abspath(os.path.dirname(__file__))
    readme_path = os.path.join(cwd, 'README.md')
    if not os.path.exists(readme_path):
        return pylink.__long_description__

    try:
        import pypandoc
        return pypandoc.convert(readme_path, 'rst')
    except (IOError, ImportError):
        pass

    return open(readme_path, 'r').read() 
开发者ID:square,项目名称:pylink,代码行数:22,代码来源:setup.py

示例4: long_description

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def long_description(*paths):
    '''Returns a RST formated string.
    '''
    result = ''

    # attempt to import pandoc
    try:
        import pypandoc
    except (ImportError, OSError) as e:
        print("Unable to import pypandoc - %s" % e)
        return result

    # attempt md -> rst conversion
    try:
        for path in paths:
            result += '\n' + pypandoc.convert(
                path, 'rst', format='markdown'
            )
    except (OSError, IOError) as e:
        print("Failed to convert with pypandoc - %s" % e)
        return result

    return result 
开发者ID:ansible,项目名称:pytest-ansible,代码行数:25,代码来源:setup.py

示例5: convert_to_html

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def convert_to_html(filename):
    # Do the conversion with pandoc
    output = pypandoc.convert(filename, 'html')

    # Clean up with tidy...
    output, errors = tidy_document(output,  options={
        'numeric-entities': 1,
        'wrap': 80,
    })
    print(errors)

    # replace smart quotes.
    output = output.replace(u"\u2018", '‘').replace(u"\u2019", '’')
    output = output.replace(u"\u201c", "“").replace(u"\u201d", "”")

    # write the output
    filename, ext = os.path.splitext(filename)
    filename = "{0}.html".format(filename)
    with open(filename, 'w') as f:
        # Python 2 "fix". If this isn't a string, encode it.
        if type(output) is not str:
            output = output.encode('utf-8')
        f.write(output)

    print("Done! Output written to: {}\n".format(filename)) 
开发者ID:bradmontgomery,项目名称:word2html,代码行数:27,代码来源:main.py

示例6: read_md

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def read_md(f):
        return convert(f, 'rst') 
开发者ID:PacktPublishing,项目名称:Expert-Python-Programming_Second-Edition,代码行数:4,代码来源:setup.py

示例7: readme

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def readme():
    # I really prefer Markdown to reStructuredText.  PyPi does not.  This allows me
    # to have things how I'd like, but not throw complaints when people are trying
    # to install the package and they don't have pypandoc or the README in the
    # right place.
    # From https://coderwall.com/p/qawuyq/use-markdown-readme-s-in-python-modules
    try:
        import pypandoc
        long_description = pypandoc.convert('README.md', 'rst')
    except (IOError, ImportError):
        with open('README.md') as f:
            return f.read()
    else:
        return long_description 
开发者ID:HealthCatalyst,项目名称:healthcareai-py,代码行数:16,代码来源:setup.py

示例8: read_md

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def read_md(fpath):
        return convert(fpath, 'rst') 
开发者ID:hdidx,项目名称:hdidx,代码行数:4,代码来源:setup.py

示例9: get_readme

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def get_readme():
    try:
        import pypandoc
        readme_data = pypandoc.convert('README.md', 'rst')
    except(IOError, ImportError):
        readme_data = open('README.md').read()
    return readme_data 
开发者ID:calebmadrigal,项目名称:trackerjacker,代码行数:9,代码来源:setup.py

示例10: read_markdown

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def read_markdown(filename):
    path = os.path.join(os.path.dirname(__file__), filename)
    if not os.path.exists(path):
        if 'sdist' in sys.argv:
            print('WARNING: did not find %r' % filename, file=sys.stderro)
        return
    try:
        import pypandoc
    except ImportError:
        if 'sdist' in sys.argv:
            print('WARNING: Could not import pypandoc to convert README.md to RST!',
                  file=sys.stderr)
        return open(path).read()
    return pypandoc.convert(path, 'rst') 
开发者ID:wikilinks,项目名称:neleval,代码行数:16,代码来源:setup.py

示例11: readme

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def readme():
    with open('README.md') as f:
        content = f.read()
        try:
            # noinspection PyUnresolvedReferences
            from pypandoc import convert
            return convert(content, 'rst', 'md')
        except ImportError:
            print("warning: pypandoc module not found, could not convert Markdown to RST")
            return content 
开发者ID:ekeih,项目名称:OmNomNom,代码行数:12,代码来源:setup.py

示例12: desc_converter

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def desc_converter(desc):
    desc = pypandoc.convert(desc, to='rst', format='markdown')
    return re.sub(r'\[STRIKEOUT:(\:.*)\:``(.*)``\]', r'\1:`\2`', desc).rstrip().replace(r'"', "'") 
开发者ID:StatisKit,项目名称:AutoWIG,代码行数:5,代码来源:doxygen2sphinx.py

示例13: _read_long_description

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def _read_long_description():
    try:
        import pypandoc
        return pypandoc.convert('README.md', 'rst', format='markdown')
    except Exception:
        return None 
开发者ID:python-thumbnails,项目名称:python-thumbnails,代码行数:8,代码来源:setup.py

示例14: md2rst

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def md2rst(obj):
    if WITH_PANDOC:
        return pypandoc.convert(obj, to='rst', format='markdown')
    else:
        return obj.replace('```', '\n') 
开发者ID:Arello-Mobile,项目名称:swagger2rst,代码行数:7,代码来源:rst.py

示例15: convert_md

# 需要导入模块: import pypandoc [as 别名]
# 或者: from pypandoc import convert [as 别名]
def convert_md():
    with open(RST_README_PATH, 'wb') as readme:
        converted = convert(MD_README_PATH, 'rst')
        readme.write(converted.encode('utf-8')) 
开发者ID:swistakm,项目名称:pyimgui,代码行数:6,代码来源:convert_readme.py


注:本文中的pypandoc.convert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。