def test_hoep(self):
     import hoep as m
     extensions = (m.EXT_NO_INTRA_EMPHASIS | m.EXT_FENCED_CODE
                   | m.EXT_AUTOLINK | m.EXT_TABLES | m.EXT_STRIKETHROUGH
                   | m.EXT_FOOTNOTES)
     md = m.Hoep(extensions=extensions)
     md.render(self.hoep_text)
Пример #2
0
    def setUp(self):
        self._path = op.join(op.dirname(__file__), 'res')

        self.md = h.Hoep().render
Пример #3
0
    def _ensureInitialized(self):
        if self._formatter is not None:
            return

        # Don't show warnings once for each worker when baking, so only
        # show them for the first. If the variable is not set, we're not
        # baking so do show them either way.
        show_warnings = (self.app.config.get('baker/worker_id', 0) == 0)

        config = self.app.config.get('markdown')
        if config is None:
            config = {}
        elif not isinstance(config, dict):
            raise Exception("The `markdown` configuration setting must be "
                            "a dictionary.")

        extensions = config.get('extensions')
        if extensions is None:
            extensions = []
        if isinstance(extensions, str):
            extensions = [e.strip() for e in extensions.split(',')]
        # Compatibility with PieCrust 1.x
        if config.get('use_markdown_extra'):
            extensions.append('extra')

        render_flags = config.get('render_flags')
        if render_flags is None:
            render_flags = []

        # Translate standard Markdown formatter extensions to Hoedown
        # extension/render flags to make it easier to use Hoep as a drop-in
        # replacement.
        exts = 0
        rdrf = 0
        for n in extensions:
            # Try an extension?
            e = getattr(hoep, 'EXT_' + n.upper(), None)
            if e is not None:
                exts |= e
                continue

            # Try a render flag?
            f = getattr(hoep, 'HTML_' + n.upper(), None)
            if f is not None:
                rdrf |= f

            # Try translating from a Markdown extension name.
            t = ext_translate.get(n)
            if t is None:
                if show_warnings:
                    logger.warning("Unknown Hoep Markdown extension or flag: "
                                   "%s" % n)
                continue
            if not isinstance(t, list):
                t = [t]
            for i in t:
                if i.startswith('EXT_'):
                    exts |= getattr(hoep, i)
                elif i.startswith('HTML_'):
                    rdrf |= getattr(hoep, i)
                elif show_warnings:
                    logger.warning("Unknown Hoep Markdown extension or flag:"
                                   "%s" % n)
            if n == 'extra' and show_warnings:
                # Special warning for the 'extra' extension.
                logger.warning(
                    "The 'extra' extension doesn't have a full equivalent "
                    "in Hoedown Markdown. Only 'fenced_code', 'footnotes' and "
                    "'tables' extensions will be active. "
                    "To remove this warning, replace 'extra' with those 3 "
                    "specific extensions.")

        # Enable a few things by default.
        exts |= hoep.EXT_NO_INTRA_EMPHASIS

        # Create the formatter.
        self._formatter = hoep.Hoep(exts, rdrf)
Пример #4
0
 def setUp(self):
     self.md = h.Hoep(render_flags=h.HTML_SMARTYPANTS).render