public static function escape($string) {
    $escaped_chars = str_split(self::ESCAPED_CHARACTERS);
    $escaped_chars_replace = array_map(function($char) {
      return '\\' . $char;
    }, $escaped_chars);
    $string = str_replace($escaped_chars, $escaped_chars_replace, $string);
    // Ignored whitespace.
    return preg_replace('/\s+/u', ' ', $string);
  }
public static function escape($string) {
    $escaped_chars = str_split(self::ESCAPED_CHARACTERS);
    $escaped_chars_replace = array_map(function($char) {
      return '\\' . $char;
    }, $escaped_chars);
    $string = str_replace($escaped_chars, $escaped_chars_replace, $string);
    // Ignored whitespace.
    return preg_replace('/\s+/u', ' ', $string);
  }
public static function escape ( $ string ) { $ escaped_chars = str_split ( self :: ESCAPED_CHARACTERS ) ; $ escaped_chars_replace = array_map ( function ( $ char ) { return '\\' . $ char ; } , $ escaped_chars ) ; $ string = str_replace ( $ escaped_chars , $ escaped_chars_replace , $ string ) ; // Ignored whitespace. return preg_replace ( '/\s+/u' , ' ' , $ string ) ; }
Escape Markdown special characters.

@param string $string
A string without any Markdown.

@return mixed
$string with any special characters escaped.
Escape Markdown special characters .