<commit_before># coding: utf-8
from __future__ import unicode_literals
from django import template
import markdown

register = template.Library()

extensions = ['markdown.extensions.extra', 
              'markdown.extensions.codehilite',
              'markdown.extensions.toc',
              'mdx_math',
             ]

extension_configs = {
    'CodeHilite' : {
        'linenums' : True,
        'use_pygments': True,
    },
}
md = markdown.Markdown(extensions, extension_configs)

@register.filter(is_safe=True)
def emarkdown(text):
    """Parse the given markdown text in html."""
    return md.convert(text)<commit_msg>Compatibilité du markdown avec python2<commit_after># coding: utf-8
from __future__ import unicode_literals
from django import template
import markdown
import sys

register = template.Library()

extensions = ['markdown.extensions.extra', 
              'markdown.extensions.codehilite',
              'markdown.extensions.toc',
              'mdx_math',
             ]

extension_configs = {
    'CodeHilite' : {
        'linenums' : True,
        'use_pygments': True,
    },
}
md = markdown.Markdown(extensions, extension_configs)

@register.filter(is_safe=True)
def emarkdown(text):
    """Parse the given markdown text in html."""
    if sys.version_info[0] < 3:
      return md.convert(text)
    else:
      return md.convert(text.decode("utf8"))
{'fraction_non_alphanumeric': 0.11328976034858387, 'fraction_numerical': 0.004357298474945534, 'mean_word_length': 3.0174927113702625, 'pattern_counts': {'":': 0, '<': 4, '<?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': '5265393', 'n_tokens_mistral': 429, 'n_tokens_neox': 414, 'n_words': 93}