當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。