Skip to main content

Hoep

Hoep is a Python binding for the Hoedown Markdown library.

Install

Hoep is available on PyPI so installation is only a quick pip away.

$ pip install hoep

Unicode

Hoep only accepts and returns unicode objects in Python 2 and str objects in Python 3. This goes for custom renderers as well. All callbacks receive and must return unicode or str objects, respective to the Python version.

Basic Usage

Using Hoep is pretty straightforward. You can either use the render module function or the Hoep module class. The latter is more efficient if you are rendering multiple documents in a single go.

# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import hoep as h


extensions = h.EXT_STRIKETHROUGH
render_flags = h.HTML_SMARTYPANTS


# Method form.
html = h.render('Some ~~bold~~ __"strong"__ text.', extensions, render_flags)


# Class form.
md = h.Hoep(extensions, render_flags)

html = md.render('Some ~~bold~~ __"strong"__ text.')

Extensions

You can enable multiple extensions by bitwise ORing them.

  • EXT_AUTOLINK: Automatically parse URLs into links.

  • EXT_DISABLE_INDENTED_CODE: Disables indented code blocks.

  • EXT_FENCED_CODE: Enables fenced code blocks.

  • EXT_FOOTNOTES: Enables Markdown Extra style footnotes.

  • EXT_HIGHLIGHT: Enables ==marking== text.

  • EXT_LAX_SPACING: Removes the need for an empty line between Markdown and raw HTML.

  • EXT_NO_INTRA_EMPHASIS: Disables emphasis_between_words.

  • EXT_QUOTE: “Quotes” are translated into <q> tags.

  • EXT_SPACE_HEADERS: ATX style headers require a space after the opening number sign(s).

  • EXT_STRIKETHROUGH: Enables ~~striking~~ text.

  • EXT_SUPERSCRIPT: Enables super^script.

  • EXT_TABLES: Enables Markdown Extra style tables.

  • EXT_UNDERLINE: Translates <em> tags into <u> tags.

Render flags

You can enable multiple render flags by bitwise ORing them.

  • HTML_ESCAPE: All HTML is escaped.

  • HTML_EXPAND_TABS: Tabs are expanded to spaces.

  • HTML_HARD_WRAP: Line breaks are translated into <br> tags.

  • HTML_SAFELINK: Only links to safe protocols are allowed.

  • HTML_SKIP_HTML: All HTML tags are stripped.

  • HTML_SKIP_IMAGES: Images are ignored.

  • HTML_SKIP_LINKS: Links are ignored.

  • HTML_SKIP_STYLE: <style> tags are stripped.

  • HTML_SMARTYPANTS: Enables SmartyPants.

  • HTML_TOC: Anchors are added to headers.

  • HTML_USE_XHTML: Renders XHTML instead of HTML.

Custom renderer

By subclassing the Hoep class, you can create a custom renderer overriding various callbacks.

# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import hoep as h


class MyRenderer(h.Hoep):
    def __init__(self, extensions = 0, render_flags = 0):
        # If you override the `__init__` function, you must call
        # the parent class's or bad things will happen.
        super(MyRenderer, self).__init__(extensions, render_flags)

        self.replace = '[redacted]'


    def strikethrough(self, text):
        return self.replace


md = MyRenderer(h.EXT_STRIKETHROUGH)

html = md.render('Some ~~bold~~ __"strong"__ text.')

Callbacks

Document level

  • preprocess(str markdown)

  • doc_header()

  • doc_footer()

  • postprocess(str html)

Block level

  • block_code(str text, str language)

  • block_html(str text)

  • block_quote(str text)

  • footnotes(str text)

  • footnote_def(str text, int number)

  • header(str text, int level)

  • hrule()

  • list(str text, bool ordered)

  • list_item(str text, bool ordered)

  • paragraph(str text)

  • table(str header, str body)

  • table_row(str text)

  • table_cell(str text, int flags)

Span level

  • autolink(str link, bool is_email)

  • codespan(str text)

  • double_emphasis(str text)

  • emphasis(str text)

  • footnote_ref(int number)

  • highlight(str text)

  • image(str link, mixed title, str alt)

  • line_break()

  • link(str link, mixed title, str content)

  • quote(str text)

  • raw_html_tag(str tag)

  • strikethrough(str text)

  • superscript(str text)

  • triple_emphasis(str text)

  • underline(str text)

Low-level

  • entity(str entity)

  • normal_text(str text)

Support

If you run into any issues or have any questions, either open an issue or hop in #mynt on irc.freenode.net.

Metadata

Release files for hoep 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hoep 1.0.2
File Size Uploaded Provenance Actions
hoep-1.0.2.tar.gz 94.8 kB Without provenance Details for hoep-1.0.2.tar.gz

Release files / hoep-1.0.2.tar.gz

Download URL hoep-1.0.2.tar.gz
Size 94.8 kB
Tags Source
SHA-256 checksum
How to use checksums
712d6f890138e4f785bcfa8147f7e8eac802ae5543f533edbd810c5beabf7c7a
BLAKE2b-256 checksum
How to use checksums
f5effcfd4f9fba12d89bcef8bf4ce51ae7c628a7f25c95fe35443473d39beb94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for hoep 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page