<commit_before><?php

/* This file is part of the Markdownify project, which is under LGPL license */

namespace Test\Markdownify;

use Markdownify\Converter;

require_once(__DIR__ . '/../../../vendor/autoload.php');

class ConverterTestCase extends \PHPUnit_Framework_TestCase
{


    /* ATTRIBUTES
     *************************************************************************/
    protected $converter;
   

    /* HEADING TEST METHODS
     *************************************************************************/
    /**
     * @dataProvider providerHeadingConversion
     */
    public function testHeadingConversion_withAttribute($level, $attributesHTML, $attributesMD = null)
    {
        $innerHTML = 'Heading '.$level;
        if (empty($attributesHTML)) {
            $md = str_pad('', $level, '#').' '.$innerHTML;
        } else {
            $md = '<h'.$level.$attributesHTML.'>'."\n"
                .'  '.$innerHTML."\n"
                .'</h'.$level.'>';
        }
        $html = '<h'.$level.$attributesHTML.'>'.$innerHTML.'</h'.$level.'>';
        $this->assertEquals($md, $this->converter->parseString($html));
    }

    public function providerHeadingConversion()
    {
        $attributes = array(' id="idAttribute"', ' class=" class1  class2 "');
        $data = array();
        for ($i=1; $i<=6; $i++) {
            $data[] = array($i, '');
            $data[] = array($i, $attributes[0]);
            $data[] = array($i, $attributes[1]);
            $data[] = array($i, $attributes[0].$attributes[1]);
        } 
        return $data;
    }

    /**
     * @dataProvider providerHeadingConversionEscape
     */
    public function testHeadingConversionEscape($html, $md)
    {
        $this->assertEquals($md, $this->converter->parseString($html));
    }

    public function providerHeadingConversionEscape()
    {
        $data = array();
        $data['level1']['html'] = '# Heading 1';
        $data['level1']['md'] = '\# Heading 1';
        $data['level2']['html'] = '## Heading 2';
        $data['level2']['md'] = '\## Heading 2';
        return $data;
    }


    /* ESCAPE TEST METHODS
     *************************************************************************/

    /**
     * @dataProvider providerAutoescapeConversion
     */
    public function testAutoescapeConversion($html, $md)
    {
        $this->assertEquals($md, $this->converter->parseString($html));
    }

    public function providerAutoescapeConversion()
    {
        return array(
            array('AT&amp;T', 'AT&T'),
            array('4 &lt; 5', '4 < 5'),
            array('&copy;', '&copy;')
        );
    }


    /* BLOCKQUOTE TEST METHODS
     *************************************************************************/

    /**
     * @dataProvider providerBlockquoteConversion
     */
    public function testBlockquoteConversion($html, $md)
    {
        $this->assertEquals($md, $this->converter->parseString($html));
    }

    public function providerBlockquoteConversion()
    {
        $data = array();
        $data['simple']['html'] = '<blockquote>blockquoted text goes here</blockquote>';
        $data['simple']['md'] = '> blockquoted text goes here';
        $data['paragraphs']['html'] = '<blockquote><p>paragraph1</p><p>paragraph2</p></blockquote>';
        $data['paragraphs']['md'] = '> paragraph1
> 
> paragraph2';
        $data['cascade']['html'] = '<blockquote><blockquote>cascading blockquote</blockquote></blockquote>';
        $data['cascade']['md'] = '> > cascading blockquote';
        $data['container']['html'] = '<blockquote><h2>This is a header.</h2></blockquote>';
        $data['container']['md'] = '> ## This is a header.';
        return $data;
    }


    /* LISTS TEST METHODS
     *************************************************************************/

    /**
     * @dataProvider providerListConversion
     */
    public function testListConversion($html, $md)
    {
        $this->assertEquals($md, $this->converter->parseString($html));
    }

