<commit_before>import base64
import binascii
import re
import time

from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.markup.templatetags import markup
from django.core.urlresolvers import reverse
from django.template.loader import render_to_string
from jingo import register
from jinja2 import Markup

from Crypto.Cipher import AES

AES_PADDING = 16
AES_IV_LENGTH = 16


@register.filter
def restructuredtext(text):
    """Return text rendered as RestructuredText."""
    return Markup(markup.restructuredtext(text))


@register.filter
def markdown(text):
    """Return text rendered as Markdown."""
    return Markup(markup.markdown(text))


@register.filter
def get_display_name(obj):
    """Return obj display_name if obj is User. Otherwise return None."""
    if isinstance(obj, User):
        return obj.userprofile.display_name


@register.filter
def format_datetime(obj, type=None):
    """Return datetime obj formatted."""
    if type=='full':
        return obj.strftime('%d %B %Y %H:%M')
    return obj.strftime('%Y-%m-%d %H:%M')


@register.filter
def format_datetime_iso(obj):
    """Return datetime obj ISO formatted."""
    return obj.strftime('%Y-%m-%dT%H:%M:%S')


@register.filter
def format_datetime_unix(obj):
    """Return unix representation of obj."""<commit_msg>[fix bug 777667] Escape markdown enabled fields.<commit_after>import base64
import binascii
import re
import time

from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.markup.templatetags import markup
from django.core.urlresolvers import reverse
from django.template.loader import render_to_string
from jingo import register
from jinja2 import Markup

from Crypto.Cipher import AES

AES_PADDING = 16
AES_IV_LENGTH = 16


@register.filter
def markdown(text):
    """Return text rendered as Markdown."""
    return Markup(markup.markdown(text, 'safe'))


@register.filter
def get_display_name(obj):
    """Return obj display_name if obj is User. Otherwise return None."""
    if isinstance(obj, User):
        return obj.userprofile.display_name


@register.filter
def format_datetime(obj, type=None):
    """Return datetime obj formatted."""
    if type=='full':
        return obj.strftime('%d %B %Y %H:%M')
    return obj.strftime('%Y-%m-%d %H:%M')


@register.filter
def format_datetime_iso(obj):
    """Return datetime obj ISO formatted."""
    return obj.strftime('%Y-%m-%dT%H:%M:%S')


@register.filter
def format_datetime_unix(obj):
    """Return unix representation of obj."""
{'fraction_non_alphanumeric': 0.11440843420538852, 'fraction_numerical': 0.007809449433814916, 'mean_word_length': 4.643171806167401, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5860269', 'n_tokens_mistral': 822, 'n_tokens_neox': 768, 'n_words': 232}