<commit_before>import markdown

from django import template
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe

register = template.Library()

@register.filter(is_safe=True)
@stringfilter
def markdown_safe(value):
    extensions = ["nl2br", "urlize",]

    return mark_safe(markdown.markdown(value,
                                       extensions,
                                       safe_mode=True,
                                       enable_attributes=False))

@register.filter(is_safe=False)
@stringfilter
def markdown_unsafe(value):
    extensions = ["nl2br", "urlize",]

    return markdown.markdown(value,
                            extensions,
                            safe_mode=False,
                            enable_attributes=False)


<commit_msg>Use fenced_code and codehilite to make code work properly in markdown.<commit_after>import markdown

from django import template
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe

register = template.Library()

@register.filter(is_safe=True)
@stringfilter
def markdown_safe(value):
    extensions = ["nl2br", "urlize", "fenced_code", "codehilite",]

    return mark_safe(markdown.markdown(value,
                                       extensions,
                                       safe_mode=True,
                                       enable_attributes=False))

@register.filter(is_safe=False)
@stringfilter
def markdown_unsafe(value):
    extensions = ["nl2br", "urlize", "fenced_code", "codehilite",]

    return markdown.markdown(value,
                            extensions,
                            safe_mode=False,
                            enable_attributes=False)



{'fraction_non_alphanumeric': 0.08120386144236229, 'fraction_numerical': 0.002271436683702442, 'mean_word_length': 2.0912280701754384, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5195850', 'n_tokens_mistral': 464, 'n_tokens_neox': 442, 'n_words': 94}