<commit_before><?php
require_once dirname(__FILE__) . '/../HTML_To_Markdown.php';

class HTML_To_MarkdownTest extends PHPUnit_Framework_TestCase
{
    private function html_gives_markdown($html, $expected_markdown)
    {
        $markdown = new HTML_To_Markdown($html);
        $this->assertEquals($expected_markdown, $markdown->__toString());
    }

    public function test_plain_text()
    {
        $this->html_gives_markdown("test", "test");
        $this->html_gives_markdown("<p>test</p>", "test");
    }

    public function test_line_breaks()
    {
        $this->html_gives_markdown("test\nanother line", "test another line");
        $this->html_gives_markdown("<p>test\nanother line</p>", "test another line");
        $this->html_gives_markdown("<p>test<br>another line</p>", "test  \nanother line");
    }

    public function test_headers()
    {
        $this->html_gives_markdown("<h1>Test</h1>", "Test\n====");
        $this->html_gives_markdown("<h2>Test</h2>", "Test\n----");
        $this->html_gives_markdown("<h3>Test</h3>", "### Test");
        $this->html_gives_markdown("<h4>Test</h4>", "#### Test");
        $this->html_gives_markdown("<h5>Test</h5>", "##### Test");
        $this->html_gives_markdown("<h6>Test</h6>", "###### Test");
    }

    public function test_spans()
    {
        $this->html_gives_markdown("<em>Test</em>", "*Test*");
        $this->html_gives_markdown("<i>Test</i>", "*Test*");
        $this->html_gives_markdown("<strong>Test</strong>", "**Test**");
        $this->html_gives_markdown("<b>Test</b>", "**Test**");
        $this->html_gives_markdown("<span>Test</span>", "<span>Test</span>");
    }

    public function test_image()
    {
        $this->html_gives_markdown('<img src="/path/img.jpg" alt="alt text" title="Title" />', '![alt text](/path/img.jpg "Title")');
    }

    public function test_anchor()
    {
        $this->html_gives_markdown('<a href="http://modernnerd.net" title="Title">Modern Nerd</a>', '[Modern Nerd](http://modernnerd.net "Title")');
    }
<commit_msg>Add failing test for collapsing space between anchors<commit_after><?php
require_once dirname(__FILE__) . '/../HTML_To_Markdown.php';

class HTML_To_MarkdownTest extends PHPUnit_Framework_TestCase
{
    private function html_gives_markdown($html, $expected_markdown)
    {
        $markdown = new HTML_To_Markdown($html);
        $this->assertEquals($expected_markdown, $markdown->__toString());
    }

    public function test_plain_text()
    {
        $this->html_gives_markdown("test", "test");
        $this->html_gives_markdown("<p>test</p>", "test");
    }

    public function test_line_breaks()
    {
        $this->html_gives_markdown("test\nanother line", "test another line");
        $this->html_gives_markdown("<p>test\nanother line</p>", "test another line");
        $this->html_gives_markdown("<p>test<br>another line</p>", "test  \nanother line");
    }

    public function test_headers()
    {
        $this->html_gives_markdown("<h1>Test</h1>", "Test\n====");
        $this->html_gives_markdown("<h2>Test</h2>", "Test\n----");
        $this->html_gives_markdown("<h3>Test</h3>", "### Test");
        $this->html_gives_markdown("<h4>Test</h4>", "#### Test");
        $this->html_gives_markdown("<h5>Test</h5>", "##### Test");
        $this->html_gives_markdown("<h6>Test</h6>", "###### Test");
    }

    public function test_spans()
    {
        $this->html_gives_markdown("<em>Test</em>", "*Test*");
        $this->html_gives_markdown("<i>Test</i>", "*Test*");
        $this->html_gives_markdown("<strong>Test</strong>", "**Test**");
        $this->html_gives_markdown("<b>Test</b>", "**Test**");
        $this->html_gives_markdown("<span>Test</span>", "<span>Test</span>");
    }

    public function test_image()
    {
        $this->html_gives_markdown('<img src="/path/img.jpg" alt="alt text" title="Title" />', '![alt text](/path/img.jpg "Title")');
    }

    public function test_anchor()
    {
        $this->html_gives_markdown('<a href="http://modernnerd.net" title="Title">Modern Nerd</a>', '[Modern Nerd](http://modernnerd.net "Title")');
        $this->html_gives_markdown('<a href="http://modernnerd.net" title="Title">Modern Nerd</a> <a href="http://modernnerd.net" title="Title">Modern Nerd</a>', '[Modern Nerd](http://modernnerd.net "Title") [Modern Nerd](http://modernnerd.net "Title")');
    }

{'fraction_non_alphanumeric': 0.21275137111517367, 'fraction_numerical': 0.005484460694698354, 'mean_word_length': 3.8471760797342194, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 116, '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': '903009', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1448, 'n_words': 203}