    public function providerListConversion()
    {
        $data = array();
        $data['ordered']['html'] = '<ol><li>Bird</li><li>McHale</li><li>Parish</li></ol>';
        $data['ordered']['md'] = 
'  1. Bird
  2. McHale
  3. Parish';
        $data['unordered']['html'] = '<ul><li>Red</li><li>Green</li><li>Blue</li></ul>';
        $data['unordered']['md'] = 
'  * Red
  * Green
  * Blue';
        $data['paragraph']['html'] = '<ul><li><p>Bird</p></li><li><p>Magic</p></li></ul>';
        $data['paragraph']['md'] =
'  * Bird

  * Magic';
        $data['next-to-text']['html'] = 'McHale<ol><li>Bird</li><li>Magic</li></ol>';
        $data['next-to-text']['md'] = 'McHale

  1. Bird
  2. Magic';
        $data['next-to-text-in-block-context']['html'] = '<blockquote>McHale<ol><li>Bird</li><li>Magic</li></ol></blockquote>';
        $data['next-to-text-in-block-context']['md'] = '> McHale
> 
>   1. Bird
>   2. Magic';
        $data['next-to-bold']['html'] = '<b>McHale</b><ol><li>Bird</li><li>Magic</li></ol>';
        $data['next-to-bold']['md'] = '**McHale**

  1. Bird
  2. Magic';
        $data['next-to-paragraph']['html'] = '<p>McHale</p><ol><li>Bird</li><li>Magic</li></ol>';
        $data['next-to-paragraph']['md'] = 'McHale

  1. Bird
  2. Magic';
        $data['nested-ordered']['html'] = '<ol><li>Bird</li><li>Colors<ol><li>Red</li><li>Green<ol><li>Light</li><li>Dark</li></ol></li><li>Blue</li></ol></li></ol>';
        $data['nested-ordered']['md'] = 
'  1. Bird
  2. Colors
      1. Red
      2. Green
          1. Light
          2. Dark
      3. Blue';
        $data['nested-unordered']['html'] = '<ul><li>Bird</li><li>Colors<ul><li>Red</li><li>Green<ul><li>Light</li><li>Dark</li></ul></li><li>Blue</li></ul></li></ul>';
        $data['nested-unordered']['md'] = 
'  * Bird
  * Colors
      * Red
      * Green
          * Light
          * Dark
      * Blue';

        return $data;
    }
<commit_msg>Add a test case for the issue #7: a block content following a br tag<commit_after><?php

/* This file is part of the Markdownify project, which is under LGPL license */

namespace Test\Markdownify;

use Markdownify\Converter;

require_once(__DIR__ . '/../../../vendor/autoload.php');

class ConverterTestCase extends \PHPUnit_Framework_TestCase
{


    /* ATTRIBUTES
     *************************************************************************/
    protected $converter;
   

    /* HEADING TEST METHODS
     *************************************************************************/
    /**
     * @dataProvider providerHeadingConversion
     */
    public function testHeadingConversion_withAttribute($level, $attributesHTML, $attributesMD = null)
    {
        $innerHTML = 'Heading '.$level;
        if (empty($attributesHTML)) {
            $md = str_pad('', $level, '#').' '.$innerHTML;
        } else {
            $md = '<h'.$level.$attributesHTML.'>'."\n"
                .'  '.$innerHTML."\n"
                .'</h'.$level.'>';
        }
        $html = '<h'.$level.$attributesHTML.'>'.$innerHTML.'</h'.$level.'>';
        $this->assertEquals($md, $this->converter->parseString($html));
    }

    public function providerHeadingConversion()
    {
        $attributes = array(' id="idAttribute"', ' class=" class1  class2 "');
        $data = array();
        for ($i=1; $i<=6; $i++) {
            $data[] = array($i, '');
            $data[] = array($i, $attributes[0]);
            $data[] = array($i, $attributes[1]);
            $data[] = array($i, $attributes[0].$attributes[1]);
        } 
        return $data;
    }

    /**
     * @dataProvider providerHeadingConversionEscape
     */
    public function testHeadingConversionEscape($html, $md)
    {
        $this->assertEquals($md, $this->converter->parseString($html));
    }

    public function providerHeadingConversionEscape()
    {
        $data = array();
        $data['level1']['html'] = '# Heading 1';
        $data['level1']['md'] = '\# Heading 1';
        $data['level2']['html'] = '## Heading 2';
        $data['level2']['md'] = '\## Heading 2';
        return $data;
    }


    /* ESCAPE TEST METHODS
     *************************************************************************/

    /**
     * @dataProvider providerAutoescapeConversion
     */
    public function testAutoescapeConversion($html, $md)
    {
        $this->assertEquals($md, $this->converter->parseString($html));
    }

    public function providerAutoescapeConversion()
    {
        return array(
            array('AT&amp;T', 'AT&T'),
            array('4 &lt; 5', '4 < 5'),
            array('&copy;', '&copy;')
        );
    }


