<commit_before><?php
abstract class f_util_HtmlUtils
{
	const REGEXLINKTAG = '/<a\s+(.*?)>(.*?)<\/a>/i';
	const REGEXIMAGETAG = '/<img\s+(.*?)>/i';

	/**
	 * @param String $string
	 * @return String
	 */
	public static function nlTobr($string)
	{
		if (!empty($string))
		{
			return nl2br($string);
		}
		return $string;
	}

	/**
	 * @param string $string
	 * @return string
	 */
	public static function textToHtml($string)
	{
		if (!empty($string))
		{
			$string = htmlspecialchars($string, ENT_COMPAT, "utf-8");
			return nl2br($string);
		}
		return '';
	}
	
	/**
	 * @param String $string
	 * @param Boolean $translateUri
	 * @param Boolean $convertNlToSpace
	 * @return String
	 */
	public static function htmlToText($string, $translateUri = true, $convertNlToSpace = false)
	{
		if ($string === null)
		{
			return "";
		}
		$string = f_util_StringUtils::addCrLfToHtml($string);
		if ($translateUri)
		{
			$string = preg_replace(array('/<a[^>]+href="([^"]+)"[^>]*>([^<]+)<\/a>/i', '/<img[^>]+alt="([^"]+)"[^>]*\/>/i'), array('$2 [$1]',
				K::CRLF . '[$1]' . K::CRLF), $string);
		}
		$string = trim(html_entity_decode(strip_tags($string), ENT_QUOTES, 'UTF-8'));
		if ($convertNlToSpace)
		{
			$string = str_replace(K::CRLF, ' ', $string);
		}
		return $string;<commit_msg>[FIX #70402] textToHtml + 0<commit_after><?php
abstract class f_util_HtmlUtils
{
	const REGEXLINKTAG = '/<a\s+(.*?)>(.*?)<\/a>/i';
	const REGEXIMAGETAG = '/<img\s+(.*?)>/i';

	/**
	 * @param String $string
	 * @return String
	 */
	public static function nlTobr($string)
	{
		if (!empty($string))
		{
			return nl2br($string);
		}
		return $string;
	}

	/**
	 * @param string $string
	 * @return string
	 */
	public static function textToHtml($string)
	{
		if (!f_util_StringUtils::isEmpty($string))
		{
			$string = htmlspecialchars($string, ENT_COMPAT, "utf-8");
			return nl2br($string);
		}
		return '';
	}
	
	/**
	 * @param String $string
	 * @param Boolean $translateUri
	 * @param Boolean $convertNlToSpace
	 * @return String
	 */
	public static function htmlToText($string, $translateUri = true, $convertNlToSpace = false)
	{
		if ($string === null)
		{
			return "";
		}
		$string = f_util_StringUtils::addCrLfToHtml($string);
		if ($translateUri)
		{
			$string = preg_replace(array('/<a[^>]+href="([^"]+)"[^>]*>([^<]+)<\/a>/i', '/<img[^>]+alt="([^"]+)"[^>]*\/>/i'), array('$2 [$1]',
				K::CRLF . '[$1]' . K::CRLF), $string);
		}
		$string = trim(html_entity_decode(strip_tags($string), ENT_QUOTES, 'UTF-8'));
		if ($convertNlToSpace)
		{
			$string = str_replace(K::CRLF, ' ', $string);
		}
		return $string;
{'fraction_non_alphanumeric': 0.22905457340507301, 'fraction_numerical': 0.007686395080707148, 'mean_word_length': 3.8654205607476637, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '780653', 'n_tokens_mistral': 1118, 'n_tokens_neox': 999, 'n_words': 182}