Converts line breaks into <br /> tags
and double <br /> to </p><p> tags.

@param string $string

@return string
438425
public function nl2p($string)
    {
        // replace lineFeed with <br /> tag
        $lineFeed = chr(10);
        $value = preg_replace('#'.$lineFeed.'#', '<br />', $string);

        // replace double <br /> tags with </p><p> tags
        $pattern = '#<br />([ ]*)<br />#';
        $replacement = '</p><p>';
        $result = preg_replace($pattern, $replacement, $value);

        return $result;
    }
719838
final public static function handlifyString($string)
    {
        $string = preg_replace('/\W+/', '_', $string);
        $string = preg_replace('/([A-Z])/', '_$1', $string);
        $string = strtolower($string);
        $string = preg_replace('/_+/', '_', trim($string, '_'));

        return $string;
    }
112285
public function process($string)
    {
        preg_match_all($this->tagFilter, $string, $matches);

        if (!$matches) {
            return $string;
        }

        foreach ($matches[0] as $i => $m) {
            if (array_key_exists($matches[1][$i], $this->styles)) {
                $string = $this->replaceColors(
                    $string,
                    $matches[1][$i],
                    $matches[2][$i],
                    $this->styles[$matches[1][$i]]
                );
            } elseif (strpos($matches[1][$i], '=')) {
                // Custom format
                $string = $this->replaceColors(
                    $string,
                    $matches[1][$i],
                    $matches[2][$i],
                    ColorStyle::fromString($matches[1][$i])
                );
            }
        }

        return $string;
    }
1034358
public static function text($string, $breaksEnabled = true)
    {
        $parse = new Parsedown();
        $parse->setBreaksEnabled($breaksEnabled);

        return $parse->text($string);
    }
360640
public static function addTag(string $string, string $tag): string
    {
        $lastPoint = strrpos($string, '.');
        return ($tag ? substr_replace($string, sprintf('.%s.', $tag), $lastPoint, 1) : $string);
    }
1367444
protected function stripHtmlTags( $string )
	{
		$string = preg_replace( '@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string );
		$string = preg_replace( '@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string );
		$string = preg_replace( '@</(td|th)@iu', " \$0", $string );
		$string = preg_replace( '@<(li)[^>]*?>@siu', "\$0-o-^-o-", $string );
		$string = wp_strip_all_tags( $string );
		$string = wp_specialchars_decode( $string, ENT_QUOTES );
		$string = preg_replace( '/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string );
		$string = str_replace( '-o-^-o-', ' - ', $string );
		return html_entity_decode( $string, ENT_QUOTES, 'UTF-8' );
	}
957762
protected function parseString(/*# string */ $string)/*# : array */
    {
        $regex =
        '~^\s*+
            (?:
                (?:([^#\s=]++) \s*+ = \s*+
                    (?|
                        (([^"\'#\s][^#\n]*?)) |
                        (["\'])((?:\\\2|.)*?)\2
                    )?
                ) |
                (?: (\.|source) \s++ ([^#\n]*) )
            )\s*?(?:[#].*)?
        $~mx';

        if (preg_match_all($regex, $string, $matched, \PREG_SET_ORDER)) {
            return $this->clearPairs($matched);
        } else {
            return [];
        }
    }
1333001
public static function html2rgb( $string )
	{
		sscanf( $string, "%2X%2X%2X", $r, $g, $b );
		return array( $r, $g, $b );
	}
406915
public static function highlight($string)
    {
        $tokens = self::tokenize($string);

        $return = '';

        foreach ($tokens as $token) {
            $return .= self::highlightToken($token);
        }

        return self::output($return);
    }
569466
public function bBversHTML ($string = '')
    {
                $this->parserBB->setText($string);
                $this->parserBB->parse();
                return $this->parserBB->getParsed();
    }
1142004
public static function clean($string): string
    {
        $string = trim($string);
        $string = htmlspecialchars($string);
        return $string;
    }
12046
public function parseTags($string)
    {
        foreach ($this->tags as $tag => $code) {
            if (strpos($string, "<{$tag}>") !== false
                || strpos($string, "</{$tag}>") !== false
            ) {
                $string = str_replace("<{$tag}>", $code, $string);
                $string = str_replace("</{$tag}>", $this->tags['default'], $string);
            }
        }

        return $string . $this->tags['default'];
    }
1271867
protected function parseNumberTags(string $string): string
	{
		return preg_replace_callback('/\<number(:([0-9]+)(,(.)(,(.))?)?)?\>([0-9-.e]*)\<\/number\>/iu', function($matches)
		{
			return $this->number((float) $matches[7], ($matches[2] ?: 0), $matches[4], $matches[6]);
		}, $string);
	}
408448
private static function __doubleUnderlineBorder($string)
    {
        $border          = new Border(Border::TYPE_UNDERLINE, '=');
        $borderedElement = new BorderedElement($string, $border);

        return $borderedElement->render();
    }
1255818
public function formatMessage($string)
    {
        $string = str_replace('&', '&amp;', $string);
        $string = str_replace('<', '&lt;', $string);
        $string = str_replace('>', '&gt;', $string);

        return $string;
    }
1216899
public static function stripTags($string, $allowTags = '') {
		$string = strip_tags($string, $allowTags);
		$string = str_replace('&nbsp;', '', $string);
		$string = trim($string);

		return $string;
	}
378939
public static function makeByString($string)
    {
        $fg = $bg = '';
        $extra = false;
        $options = [];
        $parts = \explode(';', \str_replace(' ', '', $string));

        foreach ($parts as $part) {
            $subParts = \explode('=', $part);

            if (\count($subParts) < 2) {
                continue;
            }

            switch ($subParts[0]) {
                case 'fg':
                    $fg = $subParts[1];
                    break;
                case 'bg':
                    $bg = $subParts[1];
                    break;
                case 'extra':
                    $extra = (bool)$subParts[1];
                    break;
                case 'options':
                    $options = \explode(',', $subParts[1]);
                    break;
                default:
                    throw new \RuntimeException('Invalid option');
                    break;
            }
        }

        return new self($fg, $bg, $options, $extra);
    }