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

from __future__ import absolute_import, unicode_literals, print_function

import markdown
import unittest

import os

from docdown.sequence import SequenceDiagramBlockPreprocessor

class IncludeExtensionTest(unittest.TestCase):
    # TODO: This test appears to be relying on behavior from another extension
    # due to the expected output vs what is really being output... nl2br probably
    # as well as maybe something to parse ``` and ```
    _root = os.path.dirname(os.path.abspath(__file__))
    ASSET_DIR = os.path.join(_root, 'test_files', 'assets')

    MARKDOWN_EXTENSIONS = ['docdown.include']

    EXTENSION_CONFIGS = {
        'docdown.include': {
            'asset_directory': ASSET_DIR,
            'root_directory': ASSET_DIR,
        }
    }

    def test_text_with_extension_default_config(self):
        text = ('Test File:\n' '+++ %s/test.md' % self.ASSET_DIR)

        html = markdown.markdown(
            text,
            extensions=self.MARKDOWN_EXTENSIONS,
            output_format='html5'
        )
        expected_output = ('<p>Test File:\n<div><pre><span></span>'
                           '# Test\n\nContent\n</pre>\n</div>')
        self.assertEqual(html, expected_output)

    def test_text_with_set_asset_dir(self):
        text = ('Test File:\n' '+++ test.md')

        html = markdown.markdown(
            text,
            extensions=self.MARKDOWN_EXTENSIONS,
            extension_configs=self.EXTENSION_CONFIGS,
            output_format='html5'
        )
        expected_output = ('<p>Test File:</p>\n<div class="codehilite"><pre><span></span>'
                           '# Test\n\nContent\n</pre>\n</div>')
        self.assertEqual(html, expected_output)

    def test_json(self):
        text = ('Test JSON:\n'<commit_msg>Passing include extension tests for the default text parsing<commit_after># -*- coding: utf-8 -*-

from __future__ import absolute_import, unicode_literals, print_function

import markdown
import unittest

import os

from docdown.sequence import SequenceDiagramBlockPreprocessor

class IncludeExtensionTest(unittest.TestCase):
    # TODO: This test appears to be relying on behavior from another extension
    # due to the expected output vs what is really being output... nl2br and fenced_code
    # The extension should probably check for them, or at least document that they are needed,
    # if they are expected to always be there.
    _root = os.path.dirname(os.path.abspath(__file__))
    ASSET_DIR = os.path.join(_root, 'test_files', 'assets')

    MARKDOWN_EXTENSIONS = [
        'markdown.extensions.fenced_code',
        'docdown.include']

    EXTENSION_CONFIGS = {
        'docdown.include': {
            'asset_directory': ASSET_DIR,
            'root_directory': ASSET_DIR,
        }
    }

    def test_text_with_extension_default_config(self):
        text = ('Test File:\n' '+++ %s/test.md' % self.ASSET_DIR)

        html = markdown.markdown(
            text,
            extensions=self.MARKDOWN_EXTENSIONS,
            output_format='html5'
        )

        # TODO: Expected output with code_block and nl2br and codehilite extensions
        # Are any of these truly expected to always be used with this extension?
        # expected_output = ('<p>Test File:</p>\n<div class="codehilite">'
        #                    '<pre><span></span># Test\n\nContent\n</pre>#</div>')
        expected_output = '<p>Test File:</p>\n<pre><code># Test\n\nContent\n</code></pre>'
        self.assertEqual(html, expected_output)

    def test_text_with_set_asset_dir(self):
        text = ('Test File:\n' '+++ test.md')

        html = markdown.markdown(
            text,
            extensions=self.MARKDOWN_EXTENSIONS,
            extension_configs=self.EXTENSION_CONFIGS,
            output_format='html5'
        )

        # TODO: Expected output with code_block and nl2br and codehilite extensions
        # Are any of these truly expected to always be used with this extension?
        # expected_output = ('<p>Test File:</p>\n<div class="codehilite"><pre><span></span>'
        #                    '# Test\n\nContent\n</pre>\n</div>')
        expected_output = '<p>Test File:</p>\n<pre><code># Test\n\nContent\n</code></pre>'
        self.assertEqual(html, expected_output)

    def test_json(self):
        text = ('Test JSON:\n'
{'fraction_non_alphanumeric': 0.11725562184488297, 'fraction_numerical': 0.002294630564479119, 'mean_word_length': 2.6446488294314383, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 46, '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': '5606499', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1296, 'n_words': 300}