django-markitup / markitup /

markup filters for django-markitup

Time-stamp: <2009-03-18 11:44:57 carljm>

This module provides a ``filter_func`` module-level markup filter
function based on the MARKITUP_PREVIEW_FILTER setting.

MARKITUP_PREVIEW_FILTER should be a two-tuple, where the first element
is a dotted-path string to a markup filter function, and the second
element is a dictionary of kwargs to be passed to the filter function
along with the markup to parse.

For instance, if MARKITUP_PREVIEW_FILTER is set to::

    ('markdown.markdown', {'safe_mode': True})

then calling ``filter_func(text)`` is equivalent to::

    from markdown import markdown
    markdown(text, safe_mode=True)

Though the implementation differs, the format of the
MARKITUP_PREVIEW_FILTER setting is inspired by James Bennett's

.. _django-template-utils:

from django.utils.functional import curry, wraps

from markitup.settings import MARKITUP_PREVIEW_FILTER

    filter_func = lambda text: text
    filter_path, filter_kwargs = MARKITUP_PREVIEW_FILTER
    module, funcname = filter_path.rsplit('.', 1)
    func = getattr(__import__(module, {}, {}, [funcname]), funcname)
    filter_func = wraps(func)(curry(func, **filter_kwargs))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.