    /* BLOCKQUOTE TEST METHODS
     *************************************************************************/

    /**
     * @dataProvider providerBlockquoteConversion
     */
    public function testBlockquoteConversion($html, $md)
    {
        $this->assertEquals($md, $this->converter->parseString($html));
    }

    public function providerBlockquoteConversion()
    {
        $data = array();
        $data['simple']['html'] = '<blockquote>blockquoted text goes here</blockquote>';
        $data['simple']['md'] = '> blockquoted text goes here';
        $data['paragraphs']['html'] = '<blockquote><p>paragraph1</p><p>paragraph2</p></blockquote>';
        $data['paragraphs']['md'] = '> paragraph1
> 
> paragraph2';
        $data['cascade']['html'] = '<blockquote><blockquote>cascading blockquote</blockquote></blockquote>';
        $data['cascade']['md'] = '> > cascading blockquote';
        $data['container']['html'] = '<blockquote><h2>This is a header.</h2></blockquote>';
        $data['container']['md'] = '> ## This is a header.';
        return $data;
    }


    /* LISTS TEST METHODS
     *************************************************************************/

    /**
     * @dataProvider providerListConversion
     */
    public function testListConversion($html, $md)
    {
        $this->assertEquals($md, $this->converter->parseString($html));
    }

    public function providerListConversion()
    {
        $data = array();
        $data['ordered']['html'] = '<ol><li>Bird</li><li>McHale</li><li>Parish</li></ol>';
        $data['ordered']['md'] = 
'  1. Bird
  2. McHale
  3. Parish';
        $data['unordered']['html'] = '<ul><li>Red</li><li>Green</li><li>Blue</li></ul>';
        $data['unordered']['md'] = 
'  * Red
  * Green
  * Blue';
        $data['paragraph']['html'] = '<ul><li><p>Bird</p></li><li><p>Magic</p></li></ul>';
        $data['paragraph']['md'] =
'  * Bird

  * Magic';
        $data['next-to-text']['html'] = 'McHale<ol><li>Bird</li><li>Magic</li></ol>';
        $data['next-to-text']['md'] = 'McHale

  1. Bird
  2. Magic';
        $data['next-to-text-in-block-context']['html'] = '<blockquote>McHale<ol><li>Bird</li><li>Magic</li></ol></blockquote>';
        $data['next-to-text-in-block-context']['md'] = '> McHale
> 
>   1. Bird
>   2. Magic';
        $data['next-to-bold']['html'] = '<b>McHale</b><ol><li>Bird</li><li>Magic</li></ol>';
        $data['next-to-bold']['md'] = '**McHale**

  1. Bird
  2. Magic';
        $data['next-to-bold-and-br']['html'] = '<b>McHale</b><br><ol><li>Bird</li><li>Magic</li></ol>';
        $data['next-to-bold-and-br']['md'] = '**McHale**  


  1. Bird
  2. Magic';
        $data['next-to-paragraph']['html'] = '<p>McHale</p><ol><li>Bird</li><li>Magic</li></ol>';
        $data['next-to-paragraph']['md'] = 'McHale

  1. Bird
  2. Magic';
        $data['nested-ordered']['html'] = '<ol><li>Bird</li><li>Colors<ol><li>Red</li><li>Green<ol><li>Light</li><li>Dark</li></ol></li><li>Blue</li></ol></li></ol>';
        $data['nested-ordered']['md'] = 
'  1. Bird
  2. Colors
      1. Red
      2. Green
          1. Light
          2. Dark
      3. Blue';
        $data['nested-unordered']['html'] = '<ul><li>Bird</li><li>Colors<ul><li>Red</li><li>Green<ul><li>Light</li><li>Dark</li></ul></li><li>Blue</li></ul></li></ul>';
        $data['nested-unordered']['md'] = 
'  * Bird
  * Colors
      * Red
      * Green
          * Light
          * Dark
      * Blue';

        return $data;
    }

{'fraction_non_alphanumeric': 0.2674159160399967, 'fraction_numerical': 0.007520039666143294, 'mean_word_length': 2.8068575023592324, 'pattern_counts': {'":': 0, '<': 250, '<?xml version=': 0, '>': 296, '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': '572', 'n_tokens_mistral': 3918, 'n_tokens_neox': 3770, 'n_words': 586}