<commit_before># -*- coding: utf-8 -*-

from jinja2.utils import Markup
from pprint import pformat
import sys
import types


def global_node(node_value):
    """
    Used for the inclusion of a node in a template.
    It just marks the node value `node_value` as safe.
    """
    return Markup(node_value)

def global_dump(value):
    """
    Dump `value` for debugging.
    """
    return Markup('<pre>' + pformat(value, 1, 2, 4) + '</pre>')


# save references to the defined functions
functions = {}
current_module = sys.modules[__name__]
for x in dir(current_module):
    x = current_module.__dict__.get(x)

    if isinstance(x, types.FunctionType) \
        and x.__name__.startswith('global_'):
        fn = x.__name__[len('global_'):]
        functions[fn] = x<commit_msg>Add some indent options in the node Jinja macro.<commit_after># -*- coding: utf-8 -*-

from jinja2 import Environment
from jinja2.utils import Markup
from pprint import pformat
import sys
import types


env = Environment()


def global_node(node_value, indent=0, indent_first=False):
    """
    Used for the inclusion of a node in a template by indenting and flagging
    the HTML string as safe.
    """
    spaces = indent * 4
    tmpl = env.from_string(('{{ node_value | indent(%d, %s) }}' % (spaces, indent_first)))
    return Markup(tmpl.render(node_value=node_value))

def global_dump(value):
    """
    Dump `value` for debugging.
    """
    return Markup('<pre>' + pformat(value, 1, 2, 4) + '</pre>')


# save references to the defined functions
functions = {}
current_module = sys.modules[__name__]
for x in dir(current_module):
    x = current_module.__dict__.get(x)

    if isinstance(x, types.FunctionType) \
        and x.__name__.startswith('global_'):
        fn = x.__name__[len('global_'):]
        functions[fn] = x
{'fraction_non_alphanumeric': 0.1261013215859031, 'fraction_numerical': 0.007158590308370044, 'mean_word_length': 3.4101941747572817, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5912818', 'n_tokens_mistral': 592, 'n_tokens_neox': 571, 'n_words': 175}