How to use the pypandoc.convert function in pypandoc

To help you get started, we’ve selected a few pypandoc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hammerlab / seltest / setup.py View on Github external
from setuptools import setup, find_packages

try:
   import pypandoc
   description = pypandoc.convert('README.md', to='rst', format='md')
except (IOError, ImportError):
   description = ''


setup(name='seltest',
      version='1.0.1',
      description='A perceptual difference testing framework for writing the easiest, most comprehensive tests you can run.',
      long_description=description,
      author='Isaac Hodes',
      author_email='isaachodes@gmail.com',
      url='https://github.com/ihodes/seltest/',
      packages=['seltest'],
      include_package_data=True,
      install_requires=['selenium',
                        'docopt',
                        'Pillow',
github aliyun / aliyun-log-python-sdk / doc / source / conf.py View on Github external
def convert_file(src_file, target_folder='.'):
    file_name = os.path.basename(src_file)
    new_file_name = os.path.splitext(file_name)[0] + '.rst'
    new_file_path = os.path.sep.join([target_folder, new_file_name])

    print("**** convert: " + src_file + " to " + new_file_path)
    if six.PY3:
        open(new_file_path, "w").write(pypandoc.convert(src_file, 'rst'))
    else:
        open(new_file_path, "w").write(pypandoc.convert(src_file, 'rst').encode('utf8'))
github MorganZhang100 / line-counter / setup.py View on Github external
    read_md = lambda f: convert(f, 'rst')
except ImportError:
github coppeliaMLA / glasseye / glasseye / __main__.py View on Github external
tufte_template = "templates/tufteTemplate.html"

    #Copy across directories to the user location
    if user_path != glasseye_path:
        css_path = user_path + "css"
        if os.path.exists(css_path):
            sh.rmtree(css_path)
        sh.copytree(glasseye_path + "css", css_path)

        js_path = user_path + "js"
        if os.path.exists(js_path):
            sh.rmtree(js_path)
        sh.copytree(glasseye_path + "js", js_path)

    #Convert markdown to html using pandoc
    py.convert(user_path+input_file, 'html', outputfile = user_path + "pandocHTML.html", extra_args=['--mathjax'])

    #Read in the html and soupify it
    read_html= open(user_path + pandoc_html,'r').read()
    soup = BeautifulSoup(read_html, 'html.parser')

    #Make the changes for the Tufte format
    for a in soup.findAll('marginnote'):
        p = soup.new_tag("p")
        a.replaceWith(p)
        p.insert(0, a)
        a.name = "span"
        a['class'] = "marginnote"

    for a in enumerate(soup.findAll('sidenote')):
        a[1].name = "span"
        a[1]['class'] = "marginnote"
github tbenthompson / anti_forgetful / setup.py View on Github external
from setuptools import setup

version = open('VERSION').read()

try:
    import pypandoc
    description = pypandoc.convert('README.md', 'rst')
except (IOError, ImportError):
    description = open('README.md').read()

setup(
    packages = ['anti_forgetful'],

    install_requires = ['boto3'],
    zip_safe = False,
    entry_points = {
        'console_scripts': [
            'anti_forgetful = anti_forgetful.launch:main',
            'awsterminate = anti_forgetful.terminate:main'
        ]
    },

    name = 'anti_forgetful',
github ibm-watson-iot / iot-python / setup.py View on Github external
def read_md(f):
        return convert(f, 'rst')
except:
github gt3389b / python-cson / setup.py View on Github external
def read_readme(fname):
   try:
      import pypandoc
      return pypandoc.convert('README.md','rst')
   except (IOError, ImportError):
      return ''
github kgritesh / pip-save / setup.py View on Github external
def get_readme():
    """Get the contents of the ``README.rst`` file as a Unicode string."""
    try:
        import pypandoc
        description = pypandoc.convert('README.md', 'rst')
    except (IOError, ImportError):
        description = open('README.md').read()

    return description
github msabramo / setuptools-markdown / setuptools_markdown.py View on Github external
def long_description_markdown_filename(dist, attr, value):
    logger.debug(
        'long_description_markdown_filename: '
        'dist = %r; attr = %r; value = %r',
        dist, attr, value)
    frame = _get_code_object()
    setup_py_path = inspect.getsourcefile(frame)
    markdown_filename = os.path.join(os.path.dirname(setup_py_path), value)
    logger.debug('markdown_filename = %r', markdown_filename)
    try:
        output = pypandoc.convert(markdown_filename, 'rst')
    except OSError:
        output = open(markdown_filename).read()
    lines = output.strip().splitlines()
    while len(lines) >= 2 and (not lines[1] or lines[1].isspace()):
        del lines[1]
    
    output = '\n'.join(lines)
    dist.metadata.long_description = output
github kdavies4 / ModelicaRes / 00-update-readme.py View on Github external
#!/usr/bin/python
"""Update the ReST README from the Markdown README.

Note that some manual manipulation is necessary afterwards.
"""

import pypandoc

readme = pypandoc.convert('README.md', 'rst')
f = open('README.txt', 'w')
f.write(readme)
f.close()