possumpalace_kit / _ext /

plugins for rendering that depend on docutils but not sphinx, for use in exporting drafts

import docutils.nodes
from docutils.parsers.rst import roles

class ManualCite(docutils.nodes.citation_reference):
    "Just a citation ref, really but subclassed so we can treat it differently"

def manualcite_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
    """Manual citations. In LaTeX they render to nothing much.
    I might do more sophisticated treatment in ReST when I have time.
    cribbed from

    Returns 2 part tuple containing list of nodes to insert into the
    document and a list of system messages.  Both are allowed to be

    :param name: The role name used in the document.
    :param rawtext: The entire markup snippet, with role.
    :param text: The text marked with the role.
    :param lineno: The line number where rawtext appears in the input.
    :param inliner: The inliner instance that called us.
    :param options: Directive options for customization.
    :param content: The directive content for customization.

    app =
    node = ManualCite(rawtext)
    return [node], []

def register_roles():
    roles.register_local_role('manualcite', manualcite_role)