Skip to content

Latest commit

 

History

History
146 lines (94 loc) · 4.82 KB

File metadata and controls

146 lines (94 loc) · 4.82 KB

[[Home]] ▸ API Reference

Index


renderdown

[[Home]] ▸ [[API Reference]] ▸ renderdown

Render Markdown from templates.

Classes and Functions

# renderdown.RenderDownError(?)

Error class for RenderDown-specific problems.

# renderdown.DocManager(top='Home', directories=None, multifile=True)

This class encapsulates the document formatting and management functions that are made available to all templates via the doc variable.

  • # DocManager.render(filename, page=None, *args, **kwargs)

    Render template given by filename.

    If page is None, the rendered string is returned, otherwise it is written to the buffer assigned to page.

  • # DocManager.write(text, page=None)

    Write text to the buffer of page; if page is None, write to the current page.

  • # DocManager.register_anchor(name=None, page=None)

    Find a unique, sanitized anchor for name using the name of name. If output is a single page, URIs are prepended with page. When page is None, the current page is used. The URI is registered to the id of name and then a tuple (uri, page) is returned. If the object has already been registered, the tuple for the original registration is returned and nothing else is done.

  • # DocManager.anchor(name=None, page=None)

    Return the anchor for the given name and page.

  • # DocManager.header(text, level=None)

    Return an ATX-style header at level level and header text text. If level is None, use the current level of page descent.

  • # DocManager.section()

    A context manager that increases the nesting level.

  • # DocManager.blockquote(text)

    Turn a block of text into a blockquote.

  • # DocManager.indent(text, columns=2)

    Indent a block of text by columns spaces.

  • # DocManager.listitem(text, body=None, bullet='*')

    Turn a block of text into a list-item.

# renderdown.md(text)

Basic filter for escaping text in Markdown.

# renderdown.preprocess_mako(text)

Mako template rendering treats line-initial /##+/ as comments that get ignored, but these are important for Markdown. Replace them with a substitution ${ s } where s is the hash sequence.

# renderdown.github_sanitize_id(x)

Sanitize an ID by near-GitHub standards (see toc_filter.rb in https://github.com/jch/html-pipeline):

  • remove punctuation besides hyphens and underscores
  • change spaces to hyphens
  • downcase Note that it doesn't:
  • add unique suffixes (-1, -2, etc.)

# renderdown.github_sanitize_filename(x)

Sanitize a filename by GitHub wiki conventions (see https://help.github.com/articles/adding-and-editing-wiki-pages-locally/#naming-wiki-files):

  • remove '/:*?"<>|'
  • change spaces to hyphens

# renderdown.sanitize_id(x)

Sanitize an ID similar to github_sanitize_id, but with the following differences:

  • no downcasing
  • dots (.) are replaced with hyphens (which helps Python module namespaces look better)

# renderdown.main(args)