<commit_before><?php
/**
 * Small set of general helpers (aka "The missing PHP functions")
 *
 * @author      <NAME> <<EMAIL>>
 * @copyright   Creative Commons Attribution 3.0 Unported (CC BY 3.0)
 */

/**
 * Echo with htmlspecialchars
 *
 * @param   string  $string for outputting
 * @param   bool    $withBr convert line breaks into <br />. Optional,
 *  defaults to false
 */
function _echo ($string, $withBr = FALSE)
{
    echo(!$withBr
        ? htmlspecialchars($string)
        : nl2br(htmlspecialchars($string))
    );
}

/**
 * Echos string with some minimal output converting for HTML. Uses _paragraph
 *
 * @param   string  $string
 */
function _print_p ($string)
{
    echo (_paragraph($string));
}

/**
 * Does some minimal output converting for HTML.
 *
 * @param   string  $string
 * @return  string
 */
function _paragraph ($string)
{
    $string = '<p>'.nl2br(htmlspecialchars(trim($string))).'</p>';
    $string = preg_replace('#(<br/?>){2,}#','</p><p>',$string);
    return $string;
}
<commit_msg>Added links to _paragraph()<commit_after><?php
/**
 * Small set of general helpers (aka "The missing PHP functions")
 *
 * @author      <NAME> <<EMAIL>>
 * @copyright   Creative Commons Attribution 3.0 Unported (CC BY 3.0)
 */

/**
 * Echo with htmlspecialchars
 *
 * @param   string  $string for outputting
 * @param   bool    $withBr convert line breaks into <br />. Optional,
 *  defaults to false
 */
function _echo ($string, $withBr = FALSE)
{
    echo(!$withBr
        ? htmlspecialchars($string)
        : nl2br(htmlspecialchars($string))
    );
}

/**
 * Echos string with some minimal output converting for HTML. Uses _paragraph
 *
 * @param   string  $string
 * @param   bool    $withLinks
 */
function _print_p ($string, $withLinks = FALSE)
{
    echo (_paragraph($string, $withLinks));
}

/**
 * Does some minimal output converting for HTML.
 *
 * @param   string  $string
 * @param   bool    $withLinks
 * @return  string
 */
function _paragraph ($string, $withLinks = FALSE)
{
    $string = '<p>'.nl2br(htmlspecialchars(trim($string))).'</p>';
    $string = preg_replace('#(<br\s?/?>\s*){2,}#is',"</p>\n<p>",$string);
    if ($withLinks)
    {
        $string = preg_replace('#(http(s)?\://\S+)#is','<a href="$1">$1</a>',$string);
        $string = preg_replace('#(\S+@\S+)#ise',"'<a href=\"'.htmlallchars('mailto:\\1').'\">'.htmlallchars('\\1').'</a>'",$string);
    }
    return $string;
}

{'fraction_non_alphanumeric': 0.18208092485549132, 'fraction_numerical': 0.007431874483897605, 'mean_word_length': 3.3422939068100357, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, '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': '1143620', 'n_tokens_mistral': 817, 'n_tokens_neox': 801, 'n_words': 204}