How to use the pypandoc.convert_text 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 pytest-dev / pytest / scripts / publish-gh-release-notes.py View on Github external
def convert_rst_to_md(text):
    return pypandoc.convert_text(text, "md", format="rst")
github bebraw / pypandoc / tests.py View on Github external
def test_converts_valid_format(self):
        self.assertEqualExceptForNewlineEnd(pypandoc.convert_text("ok", format='md', to='rest'), 'ok')
github novoid / lazyblorg / lib / htmlizer.py View on Github external
def convert_org_to_html5(self, orgmode):
        """Converts an arbitrary Org mode syntax element (a string) to its
        corresponding HTML5 representation.

        @param orgmode: Org mode text
        @param return: HTML5 representation of Org mode text
        """

        assert(isinstance(orgmode, str))
        self.stats_external_org_to_html5_conversion += 1
        return pypandoc.convert_text(orgmode, 'html5', format='org')
github ralphbean / bugwarrior / bugwarrior / services / activecollab.py View on Github external
def annotations(self, issue, issue_obj):
        if 'type' not in issue:
            # Subtask
            return []
        comments = self._comments(issue)
        if comments is None:
            return []

        return self.build_annotations(
            ((
                c['user'],
                pypandoc.convert_text(c['body'], 'md', format='html').rstrip()
            ) for c in comments),
            issue_obj.get_processed_url(issue_obj.record['permalink']),
        )
github RPing / input-paste / setup.py View on Github external
def read_description(filename):
    with codecs.open(filename, encoding='utf-8') as f:
        try:
            import pypandoc
            return pypandoc.convert_text(f.read(), format='md', to='rst')
        except ImportError:
            return f.read()
github mlund / faunus / scripts / extracttips.py View on Github external
print(md)

    if find_tables:
        # find all tables
        for table in soup.findAll("table"):
            if table.findParent("table") is None:

                # remove long LaTeX strings
                for i in table.findAll('span', class_="math inline"):
                    if len(i.string)>max_math_length:
                        i.string = "(hidden math)" # we could also delete w. `i.decompose`

                # tag = text in upper left corner of table
                tag = table.thead.tr.findAll('th')[0].string
                if tag!=None:
                    md = pypandoc.convert_text(table, 'plain', format='html')
                    md = re.sub(r'\n+', '\n', md) # remove double newline
                    tables[tag] = md

        # store dictionary as JSON file 
        out = json.dumps(tables, indent=2)
        with open('tips.json', 'w') as f:
            f.write(out)