<commit_before>"""
Set of "markup" template filters for Django.
These filters transform plain text
markup syntaxes to HTML; currently there is support for:

    * Textile, which requires the PyTextile library available at
      http://loopcore.com/python-textile/

    * Markdown, which requires the Python-markdown library from
      http://www.freewisdom.org/projects/python-markdown

    * reStructuredText, which requires docutils from http://docutils.sf.net/
"""

from django import template
from django.conf import settings
from django.utils.encoding import smart_str, force_text
from django.utils.safestring import mark_safe

register = template.Library()


@register.filter(is_safe=True)
def textile(value):
    """
    :type value: str

    :rtype: str
    """
    import textile

    return mark_safe(force_text(
        textile.textile(smart_str(value), encoding='utf-8', output='utf-8'))
    )


@register.filter(is_safe=True)
def markdown(value, args=''):
    """<commit_msg>Add CommonMark description to the templatetag header<commit_after>"""
Set of "markup" template filters for Django.
These filters transform plain text
markup syntaxes to HTML; currently there is support for:

    * Textile, which requires the PyTextile library available at
      http://loopcore.com/python-textile/

    * Markdown, which requires the Python-markdown library from
      http://www.freewisdom.org/projects/python-markdown

    * reStructuredText, which requires docutils from http://docutils.sf.net/

    * CommonMark, which requires CommonMark http://commonmark.org/
"""

from django import template
from django.conf import settings
from django.utils.encoding import smart_str, force_text
from django.utils.safestring import mark_safe

register = template.Library()


@register.filter(is_safe=True)
def textile(value):
    """
    :type value: str

    :rtype: str
    """
    import textile

    return mark_safe(force_text(
        textile.textile(smart_str(value), encoding='utf-8', output='utf-8'))
    )


@register.filter(is_safe=True)
def markdown(value, args=''):
    """
{'fraction_non_alphanumeric': 0.10321651464234277, 'fraction_numerical': 0.0019203072491598655, 'mean_word_length': 4.009615384615385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4611070', 'n_tokens_mistral': 623, 'n_tokens_neox': 598, 'n_words': 177}