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 / View on Github external
def convert_rst_to_md(text):
    return pypandoc.convert_text(text, "md", format="rst")
github bebraw / pypandoc / 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 / 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 / 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(
                pypandoc.convert_text(c['body'], 'md', format='html').rstrip()
            ) for c in comments),
github RPing / input-paste / View on Github external
def read_description(filename):
    with, encoding='utf-8') as f:
            import pypandoc
            return pypandoc.convert_text(, format='md', to='rst')
        except ImportError:
github mlund / faunus / scripts / View on Github external

    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 ='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: