Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(3)  |  Call(2)  |  Derive(0)  |  Import(1)
Runs Markdown over a given value, optionally using various extensions
python-markdown supports.

Syntax::

    {{ value|markdown:"extension1_name,extension2_name..." }}

To enable safe mode, which strips raw HTML and only returns HTML
generated by actual Markdown syntax, pass "safe" as the first extension in
the list.

        @register.filter(is_safe=True)
def markdown(value, arg=''):
    """
    Runs Markdown over a given value, optionally using various extensions
    python-markdown supports.

    Syntax::

        {{ value|markdown:"extension1_name,extension2_name..." }}

    To enable safe mode, which strips raw HTML and only returns HTML
    generated by actual Markdown syntax, pass "safe" as the first extension in
    the list.

    """
    try:
        import markdown
    except ImportError:
        if settings.DEBUG:
            raise template.TemplateSyntaxError(
                "Error in 'markdown' filter: "
                "The Python markdown library isn't installed.")
    else:
        # Markdwon.version was firrst added in 1.6b. The only version of markdown
        # To fully support extensions befoer 1.6b was the shortlived 1.6a.
        if hasattr(markdown, 'version'):
            extensions = [e for e in arg.split(",") if e]
            if len(extensions) > 0 and extensions[0] == "safe":
                extensions = extensions[1:]
                safe_mode = True
            else:
                safe_mode = False
            python_markdown_deprication = (
                "The use of Python-Markdown < 2.1 in Django is deprecated; "
                "please update to the current version")
            # Unicode support only in markdown v1.7 or above. Version_info
            # exist only in markdown v1.6.2rc-2 or above.
            markdown_vers = getattr(markdown, "version_info", None)
            if markdown_vers < (1,7):
                warnings.warn(python_markdown_deprication, DepricationWarning)
                return mark_safe(force_unicode(markdown.markdown(smart_str(value), extensions, safe_mode=safe_mode)))
            else:
                if markdown_vers >= (2,1):
                    if safe_mode:
                        return mark_safe(markdown.markdown(force_unicode(value),
                            extensions, safe_mode=safe_mode, enable_attributes=False))
                    else:
                        return mark_safe(markdown.markdown(force_unicode(value), extensions, safe_mode=safe_mode))
                else:
                    warnings.warn(python_markdown_deprication, DepricationWarning)
                    return mark_safe(markdown)
        else:
            warnings.warn(python_markdown_deprication, DepricationWarning)
            return mark_safe(force_unicode(markdown.markdown(smart_str(value))))
        


src/d/e/denigma-HEAD/denigma/apps/data/views.py   denigma(Download)
from tables import EntryTable
from filters import TableFilter, EntryFilterSet, FilterForm
from templatetags.rendering import markdown
 
@login_required
    def node(entry):
        """Helper function to construct a node object."""
        if entry.pk not in memo:
            memo.append(entry.pk)
            data['nodes'].append({'id': str(entry.pk), 'label': entry.title, 'text': recross(hyper(markdown(entry.text))),
        node(fr)
        node(to)
        data['edges'].append({'id': "%sto%s" % (fr.pk, to.pk), 'label': be.title, 'text': markdown(be.text),
                              'source': str(fr.pk), 'target': str(to.pk), 'directed': True,
                              'links': '<a href="%s">View</a> | <a href="%s">Update</a>' %